-
Hi there! I'm using compare slider I want to disable the sliding functionality while showing the slider bar on some occasions. Is there a way to keep the slider bar at a fixed position and not make it draggable? Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hey @nigow! There's no built in functionality disable the slider at the moment but it should be simple enough to do with a custom pointer event. I've hacked together a quick demo that applies its own return (
<ReactCompareSlider
// ...
onPointerDown={(ev) => {
if (!enabled) {
ev.preventDefault();
}
}}
/>
) https://codesandbox.io/s/react-compare-slider-disable-enable-slider-qk8pb?file=/src/App.jsx:886-1035 Let me know if this does what you need. *Edit I changed the demo so it disables the entire slider instead of just the handle. |
Beta Was this translation helpful? Give feedback.
-
Hi @nerdyman , Can you suggest whether there is an alternative of onPointerDown prop for mobile devices? I have tried onTouchStart and onTouchEnd but it doesn't seem to work |
Beta Was this translation helpful? Give feedback.
-
This has been released in v3! See the npm install react-compare-slider@latest
yarn add react-compare-slider@latest
pnpm install react-compare-slider@latest |
Beta Was this translation helpful? Give feedback.
Hey @nigow!
There's no built in functionality disable the slider at the moment but it should be simple enough to do with a custom pointer event.
I've hacked together a quick demo that applies its own
onPointerDown
binding to the slider which prevents the slider from moving whenenabled
isfalse
.enabled
is toggled by a button in the top left of the demo.https://codesandbox.io/s/react-compare-slider-disable-enable-slider-qk8pb?file=/src/App.jsx:886-1035
Let me know if this does what you need.
*Edit I changed the demo so it disables …