Code sandbox: https://codesandbox.io/s/draggable-image-gallery-3-59crp
Im using react-use-gesture
to create a horizontally draggable image slider.
So far the logic I have for dragging is
set({ x: down ? mx : 0 });
where if the user presses down on the mouse, the slider will translate
to the left or right depending on the mx
movement value. Once the user lets go of the mouse, it resets back to the left side: 0
.
Relevant react-use-gesture
docs: https://use-gesture.netlify.com/docs/state
I tried multiple attempts to prevent the resetting by replacing the 0
with offset
from the API etc., but so far I haven't figured out the logic to prevent the reset.