Skip to content

diffClamp on v2 #1573

Answered by neiker
neiker asked this question in Q&A
Discussion options

You must be logged in to vote

I solved this by storing the previous value of translationY:

const gestureHandler = useAnimatedGestureHandler<
    PanGestureHandlerGestureEvent,
    { prevY: number }
  >({
    onStart: (_, ctx) => {
      ctx.prevY = 0;
    },
    onActive: (event, ctx) => {
      const diff = event.translationY - ctx.prevY;

      y.value = clamp(
        y.value + diff,
        -headerHeight,
        0
      );

      ctx.prevY = event.translationY;
    },
  });

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jakub-gonet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant