mirror of https://github.com/ElemeFE/element
Carousel: stop timer before component destroyed (#13820)
Carousel: stop timer before component destroyed (#13820)pull/13930/head
commit
91c40d311e
|
@ -181,11 +181,14 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
pauseTimer() {
|
pauseTimer() {
|
||||||
clearInterval(this.timer);
|
if (this.timer) {
|
||||||
|
clearInterval(this.timer);
|
||||||
|
this.timer = null;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
startTimer() {
|
startTimer() {
|
||||||
if (this.interval <= 0 || !this.autoplay) return;
|
if (this.interval <= 0 || !this.autoplay || this.timer) return;
|
||||||
this.timer = setInterval(this.playSlides, this.interval);
|
this.timer = setInterval(this.playSlides, this.interval);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -257,6 +260,7 @@ export default {
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
if (this.$el) removeResizeListener(this.$el, this.resetItemPosition);
|
if (this.$el) removeResizeListener(this.$el, this.resetItemPosition);
|
||||||
|
this.pauseTimer();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue