akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.72k stars 2.1k forks source link

Prevent change slide #872

Closed hodovani closed 6 years ago

hodovani commented 6 years ago

Is there any way to prevent change slide?

I tried to catch beforeChange event and change state of slider to current slide but it doesn't help.

Also I tried to set initialSlide to catch if i lost mu curent index on rerender, but it doesn't help.

I had initialSlide: this.refs.slider ? this.refs.slider.innerSlider.state.currentSlide : 1, and on rerender it doesn't set to 1. It just go to 0 and I can do nothing with that/

laveesingh commented 6 years ago

Closing as stale. If still facing any problem related to this. Please reopen with more details or perhaps a codesandbox demo.

paulcredmond commented 6 years ago

@laveesingh Can we reopen this? I'd like the same functionality.

Discussion on the same topic on the main JS version here: https://github.com/kenwheeler/slick/pull/2104

pbortnick commented 6 years ago

I had this issue when trying to prevent keyboard left/right clicks from moving the slides. What I used was an onClick event and blur() in order to prevent. handleClick(e) { var target = e.target.closest('.slick-slide') || e.target target.blur() }

hope this helps!

paulcredmond commented 6 years ago

@pbortnick I did something similar, but the ideal solution I think is to show an animation and have it 'bounce' back so the user is aware the action (prev/next) works but is not allowed to go to the next slide. In my situation it's a slider of form fields so you need to complete the current field before being allowed to move on to the next one.

hodovani commented 6 years ago

@paulcredmond do you have realization of your idea?

ryonwasis311 commented 11 months ago

how to prevent the Splatter effect in react-slick