Replies: 1 comment
-
useDrag(
({ offset: [x, y] }) => {
api.start({ x, y });
},
{
target: ref,
from: () => [style.x.get(), style.y.get()],
},
); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to implement some drag and drop code with long press on mobile devices. I'm not sure if this is a bug or something I'm doing wrong, but I'll try to explain as best as I can:
I'm using
@react-spring/web
version 9.7.3 and@use-gesture/react
version 10.3.1. my code should be fairly standard stuff taken straight from the examples, the only difference is a timer which startsonTouchStart
. if the user moves a certain offset before the timer ends, I callcancel()
. after calling cancel, if I move after the long press, my div "jumps" to the last offset. i.e.:cancel
ed()so basically what I see is my div jumping from [ 60, 20 ]. to [ 70, 100 ]. since I canceled that gesture, I expect to have a new gesture having offset equal to [ 60, 20 ], where my div is currently positioned.
The reason I use
offset
is because react-spring is moving the div withtransform: translate3d();
Any way to solve this?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions