fix[Sticky]: fixed bug in resize #724

This commit is contained in:
Pan 2018-05-31 13:22:12 +08:00
parent 03e5f762b3
commit 0375542009

View file

@ -29,7 +29,8 @@ export default {
active: false, active: false,
position: '', position: '',
width: undefined, width: undefined,
height: undefined height: undefined,
isSticky: false
} }
}, },
mounted() { mounted() {
@ -52,6 +53,7 @@ export default {
this.position = 'fixed' this.position = 'fixed'
this.active = true this.active = true
this.width = this.width + 'px' this.width = this.width + 'px'
this.isSticky = true
}, },
reset() { reset() {
if (!this.active) { if (!this.active) {
@ -60,6 +62,7 @@ export default {
this.position = '' this.position = ''
this.width = 'auto' this.width = 'auto'
this.active = false this.active = false
this.isSticky = false
}, },
handleScroll() { handleScroll() {
this.width = this.$el.getBoundingClientRect().width this.width = this.$el.getBoundingClientRect().width
@ -71,8 +74,10 @@ export default {
this.reset() this.reset()
}, },
handleReize() { handleReize() {
if (this.isSticky) {
this.width = this.$el.getBoundingClientRect().width + 'px' this.width = this.$el.getBoundingClientRect().width + 'px'
} }
} }
}
} }
</script> </script>