How do you cancel a slider event programmatically? #4764
-
Hi, I'm trying to figure out how to cancel a moving slide event programmatically. In React, I have attached a
But they all don't cancel the current slide event. The reason I wish to cancel this is because in the component, I have a separate element detecting a long press, and then an overlay shows up. But while long pressing, you can move the Swiper, and after 200ms, an overlay appears, but you can continue moving the Swiper. But I wish to cancel the touch event upon the overlay showing, and I tried the 3 methods above but they don't seem to be canceling an ongoing touch event correctly. Appreciate any help, thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Sorry, I managed to accomplish this with |
Beta Was this translation helpful? Give feedback.
Sorry, I managed to accomplish this with
swiper.current.swiper.disable()
. It was a mistake on my part as I have nested swiping and I was testing the disabling on the wrong nested Swiper. Also I don't actually cancel any Swiper movements, I just disable it if the long press event is started, and enable it if the long press event is canceled or after the overlay has disappeared.