Skip to content

Commit

Permalink
fix(esl-carousel): fix initial index normalization and long animation…
Browse files Browse the repository at this point in the history
… speed
  • Loading branch information
ala-n committed Aug 21, 2024
1 parent 9ab2b6b commit 45c7560
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ESLDefaultCarouselRenderer extends ESLCarouselRenderer {
* Prepare to renderer animation.
*/
public override onBind(): void {
this.currentIndex = this.normalizeIndex(this.$carousel.activeIndex);
this.currentIndex = this.normalizeIndex(Math.max(0, this.$carousel.activeIndex));
this.redraw();
}

Expand Down Expand Up @@ -100,7 +100,7 @@ export class ESLDefaultCarouselRenderer extends ESLCarouselRenderer {
this.currentIndex = activeIndex;
if (!$slidesArea) return;
const distance = normalize((nextIndex - activeIndex) * direction, this.size);
const speed = Math.max(1, distance / this.count);
const speed = Math.min(1, this.count / distance);
while (this.currentIndex !== nextIndex) {
await this.onStepAnimate(direction * this.INDEX_MOVE_MULTIPLIER, params.stepDuration * speed);
}
Expand Down

0 comments on commit 45c7560

Please sign in to comment.