Skip to content
This repository has been archived by the owner on Oct 20, 2018. It is now read-only.

Can't move to first slide with moveToSlide #55

Closed
ejahn opened this issue Nov 18, 2017 · 2 comments
Closed

Can't move to first slide with moveToSlide #55

ejahn opened this issue Nov 18, 2017 · 2 comments

Comments

@ejahn
Copy link

ejahn commented Nov 18, 2017

Hi @sheikalthaf,

When changing the value for the input moveToSlide, jumping to the first slide with index 0 doesn't work.

I assume this is because 0 gets evaluated as falsy when using logical operators.
In ngx-carousel.components.ts, line 253:

ngOnChanges(changes: SimpleChanges) {
  // tslint:disable-next-line:no-unused-expression
  this.moveToSlide &&
    !changes.moveToSlide.firstChange &&
    this.moveTo(changes.moveToSlide.currentValue);
}

Changing line 255 to: this.moveToSlide != null && would solve the problem.

Did you have something special in mind, when writing this code, or is this maybe a bug?

@iamlothian
Copy link
Contributor

@ejahn good spot. Some propper testing should have picked this up. For now setting to -1 works for my usecase.

@sheikalthaf
Copy link
Owner

@ejahn Fixed the bug in Build v1.3.4
Big thanks to @iamlothian for the solution
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants