React-native-reanimated: Delay in TapGestureHandler?

Created on 3 Sep 2020  路  9Comments  路  Source: software-mansion/react-native-reanimated

Description

Is there an intentional delay in TapGestureHandler? I notice after about 3 secs the onGestureEvent triggers the next animation.

Code

  const initialScale = useSharedValue(1);
  const changeSize = useSharedValue(0.5);

  const gestureHandler = useAnimatedGestureHandler({
    onStart: () => {
      changeSize.value = initialScale.value === 1 ? 0.5 : 1;
    },
    onCancel: (event) => {
      console.log(event);
    },
    onEnd: () => {
      initialScale.value = withSpring(changeSize.value);
    },
  });

  //... More code

  return (
    <View style={styles.container}>
      <TapGestureHandler onGestureEvent={gestureHandler} numberOfTaps={2}>
        <Animated.View style={animatedPosition}>
          <Animated.View style={[styles.card, animatedScale]} />
        </Animated.View>
      </TapGestureHandler>
    </View>
  );

Example

mobile-ani-test

Package versions

  • React: 16.13.1
  • React Native: 0.63.1
  • React Native Reanimated: 2.0.0-alpha.5
  • React Native Gesture Handler: 1.6.1
鉂換uestion 馃彔 Reanimated2

All 9 comments

Could you please include a snack or provide a small code example showing this behavior?

@jakub-gonet I added a gif for a visual. Were you able to see it?

Not the exact moment but I _think_ I see some small delay. I asked for repro because trying to do it on our own based on your snippet is time-consuming and not really efficient (as we're trying to write the same thing that you already have written).

Try to play around with props: https://docs.swmansion.com/react-native-gesture-handler/docs/handler-tap

Also, there is a bug in the current (alpha.5) useAnimatedGestureHandler. Try to use code from master or my handler to reproduce it.

@terrysahaidak you are a saviour 鉂わ笍

Did you try the code from master?

yeah, i tried your implementation of useAnimatedGestureHandler from your master, and it works fine

Could you also try the one from this repo master? if it works, we can close this issue then.

Looks like the problem has been resolved. We will close it for now but feel free to reopen anytime.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mrousavy picture mrousavy  路  3Comments

dinhmai74 picture dinhmai74  路  3Comments

levibuzolic picture levibuzolic  路  3Comments

jwhscholten picture jwhscholten  路  4Comments

alexfov picture alexfov  路  3Comments