Linkd-Inc / ngx-slideshow

An Agular 2+ slideshow component
5 stars 0 forks source link

feature request: goTo() #6

Closed RafaelC457ro closed 6 years ago

RafaelC457ro commented 6 years ago

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Desired functionality

A good function could be goTo(), to slide to index given. I need this for create a minimap of images, and when user click make possible change image on slide. expect to be:

<p (click)="carousel.left()">Left</p>
<ngx-slideshow-component #carousel [cards]="3" [cardSize]="'350px'" [padding]="'14px'">
  <li><img src="http://via.placeholder.com/350x150"></li>
  <li><img src="http://via.placeholder.com/350x150"></li>
  <li><img src="http://via.placeholder.com/350x150"></li>
</ngx-slideshow-component>
<p (click)="carousel.right()">Right</p>
<p (click)="carousel.goTo(2)">Slide index 2</p>

I can help if you let me. Thanks.

crutchcorn commented 6 years ago

This would be easily done. I'll take a look at that today in a few hours, make sure that everything is working, and press a new release. Expect it done by the end of today.

Otherwise, if you wanted to do so yourself, you could add something like (this code SHOULD work AFAIK):

  goTo(i) {
    if (i > this.max || i < this.min) {
      return 'Error'; // Or some other kind of error
    } else {
      this.index = i;
      this.setLeft();
    }
  }
crutchcorn commented 6 years ago

I just added some similar functions: leftBy(i) and rightBy(i). You might be able to guess what they do, but I updated the documentation (README) just in case