@@ -437,7 +437,7 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
437437 private newDuration = 0 ;
438438
439439 constructor ( private element : ElementRef , private iterableDiffers : IterableDiffers ,
440- private builder : AnimationBuilder , private platformUtil : PlatformUtil ) {
440+ private builder : AnimationBuilder , private platformUtil : PlatformUtil ) {
441441 this . differ = this . iterableDiffers . find ( [ ] ) . create ( null ) ;
442442 }
443443
@@ -481,6 +481,12 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
481481 if ( this . animationType !== CarouselAnimationType . none ) {
482482 if ( animationWasStarted ) {
483483 requestAnimationFrame ( ( ) => {
484+ if ( this . leaveAnimationPlayer ) {
485+ this . leaveAnimationPlayer . reset ( ) ;
486+ }
487+ if ( this . enterAnimationPlayer ) {
488+ this . enterAnimationPlayer . reset ( ) ;
489+ }
484490 this . playAnimations ( ) ;
485491 } ) ;
486492 } else {
@@ -505,13 +511,8 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
505511 if ( this . previousSlide && this . previousSlide . previous ) {
506512 this . previousSlide . previous = false ;
507513 }
508- if ( this . leaveAnimationPlayer ) {
514+ if ( this . leaveAnimationPlayer || this . enterAnimationPlayer ) {
509515 animationWasStarted = true ;
510- this . leaveAnimationPlayer . finish ( ) ;
511- }
512- if ( this . enterAnimationPlayer ) {
513- animationWasStarted = true ;
514- this . enterAnimationPlayer . finish ( ) ;
515516 }
516517 return animationWasStarted ;
517518 }
@@ -565,10 +566,11 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
565566 }
566567
567568 private playEnterAnimation ( ) {
568- if ( ! this . getAnimation ( ) . enterAnimation ) {
569+ const animation = this . getAnimation ( ) . enterAnimation ;
570+ if ( ! animation ) {
569571 return ;
570572 }
571- const animationBuilder = this . builder . build ( this . getAnimation ( ) . enterAnimation ) ;
573+ const animationBuilder = this . builder . build ( animation ) ;
572574
573575 this . enterAnimationPlayer = animationBuilder . create ( this . currentSlide . nativeElement ) ;
574576
@@ -586,11 +588,12 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
586588 }
587589
588590 private playLeaveAnimation ( ) {
589- if ( ! this . getAnimation ( ) . leaveAnimation ) {
591+ const animation = this . getAnimation ( ) . leaveAnimation ;
592+ if ( ! animation ) {
590593 return ;
591594 }
592595
593- const animationBuilder = this . builder . build ( this . getAnimation ( ) . leaveAnimation ) ;
596+ const animationBuilder = this . builder . build ( animation ) ;
594597 this . leaveAnimationPlayer = animationBuilder . create ( this . previousSlide . nativeElement ) ;
595598
596599 this . leaveAnimationPlayer . onDone ( ( ) => {
@@ -1021,7 +1024,15 @@ export class IgxCarouselComponent implements OnDestroy, AfterContentInit {
10211024 this . stoppedByInteraction = true ;
10221025 this . stop ( ) ;
10231026 }
1024- this . finishAnimations ( ) ;
1027+ const animationWasStarted = this . finishAnimations ( ) ;
1028+ if ( animationWasStarted ) {
1029+ if ( this . leaveAnimationPlayer ) {
1030+ this . leaveAnimationPlayer . finish ( ) ;
1031+ }
1032+ if ( this . enterAnimationPlayer ) {
1033+ this . enterAnimationPlayer . finish ( ) ;
1034+ }
1035+ }
10251036
10261037 if ( this . incomingSlide ) {
10271038 if ( index !== this . incomingSlide . index ) {
0 commit comments