tiny-slider
tiny-slider copied to clipboard
centered doesn't work with decimal item numbers
Issue description:
Using a decimal to indicate number of items (e.g. items: 3.3, ) causes the center property to miscalculate the position of the 'centered' slide, failing to account for the offset.
Demo link/slider setting: https://codepen.io/wearingalampshade/pen/rNVmwaw
Tiny-slider version: current Browser name && version: current versions of firefox and chrome OS name && version: max catalina baby
This bug was also affecting me but I was able to "fix" it by translating my slides in css.
If I'm supposed to have 1.4 slides, centered, I add the "transform: translateX(20%);" styles to my slide items.
This bug was also affecting me but I was able to "fix" it by translating my slides in css.
If I'm supposed to have 1.4 slides, centered, I add the "transform: translateX(20%);" styles to my slide items.
Just in case someone stumbles upon this, I can say it works. Thanks for the suggestion!
Stumbled on this issue as well and ChatonMeow's solution worked.
this bug still bugs
this bug still bugs
@OwenMagelssen At this point I'd suggest just switching to https://swiperjs.com/, this project hasn't been updated in the last 2 years, while SwiperJS works really great and has integrations with all the common frameworks.
this bug still bugs
@OwenMagelssen At this point I'd suggest just switching to https://swiperjs.com/, this project hasn't been updated in the last 2 years, while SwiperJS works really great and has integrations with all the common frameworks.
thank you for the recommendation
I think this is due to this line.
Removing the Math.floor rounding function:
items = !autoWidth ? Math.floor(getOption('items')) : 1,
so that it reads:
items = !autoWidth ? getOption('items') : 1,
preserves any decimal value you might assign to it. The horizontal transform for the container is then correctly calculated so that it centers correctly.