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