nandorojo / moti

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

Experiencing flashing when animating to any color from `transparent` #330

Closed agrawal-rohit closed 6 months ago

agrawal-rohit commented 6 months ago

Is there an existing issue for this?

Do you want this issue prioritized?

Current Behavior

Animating the backgroundColor property from transparent to another color can result in a brief flash of black before the animation completes. This flash does not occur if the starting color is anything other than transparent.

Expected Behavior

The color animation should be a smooth transition without the flash of black.

Steps To Reproduce

No response

Versions

- Moti: 0.27.0
- Reanimated: ~3.3.0
- Expo: 49.0.0

Screenshots

2023-12-20 13 57 08

Reproduction

Expo Snack: https://snack.expo.dev/@agrawal-rohit/moti-color-flashing-issue

nandorojo commented 6 months ago
  1. Be sure to use a timing transition
  2. This is likely a reanimated issue not Moti
  3. Maybe you can try a HEX with 0 opacity by appending 00 to your color and see what it happens there.
  4. Consider absolute positioning a background and then using opacity instead
agrawal-rohit commented 6 months ago

The HEX with opacity 0 hack worked great, thanks! Not sure what the underlying issue with Reanimated is, but the current solution should do the job for now.

PS -

  1. The black flashing still occurred with a timing transition.
  2. The reason I raised the issue here is that I am using Moti as a wrapper for Reanimated. I'm not sure if the resolution might require handling this case differently in Moti itself.