Tiny-slider: Wrong index in indexChanged event

Created on 28 Feb 2018  路  9Comments  路  Source: ganlanyuan/tiny-slider

__Issue description__:
When slide have changed, indexChanged event returning wrong index.
I'm expecting to have indexes from 0 or 1 to N, but instead getting some random values,

demo

__Demo link/slider setting__:
https://codepen.io/makedonec88/pen/MQZLmL
_Tiny-slider version_: 2.6.0

Most helpful comment

@ganlanyuan Why don't make this math go inside of the plugin and return already operational index that represents expected way of things?

All 9 comments

Hey, the output is actually correct.
Since the default options for loop is true, so there are some cloned slides before the first slide displayed on the screen.
If you want to see the index from 0 ~ n, set loop: false.

although I remember getting around this by using data attributes.
It would be nice to have a displayIndex, currentSlide or something along those lines.

index - cloneCount = visual index

@ganlanyuan Why don't make this math go inside of the plugin and return already operational index that represents expected way of things?

If I do that way, instead of getting the first visible slide when you do slides[info.index], you will get a cloned slide which is not visible. That's a big problem too.

How is implementing index - cloneCount = visual index math inside slider codebase will produce situation you've described?

So did you mean add one more variable: visualIndex to present the current visual index?

Would indeed be nice to have a visualIndex to make a slide indicator
e.g: 02/07

displayIndex added. (https://github.com/ganlanyuan/tiny-slider/issues/304#issuecomment-432386766)
Will be available in next release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DuckThom picture DuckThom  路  5Comments

CristianEstiber picture CristianEstiber  路  3Comments

youradds picture youradds  路  3Comments

notrealdev picture notrealdev  路  5Comments

matheusgrieger picture matheusgrieger  路  3Comments