Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Bug: infinite slider doesn't show if contained slides is less than slidesToShow #89

Open
chivent opened this issue Jul 18, 2019 · 0 comments

Comments

@chivent
Copy link

chivent commented Jul 18, 2019

For example if options are set to slidesToShow:3, infinite:true and there are only 2 slides in the carousel, the carousel will be shown as empty with a cloneNode error.

It might be due to the calculations for infinite slides, where calculated slideIndex goes into negatives once infiniteCount >= slider.state.length, and a cloneNode error occurs as this.slider.slides[-1] is undefined


// infinite.js: 16-19
for (var i = this.slider.state.length; i > this.slider.state.length - 1 - this._infiniteCount; i -= 1) {
	slideIndex = i - 1;
	frontClones.unshift(this._cloneSlide(this.slider.slides[slideIndex], slideIndex - this.slider.state.length));
}

however I might be wrong, would be cool if there was a fix!

tan-z-tan added a commit to tan-z-tan/bulma-carousel that referenced this issue Oct 9, 2020
## WHY
I encountered `cloneNode` error while using bulma-carousel with `infinite` option true.

```
Uncaught TypeError: Cannot read property 'cloneNode' of undefined
```

As mentioned in the issue Wikiki#89, the error occurs when i set `infinite: true` and `slidesToShow` value is greater or equal to the length of the `.carousel-item` elements because the index goes to negative.

## WHAT
Fix the index calculation to get always get a positive index (within the length).
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

1 participant