framer / motion

Open source, production-ready animation and gesture library for React
https://framer.com/motion
MIT License
22.27k stars 733 forks source link

[BUG] Blinking on Enter and Exit Animations with layoutId and AnimatePresence #2616

Open ibelick opened 1 month ago

ibelick commented 1 month ago

1. Read the FAQs👇

2. Describe the bug

When using AnimatePresence with elements that have a layoutId, the components blink upon entering and exiting. The expected smooth transition is interrupted by a sudden change in opacity, making the components momentarily disappear or flash.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/p/sandbox/frosty-fast-dc5lt8?file=%2Fsrc%2FApp.tsx

4. Steps to reproduce

To observe the behavior:

Open the provided CodeSandbox link. Click on any item to select it and trigger the animation. Notice the blinking as the selected item enters or exits the view.

5. Expected behavior

The expected behavior is a smooth transition for components entering and exiting without any blinking. Elements with layoutId should animate their layout changes seamlessly under AnimatePresence.

6. Video or screenshots

https://github.com/framer/motion/assets/14288396/c9a04dd9-1554-4c04-b1eb-a713c7719b4e

7. Environment details

OS: macOS 13.0 Browser: Chrome 123.0.6312.105 Framer Motion version: 11.0.25