fix[Sticky]: fixed bug in resize #721

This commit is contained in:
Pan 2018-05-31 10:49:11 +08:00
parent bd0227feed
commit 03e5f762b3
1 changed files with 6 additions and 4 deletions

View File

@ -28,22 +28,21 @@ export default {
return { return {
active: false, active: false,
position: '', position: '',
currentTop: '',
width: undefined, width: undefined,
height: undefined, height: undefined
child: null,
stickyHeight: 0
} }
}, },
mounted() { mounted() {
this.height = this.$el.getBoundingClientRect().height this.height = this.$el.getBoundingClientRect().height
window.addEventListener('scroll', this.handleScroll) window.addEventListener('scroll', this.handleScroll)
window.addEventListener('resize', this.handleReize)
}, },
activated() { activated() {
this.handleScroll() this.handleScroll()
}, },
destroyed() { destroyed() {
window.removeEventListener('scroll', this.handleScroll) window.removeEventListener('scroll', this.handleScroll)
window.removeEventListener('resize', this.handleReize)
}, },
methods: { methods: {
sticky() { sticky() {
@ -70,6 +69,9 @@ export default {
return return
} }
this.reset() this.reset()
},
handleReize() {
this.width = this.$el.getBoundingClientRect().width + 'px'
} }
} }
} }