nandorojo / moti

🐼 The React Native (+ Web) animation library, powered by Reanimated 3.
https://moti.fyi
MIT License
3.91k stars 120 forks source link

Invariant Violation: Rotate transform must be expressed in degrees (deg) or radians (rad) #217

Closed jeremy303 closed 1 year ago

jeremy303 commented 1 year ago

Is there an existing issue for this?

Current Behavior

MotiView with a rotate transform and an animation loop results in the following exception:

Invariant Violation: Rotate transform must be expressed in degrees (deg) or radians (rad): {"rotate":"undefinedNaN"}

Tested on iOS only.

Expected Behavior

No exception.

Steps To Reproduce

  1. Instantiate the following MotiView:
    <MotiView
    from={{
    opacity: 0,
    transform: [
      { rotate: '45deg' },
    ],
    }}
    animate={{
    opacity: 1,
    }}
    transition={{
    loop: true,
    type: 'timing',
    duration: 500,
    }}
    >
    <Text>
    Hello, Moti.
    </Text>
    </MotiView>

Versions

- Moti: 0.18.0
- Reanimated: 2.9.1
- React Native: 0.68.2

Screenshots

No response

Reproduction

Attempted to create an Expo example, but received an error when executing: npx create-react-native-app -t with-moti

nandorojo commented 1 year ago

hey! could you make an expo snack?

clayrisser commented 1 year ago

I'm getting a similar issue, which is causing a spinner I made to freeze.

You can see it starts out with 0deg and transitions to 360deg and then repeats, but while it repeats, the value sometimes becomes undefined.

2022-09-05-145641_screenshot

2022-09-05-145410_screenshot

Here is a link to the code.

https://gitlab.com/risserlabs/community/native-theme-ui/-/blob/main/packages/core/src/components/Spinner/index.tsx#L72-75

Here is a video showing what happens.

https://us02web.zoom.us/rec/share/qV0ys493pZfQ80q92ilNoiWeQt8e-IHfVlXafdF56t8ee2sO16lV13NPi0HL9tZS.bJqdsE67sQMBaE57

Here is a link to my story on storybook. I'm getting the same issue on Android and iOS.

https://risserlabs.gitlab.io/community/native-theme-ui/?path=/story/components-spinner--like-theme-ui

clayrisser commented 1 year ago

I also believe that the value becomes undefined right after nextAnimation.onFrame is called in the reanimated repeat logic. In other words, nextAnimation.current becomes undefined for some reason. I'm not sure if this helps.

https://github.com/software-mansion/react-native-reanimated/blob/main/src/reanimated2/animation/repeat.ts#L31

nandorojo commented 1 year ago

Any shot you guys could provide an Expo snack?

nandorojo commented 1 year ago

Closing again in favor of #227