Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit 6bbd481

Browse files
Nekojita1CarterLi
authored andcommitted
Carousel: reset the timer when setActiveItem method is called (ElemeFE#20846)
1 parent 00d4d07 commit 6bbd481

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/carousel/src/main.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ export default {
236236
this.timer = setInterval(this.playSlides, this.interval);
237237
},
238238
239+
resetTimer() {
240+
this.pauseTimer();
241+
this.startTimer();
242+
},
243+
239244
setActiveItem(index) {
240245
if (typeof index === 'string') {
241246
const filteredItems = this.items.filter(item => item.name === index);
@@ -260,6 +265,7 @@ export default {
260265
if (oldIndex === this.activeIndex) {
261266
this.resetItemPosition(oldIndex);
262267
}
268+
this.resetTimer();
263269
},
264270
265271
prev() {

0 commit comments

Comments
 (0)