beyonk-group / svelte-carousel

A super lightweight, super simple Carousel for Svelte 3
MIT License
213 stars 38 forks source link

Cannot set a 'current' slide index less than 2. #3

Closed antony closed 6 years ago

antony commented 6 years ago

Not sure why but I've just noticed this. Needs some investigation.

s0kil commented 6 years ago

This bug seems to be coming from requiredSeat constant in the oncreate method. When setting current to 1, requiredSeat is equal to -1, and then newSeat.style.order is trying to set 1 on undefined, in the setNewSeatOrder method.

I can't quite figure out what your intention is in the requiredSeat algorithim.

antony commented 6 years ago

@DanielSokil it wasn't really my algorithm - it comes from the original codepen I based the carousel on, but I remember a skew of -1 on the numbers, since I believe the last slide becomes the first, in case you wanted to go backwards as your first move.

However - thanks for this bit of sleuthing, it should make it quite trivial to fix!