-
-
Notifications
You must be signed in to change notification settings - Fork 869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] AnimatePresence - enter and exit animations are mixed when they alternate rapidly #2618
Comments
PS: This is possibly a duplicate of bug #2554 , but the work-around proposed in this bug (use framer-motion@11.0.10) does not solve the problem in my repro repository. |
After analysis, it would appear that you end up with both elements systematically in the DOM when you quickly do the "Next" / "Previous", which corresponds to the situation in the other bug mentioned. |
I have also been battling with this issue for awhile, and have not found a fix. While I am unable to reproduce the issue in the Here is a video of a hereisme.movThe code for this would look something like: const characterCountMarkup = !validateUsernameLength(value) ? (
<CharacterCount key={`UserName-CharacterCount-${value.length}`} count={value.length} />
) : null;
<AnimatePresence>{characterCountMarkup}</AnimatePresence> I am currently on version As indicated by OP, there appear to be several issues raising this same concern: #2554 and #2462 |
I've created another minimal reproduction in case it is helpful: bug.movAs discovered in the other threads... However... for my specific needs, I do in fact need an |
@beefchimi |
There are a number of bugs with `framer-motion` that can result in sync issues with AnimatePresence and the conditionally rendered component. You can see this if you rapidly click an accordion, occasionally it gets out of sync and is closed when it should be open. This is a bigger problem with the viewer where the user may hold down the `z` key. It's trivial to get it to lock up. For now, just remove the animation entirely. Upstream issues for reference: motiondivision/motion#2023 motiondivision/motion#2618 motiondivision/motion#2554
There are a number of bugs with `framer-motion` that can result in sync issues with AnimatePresence and the conditionally rendered component. You can see this if you rapidly click an accordion, occasionally it gets out of sync and is closed when it should be open. This is a bigger problem with the viewer where the user may hold down the `z` key. It's trivial to get it to lock up. For now, just remove the animation entirely. Upstream issues for reference: motiondivision/motion#2023 motiondivision/motion#2618 motiondivision/motion#2554
I also faced that problem, I had to prevent the user from changing the state rapidly by disabling the buttons while the animation is running here's what I created if any1 is interested: |
I ran into the same problem. And it's not only about opacity, just using x, the same problem occurs. Someone mentioned in another issue that using different keys could help. I tried that and didn't work for me. In the DOM tree, there are many elements with different keys that should disappear due to conditional rendering, but none of them did. |
1. Read the FAQs π
Done β
2. Describe the bug
Enter and exit animations are mixed when they alternate rapidly.
3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
https://stackblitz.com/edit/vitejs-vite-5ocwzr?file=src%2FApp.tsx
4. Steps to reproduce
5. Expected behavior
The animation that works when slowly clicking on "Next" and "Previous" should also work when quickly clicking on "Next" and "Previous"
6. Video or screenshots
If applicable, add a video or screenshots to help explain the bug.
7. Environment details
Tested on:
Tested on both
framer-motion@^10
(currently10.18.0
) &framer-motion@^11
(currently11.0.28
)UPDATE:
The problem doesn't actually exist on 10.18.0, even though this version has a small glitch visual (it blinks) when you make a quick change.
The text was updated successfully, but these errors were encountered: