nir9 / itemslide

JavaScript Touch Carousel Library with Zero Dependencies

Home Page:https://itemslide.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clamp to half width if outer container contains an even number of elements

PurHur opened this issue · comments

The items will clamp to the half width if the outer container contains (in the visible part) an even number of elements. If its uneven it works perfect.

Did anybody encounter this problem before?

The bug is in getPositionByIndex

    return -(i * slides.children().outerWidth(true) - ((slides.parent().outerWidth(true) - slides.children().outerWidth(true)) / 2))

i think the / 2 is only useful if the slider is not a left_sided.

I don't really get the problem i'm now testing and i see no problem when there is an even amount of elements. can you provide an example that doesn't work (jsfiddle or something)?

Here you go:
http://jsfiddle.net/k0vh8jwc/1/ (pull the testing window to full size)

with -[margin right of an item](not / 2) it works

Ok i see, i'll work on a fix.

Added your fix, thanks.