kenwheeler / slick

the last carousel you'll ever need
kenwheeler.github.io/slick
MIT License
28.49k stars 5.89k forks source link

`initialSlide` set as "0" or "1" (String) breaks slider navigation #3176

Open eugene-lazarev opened 6 years ago

eugene-lazarev commented 6 years ago

====================================================================

[ http://jsfiddle.net/t2hrte78/1/ ]

====================================================================

Steps to reproduce the problem

  1. Set initialSlide to "0" or "1" (String type).
  2. Click on right arrow or wait for autoplay.
  3. Slick goes to the 12-th slide after 2-nd (from 1 to 11).

====================================================================

What is the expected behaviour?

Slick goes to 3-rd slide after 2-nd.

====================================================================

What is observed behaviour?

Slick goes to the 12-th slide after 2-nd (from 1 to 11).

====================================================================

Simple solution

Please use parseInt function for must-be-numeric variables sent by the user.

====================================================================

Thanks for great carousel!

DHDaniel commented 6 years ago

Hi @eugene-lazarev ! In the Slick documentation (http://kenwheeler.github.io/slick/), the "settings" part specifies that the initialSlide setting must be of type integer, so I'm not sure that converting strings to integers is the best solution (a.k.a the user should be responsible for that). However, perhaps type checking should be put in place to give the user an informative error if they fail to provide the right type - right now it fails silently, and the user might not know what they've done wrong.

I'd be willing to take this on, but I need the blessing of the maintainers @kenwheeler @simeydotme

eugene-lazarev commented 6 years ago

Thanks @DHDaniel, But I'm pretty sure the best way to do something in IT is to predict user's mistakes and fix it 'under the hook' without any notice.

Because this is Javascript, you know, here is the difference between 1 and "1" is extremely small. It's obviously that user wants to set initialSlide on 1, not "1". I can't see any reasons why don't help him without any noise :)

Anyway, I respect any of your decision here. Thanks again.