slick: Can't prevent change of current slide
I’d love to be able to prevent a user going to a certain steps until some conditions are met.
It’s great that there are so many events but we need to be able to call e.preventDefault()
or something like that. Or even if in a beforeChange
callback you could overwrite the nextSlide
slide passed in (for example: nextSlide = currentSlide
). The closest I got was using slickGoTo
inside a setPosition
callback but then I realised this was causing an infinite loop and would require me to manage some slick state stuff outside of slick.
About this issue
- Original URL
- State: open
- Created 9 years ago
- Comments: 26 (3 by maintainers)
think about this logically…
Why would you want to prevent the slideChange when you’ve already triggered the slideChange? - it doesn’t make sense.
If you want to prevent changing slides, then run the logic before you change slides and change the carousel options to disallow interaction… do not allow user to change slides and then stop half way through.
So wait, you want slick to have a disabled state? I’m not sure I have anything set up for that, because I’ve never intentionally wanted to disable its functionality.
If a client came to me wanting this, I’d probably layer a div on top of slick that intercepted and killed events until my condition to enable slick was met. Not a core solution, but likely the simplest.
Yep, creating sliders is super easy if you’re doing it for your own situation with very few variables 😃 when your client starts asking for changes, features, crazy shit, though, that’s when you come back to Slick aahahah ^^;