Skip to content

Commit ed0d5fa

Browse files
committed
fix: CCollapse: fix blinking when animation duration is 0ms
1 parent 9f8aeec commit ed0d5fa

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/components/collapse/CCollapse.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ export default {
3434
this.visible = val
3535
},
3636
visible (val) {
37-
this.collapseController(val)
37+
if (this.duration) {
38+
this.collapseController(val)
39+
} else {
40+
this.reset()
41+
}
3842
}
3943
},
4044
mounted () {
@@ -74,15 +78,15 @@ export default {
7478
},
7579
setFinishTimer (duration) {
7680
clearTimeout(this.heightWatcher)
77-
const self = this
78-
this.heightWatcher = setTimeout(() => {
79-
self.collapsing = false
80-
self.$el.style.display = self.visible ? '' : 'none'
81-
self.$el.style.height = ''
82-
self.$el.style.overflow = ''
83-
self.$el.style.transition = ''
84-
this.$emit('finish', self.visible)
85-
}, duration)
81+
this.heightWatcher = setTimeout(() => this.reset(), duration)
82+
},
83+
reset () {
84+
this.collapsing = false
85+
this.$el.style.display = this.visible ? '' : 'none'
86+
this.$el.style.height = ''
87+
this.$el.style.overflow = ''
88+
this.$el.style.transition = ''
89+
this.$emit('finish', this.visible)
8690
}
8791
}
8892
}

0 commit comments

Comments
 (0)