Skip to content

Commit aad1f5d

Browse files
authored
Merge pull request #641 from Jerit3787/carousel-fix
fix(Carousel) Fix onCycleTo not being called when slide changed
2 parents d7f6ab0 + 194a106 commit aad1f5d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/carousel/carousel.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,9 @@ export class Carousel extends Component<CarouselOptions> {
482482
this.el.classList.remove('scrolling');
483483
}, this.options.duration);
484484

485+
// Save last center before updating the center for onCycleTo callback
486+
const lastCenter = this.center;
487+
485488
// Start actual scroll
486489
this.offset = typeof x === 'number' ? x : this.offset;
487490
this.center = Math.floor((this.offset + this.dim / 2) / this.dim);
@@ -496,7 +499,6 @@ export class Carousel extends Component<CarouselOptions> {
496499
zTranslation: number,
497500
tweenedOpacity: number,
498501
centerTweenedOpacity: number;
499-
const lastCenter = this.center;
500502
const numVisibleOffset = 1 / this.options.numVisible;
501503

502504
// delta = this.offset - this.center * this.dim;

0 commit comments

Comments
 (0)