nerdyman / react-compare-slider

A slider component to compare any two React components in landscape or portrait orientation. It supports custom images, videos... and everything else.
https://react-compare-slider.vercel.app
MIT License
259 stars 17 forks source link

Preventing slide on click #158

Open monolithed opened 2 days ago

monolithed commented 2 days ago

In continuation of the discussion about the behavior of onlyHandleDraggable, I’d like to suggest adding a flag that would prevent sliding on click.

I tried creating a custom component and attaching a drag event (down + move) to it, but they don't bubble up even when using reactCompareSliderRef. Unfortunately, there’s no way to prevent event propagation in onPositionChange either.

It seems like solving this without modifying the internal logic isn't possible.

nerdyman commented 1 day ago

Thanks for opening this @monolithed. You can probably prevent the current behaviour by using reactCompareSliderRef and ev.stopImmediatePropagation() but it may still not work since the slider applies some internal state on pointer down.

This is definitely a valid issue but it may not be in the initial v4 release. I'll take a look in the coming days and if it's simple enough to implement I'll look at adding it with the main v4 release.

Also open to PRs!