Skip to content

Commit ea60cc0

Browse files
authored
Merge pull request #23 from eiamei/fix-for-padding
Possible fix for autosize issue if padding not 0
2 parents 0b4c352 + 664854f commit ea60cc0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/mixins/window_size.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ export default {
55
windowWidth: 0
66
}
77
},
8-
98
created () {
109
window.addEventListener('resize', this.getWindowSize)
1110
this.getWindowSize()
1211
},
13-
12+
mounted () {
13+
this.getWindowSize()
14+
},
1415
beforeDestroy () {
1516
window.removeEventListener('resize', this.getWindowSize)
1617
},
1718

1819
methods: {
1920
getWindowSize () {
20-
this.windowHeight = window.innerHeight
21-
this.windowWidth = window.innerWidth
21+
if (this.$el) {
22+
this.windowHeight = this.$el.clientHeight
23+
this.windowWidth = this.$el.clientWidth
24+
}
2225
}
2326
}
2427
}

0 commit comments

Comments
 (0)