-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onDragRelease snap to position #41
Comments
Current x/y positions are for the initial location. What you're looking for isn't currently supported. We set the draggable back to it's initial position here https://github.com/tongyy/react-native-draggable/blob/master/Draggable.js#L81 |
Darn, ok thanks! |
Actually I think it's possible. So you can specify your own There's a current bug however, where Fixing the bug:Line 78 on Draggable.tsx onRelease, Add onRelease,
onReverse, Line 118 on Draggable.tsx Change from: const reversePosition = React.useCallback(() => {
Animated.spring(pan.current, {
toValue: { x: 0, y: 0 },
useNativeDriver: false,
}).start();
}, [pan]); To const reversePosition = React.useCallback(() => {
const originalOffset = {x: 0, y: 0};
const newOffset = onReverse ? onReverse() : originalOffset;
Animated.spring(pan.current, {
toValue: newOffset,
useNativeDriver: false,
}).start();
}, [pan]); After those 2 changes you can now pass prop <Draggable onReverse={() => ({x: newX, y: newY})} /> |
how to add newY based on the last time we release the component? I want the draggable component always back to the right side of the screen but the Y position is changing according to the last time we drag it to somewhere and release it |
Hi,
I am wondering if its possible to when you release the drag for me to manually set where x access ends up. I tried using the x property but that does not seem to work. Any thoughts on how to archive this?
thanks
The text was updated successfully, but these errors were encountered: