Skip to content

Commit 03e5f76

Browse files
committed
fix[Sticky]: fixed bug in resize PanJiaChen#721
1 parent bd0227f commit 03e5f76

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/components/Sticky/index.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,21 @@ export default {
2828
return {
2929
active: false,
3030
position: '',
31-
currentTop: '',
3231
width: undefined,
33-
height: undefined,
34-
child: null,
35-
stickyHeight: 0
32+
height: undefined
3633
}
3734
},
3835
mounted() {
3936
this.height = this.$el.getBoundingClientRect().height
4037
window.addEventListener('scroll', this.handleScroll)
38+
window.addEventListener('resize', this.handleReize)
4139
},
4240
activated() {
4341
this.handleScroll()
4442
},
4543
destroyed() {
4644
window.removeEventListener('scroll', this.handleScroll)
45+
window.removeEventListener('resize', this.handleReize)
4746
},
4847
methods: {
4948
sticky() {
@@ -70,6 +69,9 @@ export default {
7069
return
7170
}
7271
this.reset()
72+
},
73+
handleReize() {
74+
this.width = this.$el.getBoundingClientRect().width + 'px'
7375
}
7476
}
7577
}

0 commit comments

Comments
 (0)