returnIndex returns 0 when slides count is not a multiple of slidesToScroll
@meandmax is already working on this.
Since Jun 28, 2017.
- Dominant language
- JavaScript
- Stars
- 2.3k
- Forks
- 232
- PR merge metrics
- No merged PRs in 30d
Description
This special use case is currently bugging me - I have varying numbers of slides and I want to hide the next/prev slider buttons when the slides are at the beginning or the end of the list. But **when the total number of slide elements is less than 2 * slidesToScroll** (the number of slides that are visible at once in my case (4 in the example)), **then returnIndex() returns 0**. If there are more than 2 * slidesToScroll but still not an exact multiple of slidesToScroll, then at the end of the scrolling - i.e. when the last slide is reached - returnIndex() returns the previous index.
For example when I have 4 slides visible and slidesToScroll equals 4, and I have 14 slides, then when the last slide is reached, returnIndex() returns 12 instead of 14.
I've prepared a codepen for this:
[http://codepen.io/rseidelsohn/pen/OpxGjr](http://codepen.io/rseidelsohn/pen/OpxGjr)
This special issue could be resolved by changing
```javascript
/**
* update the index with the nextIndex only if
* the offset of the nextIndex is in the range of the maxOffset
*/
if (slides[nextIndex].offsetLeft <= maxOffset) {
index = nextIndex;
}
```
to
```javascript
/**
* update the index with the nextIndex always
*/
index = nextIndex;
```
but I haven't figured out under which condition this will break the slider functionality - so far in our project it works all fine.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.