-
Hi, I'm using compare slider inside the modal window. Every time I open modal to compare images for a new item it renders compare strip at the same position I left it before. How do I reset it or set it programmatically? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hey Alexander! The component will always respect the I'm not sure how your modal is controlled but if it's with something like a E.g. const [visible, setVisible] = useState(false);
const [position, setPosition] = useState(50);
useEffect(() => {
// Always reset position when visible is true.
if (visible) setPosition(50);
}, [visible]);
return <ReactCompareSlider position={position} /> Here's a super basic example https://codesandbox.io/s/react-compare-slider-simple-reset-example-vgkdh?file=/src/App.jsx |
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.
This has been released in v3!
See the
useReactCompareSliderRef
example for usage.