Skip to content
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

Combining some style animations does not work with pan gestures on web #2044

Closed
1 of 3 tasks
rcoppolo opened this issue May 24, 2021 · 3 comments
Closed
1 of 3 tasks

Comments

@rcoppolo
Copy link

Description

I'm trying to animate a component's transform.translateX/Y and its height/width based off a pan gesture (I want to support resizing/moving a rectangle), and this doesn't seem to work well on web. During the pan gesture, the animation for each style seems to happen independently and sporadically flashes between them.

If I'm doing something wrong/weird here would love to hear it! I'm not running into this problem on iOS, though, so my hunch is something is off with web.

Not sure if this is a duplicate of #2019.

Expected behavior

Expect both style animations to maintain their shared values and animate smoothly over the course of the gesture.

Actual behavior & steps to reproduce

I can reproduce this behavior just by adding an additional animated width style to the DragAndSnapExample example component:

  const stylez = useAnimatedStyle(() => {
    const H = Math.round(
      interpolate(translation.x.value, [0, 300], [0, 360], Extrapolate.CLAMP)
    );
    const S = Math.round(
      interpolate(translation.y.value, [0, 500], [100, 50], Extrapolate.CLAMP)
    );
    const backgroundColor = `hsl(${H},${S}%,50%)`;
    return {
      transform: [
        {
          translateX: translation.x.value,
        },
        {
          translateY: translation.y.value,
        },
      ],
      backgroundColor,
      width: translation.y.value + 40, // new code to repro issue
    };
  });

Panning the element vertically should animate the element's width. This works OK with a translateY transform, but with a translateX transform (i.e. panning horizontally) the element flickers between the original width and the animated width.

Bug.mov

Snack or minimal code example

Snack with the above change to DragAndSnapExample: https://snack.expo.io/Pl0TTMZD-

Package versions

  • Expo: 41.0.1
  • React Native Reanimated: 2.1.0
  • React Native Gesture Handler: 1.10.2

Affected platforms

  • Android
  • iOS
  • Web
@github-actions
Copy link

Issue validator

The issue is valid!

@piaskowyk
Copy link
Member

piaskowyk commented May 24, 2021

This look like an issue related to react-native-web - necolas/react-native-web#1935

@rcoppolo
Copy link
Author

@piaskowyk Thanks, you are correct. I manually applied your (now reverted) patch and that solved this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants