Carousel: reset the timer when setActiveItem method is called (#20846)

pull/21193/head
Nekojita1 2021-07-28 15:05:24 +08:00 committed by GitHub
parent 1ef72a3283
commit f1252dcf61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -236,6 +236,11 @@ export default {
this.timer = setInterval(this.playSlides, this.interval);
},
resetTimer() {
this.pauseTimer();
this.startTimer();
},
setActiveItem(index) {
if (typeof index === 'string') {
const filteredItems = this.items.filter(item => item.name === index);
@ -260,6 +265,7 @@ export default {
if (oldIndex === this.activeIndex) {
this.resetItemPosition(oldIndex);
}
this.resetTimer();
},
prev() {