Skip to content

Commit

Permalink
fix(module: carousel): fix carousel not stopping when number of carou…
Browse files Browse the repository at this point in the history
…sels decreased to 1 (#865)
  • Loading branch information
aijunhao committed Jan 4, 2023
1 parent 3ffa485 commit 4cbefd4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions components/carousel/carousel.component.ts
Expand Up @@ -226,6 +226,7 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
v.top = 0;
v.margin = `auto ${this.cellSpacing / 2}px`;
});
this.stopTimer();
}, 0);
}
}
Expand Down Expand Up @@ -351,15 +352,17 @@ export class CarouselComponent implements AfterViewInit, OnDestroy {
if (afterIndex === 0) {
setTimeout(() => {
this._nodeArr.forEach((v, index) => {
if (index === this._nodeArr.length - 1) {
if (this._nodeArr.length > 1 && index === this._nodeArr.length - 1) {
v.left = this.vertical ? 0 : -this._rationWidth;
v.top = this.vertical ? -this._rationWidth : 0;
} else {
v.left = this.vertical ? 0 : index * this._rationWidth;
v.top = this.vertical ? index * this._rationWidth : 0;
}
});
this.startTimer();
if (this._nodeArr.length > 1) {
this.startTimer();
}
this.getListStyles(0);
}, this.speed);
}
Expand Down

0 comments on commit 4cbefd4

Please sign in to comment.