Commit 91c40d31 authored by Harlan's avatar Harlan Committed by GitHub

Carousel: stop timer before component destroyed (#13820)

Carousel: stop timer before component destroyed (#13820)
parents f3bf6ee1 23e81831
...@@ -181,11 +181,14 @@ export default { ...@@ -181,11 +181,14 @@ export default {
}, },
pauseTimer() { pauseTimer() {
if (this.timer) {
clearInterval(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 { ...@@ -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>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment