[BUG] A motion element with the layout flag with an AnimatePresence sibling does not transition smoothly
See original GitHub issue1. Read the FAQs 👇 👍
2. Describe the bug
A motion element with the layout flag with an AnimatePresence
sibling does not transition smoothly when the AnimatePresence element is removed.
It will animate nicely on enter but not exit.
I may be doing something wrong here, but I would expect this to work.
If I move the layout div inside the AnimatePresence then it does work as expected, but this is not always possible.
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
https://codesandbox.io/s/framer-motion-simple-animation-forked-6m9ej?file=/src/index.tsx
4. Steps to reproduce
Steps to reproduce the behavior:
<div className="container">
<Refresh onClick={toggle} />
<AnimatePresence>
{show && (
<motion.div
key="1"
className="example-container"
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={toggle}
></motion.div>
)}
</AnimatePresence>
<motion.div
onClick={toggle}
key="2"
className="example-container"
layout
></motion.div>
</div>
5. Expected behavior
The bottom motion div should animate smoothly when the top one is removed from the dom.
6. Video or screenshots
I think the codesandbox is easy enough to understand
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
You can fix this by wrapping everything in a
<LayoutGroup>
example
Ah yeah I see, thanks for clarifying
On Fri, 19 Nov 2021 at 19:28, rickyhopkins @.***> wrote: