Impossible to determine slide direction in `beforeChange` handler with 2 slides
See original GitHub issueshort description of the bug / issue, provide more detail below.
The only parameters we get for the beforeChange
handler are event, slick, currentSlide, nextSlide
. There is no direction parameter. Therefore, going from currentSlide 0 to nextSlide 1 has ambiguous direction that is impossible to determine without knowing more information. Direction can be calculated if there are more than 2 slides because going left nextSlide would be numSlides -1 which can be used as an exception case in calculating direction.
We simply need a direction parameter to be passed to this handler.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:3
- Comments:8
Top Results From Across the Web
How to detect slide direction in Slick Carousel ...
beforeChange event get you an access to currentSlide and nextSlide values. It works for infinite sliders too. So, the code is:
Read more >slick - the last carousel you'll ever need - Ken Wheeler
slick is a responsive carousel jQuery plugin that supports multiple breakpoints, CSS3 transitions, touch events/swiping & much more!
Read more >kenwheeler/slick - Gitter
"using {infinite: false} , and beforeChange event to slick("goto", 0) if the next slide > total slides " didn't work, it works same...
Read more >„‚ THREE APPROACHES TO ORGANIZATIONAL LEARNING
Conceptually, organization development is different from both management training and management development. The latter two kinds of learning may, however, be ...
Read more >Fully Responsive & Flexible jQuery Carousel Plugin - slick
Slick is a feature-rich jQuery slider plugin for creating highly ... 2. Wrap the Html contents you want to slide in DIV elements....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For anyone who needs this behaviour today:
init slick without arrows
then implement your own next and prev buttons in your html and implement the following js
And afterwards you can use the
direction
variable in yourbeforeChange
event 😃In my case the animations I trigger on the beforeChange event are turned off on mobile devices; hence the above suffices for me. If you need the animations to work on touch devices you’ll need some extra logic.
I still think this would be a great addition to the Slick core; would make an already awesome slider even more awesome 👍
@notacouch didn’t think about that, maybe by also listening in on the keypress event and checking if it was the
enter
key should take care of that. oh, also adding the ariabutton
role to it?regardless, i’ve been saying this in every single issue that I get a new notification from, this project is dead. issues should be reaching 1000 issues now and the only recent pull request was a cosmetic update to show more accurate download numbers in npm.