Skip to content

Dragging sometimes lags behind #131

Answered by dbismut
xndyz asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for pointing that out. The code in the docs doesn't reflect the actual example shown above so I understand the confusion (they're now fixed).

It's not related to react-use-gesture, but rather to react-spring that handles the animation based on the movement. Let me explain.

Let's take the direction lock example, which I'll comment line by line:

function LockDirectionExample() {
  // here we create to animated values `x` and `y` that will update with a spring.
  const [{ x, y }, set] = useSpring(() => ({ x: 0, y: 0 }))
  
const bind = useDrag(
    ({ down, movement: [mx, my] }) => {
      // `down` indicates if the pointer is pressed. The logic below sets `x` and `y`
      // to the …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dbismut
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #131 on December 09, 2020 10:39.