question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] positionTransition animation delayed when children exit

See original GitHub issue

Describe the bug When AnimatePresence children unmount, the exit animation happens to completion before positionTransition animations take place. When new children mount, no such delay exists.

To Reproduce Steps to reproduce the behavior:

  1. Create basic example with AnimatePresence parent and <motion.*> children.
<AnimatePresence>
  <motion.div />
  <motion.div />
</AnimatePresence>
  1. Add animation props to <motion.div> children
<motion.div
  animate={{ opacity: 1 }}
  initial={{ opacity: 0 }}
  exit={{ opacity: 0 }}
  key={uniqueKey}
  positionTransition
/>
  1. Create a way to add/remove <motion.div> children.
<button onClick={handleAdd}>Add Child</button>

<AnimatePresence>
  <motion.div onClick={handleRemove} {...} />
</AnimatePresence>
  1. Observe that when adding a child, all animations (opacity and position) happen simultaneous, but when removing a child, opacity/exit transitions happen first, and then position animations.

See example: https://codesandbox.io/s/framer-motion-reorder-animation-rlojg

Expected behavior All animations happen simultaneously unless otherwise specified via delay prop, etc.

Desktop (please complete the following information):

  • OS: Mac
  • Browser: Chrome
  • Version 75.0.3770.142

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
mattgperrycommented, Apr 8, 2020

I’m gonna look into this as part of Framer Motion 2 and AnimateSharedLayout

1reaction
colepeterscommented, Jul 15, 2020

@InventingWithMonster Just following up — I’ve updated to to 2.0 and notice this staggered exit/smooth entrance issue is still around. Is it something you’re still looking into, or is it fixed and I’m just not implementing it properly?

Read more comments on GitHub >

github_iconTop Results From Across the Web

PositionedTransition class - widgets library - Dart API
Animated version of Positioned which takes a specific Animation<RelativeRect> to transition the child's position from a start position to an end position ...
Read more >
Exit Animation For Children Items Not Working In Framer Motion
Describe the bug When AnimatePresence children unmount, the exit animation happens to completion before positionTransition animations take place. import React ...
Read more >
Unity 5: How to fix delayed animator/animation issue! - YouTube
This short guide shows you how to get rid of unwanted delay when using the animator and triggers in Unity 5!
Read more >
framer-motion | Yarn - Package Manager
A simple and powerful React animation library ... [8.0.2] 2022-12-23. Fixed. Fixing defaults for hardware-accelerated animations.
Read more >
https://raw.githubusercontent.com/framer/motion/ma...
[7.5.4] 2022-10-17 ### Fixed - Fixed bug relative layout animations within ... `layout` elements to animate to their new layout as soon as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found