-
-
Notifications
You must be signed in to change notification settings - Fork 852
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 gets stuck when state changes quickly #2554
Comments
Thanks for the sandbox - are you able to set it to public so I can take a look? |
@mattgperry When you use the right arrown to navigate through the animating images, the error shows up |
@Roon311 your link is also unavailable
|
Okay now that I know why it breaks I can actually trigger the problem https://codesandbox.io/p/sandbox/modern-wood-h35hc6 Click page/back until it breaks I guess |
@notmedia It should be working now. |
Here is another reproduction. Double click the button to see it https://stackblitz.com/edit/framer-motion-animate-presence-bug?file=src%2FHoldToConfirm.tsx I can confirm that framer motion 11.0.8 works correctly with same code |
sorry about that, https://codesandbox.io/p/sandbox/serene-brattain-qwd278 is now public |
I have the same problem and still could not find the solution. It happened after version 11.0.8. Here is my example and code below.
Screen.Recording.2024-03-20.at.13.53.11.mov |
This appears to have been broken in |
Correct. Just checked! |
Same here, using |
Just linking for reference as I was linked to Issue #2023 first. We're also seeing this on |
Does anyone have a workaround for this? It breaks for us too |
Fix it to 11.0.10 |
@pklada |
|
I'd prefer not to revert if possible as we're relying on some more recent fixes. Would be nice if there was some update on this specific issue as it seems like it is affecting a number of others |
@mattgperry do you have any thoughts or should i just downgrade for now? |
I have the same issue. |
Same here. (v11.1.3) |
Good find! |
I can reproduce the bug in this codesandbox, just click quickly enough |
change the |
@luluxia Ouuups, I thought the sandbox applied the fix, sorry! 😄 |
@luluxia However, I found out the solution is not working with staggering children. :( |
Am experiencing the exact same issue, but in a different setup. There seem to be cases where exit is never called, and the potential for it not being called seems to be indeed tied to opacity. If I remove the opacity on my exit, it will always get called. Here's an example. If you slowly hover over the dots on the right, it works as expected. However, once you start going faster, it sometimes bugs and multiple divs remain visible Important part is that, if you remove |
@RareSecond |
Same Issue: I can also confirm that the suggestion above with removing the exit opacity works. |
I'm using
This is the Projects route component Projects.tsx To get the exit and entrance animations to work I have all projects rendered. For any project not selected it just returns null in the map, couldn't think of another way of doing it. EDIT: |
To follow-up, this code seemed to have to fix it sort of on the latest version. It only flickers if you return back to the same project while it's exiting to the new one. const [selectedProject, setSelectedProject] = useDebounceValue(
() => getProjectByYearAndIndex(activeYear, activeProjectIndex),
250
);
useEffect(() => {
const newProject = getProjectByYearAndIndex(
activeYear,
activeProjectIndex
);
if (selectedProject?.id !== newProject?.id) {
setSelectedProject(newProject);
}
}, [activeYear, activeProjectIndex]); |
thanks,11.0.10 works for me. Here are two links. The code is the same except for the version of framer-motion. framer-motion11.2.12.mp411.2.12 framer-motion11.0.10.mp411.0.10 works |
did the same thing, can approove that it worked 👍 |
We found out that the opacity sometimes didn't work. We relied a lot in this library and are beginning to strip down bits of it due this bug. |
@ConsoleTVs @GunnerCat |
|
This is now the most commented on and "liked" issue (even more if you count the duplicates). Would be cool to at least get a comment on if its being looked into. |
sorry for the late respond, This is my code, for some odd reason, this is the same exact code that im using the whole time, the CodeSandBox also uses 11.3.2 framer motion version, and for some UNGODLY REASON IT WORKS. so at your code, does including opacity and blur fixes the problem? |
"framer-motion": "^11.2.11",
"macOS":"14.4.1" I have same issue here, but I solve it in a silly way. add
|
Sandbox not found. |
Any updates here? I have the same problem |
I'm also using the latest version (11.3.4) but the opacity issue persists. Can you upload the example you're using? |
AnimatePresence works by detecting when Direct Child are removed from the React tree. base on framer-motion 11.3.4. Placing a motion.div as a direct child at the appropriate position can solve the problem for most cases. Below are examples using radix-accordion, radix-context-menu, and radix-tooltip. video: 11.3.4.mp4These are some methods I have tried, which have solved all the issues I encountered:
I am not sure about your use case, but if this does not help you, please create a sandbox link. |
This was very helpful, thanks! |
Edit: it made sense for the children to reanimate because I had used the same key variable and added to it (key={key + 10}) |
My suspicion given that this always(?) involves So I'm going to write a browser test that encapsulates this behaviour and then figure out a fix. |
"framer-motion": "^11.11.9"
This animation is used in a tap game. When I tap fast and a lot, game app freezes. |
My use case was Page Transitions and adding the |
2. Describe the bug
Framer Motion
v11.0.12
: When state changes very quicklyAnimatePresence
gets stuck and out of sync and no longer removes the element but instead always animates it in. Reverting to versionv10.12.2
(based of other bug report concerning a similar/same issue) does not exhibit the same problem3. IMPORTANT: Provide a CodeSandbox reproduction of the bug
https://codesandbox.io/p/sandbox/serene-brattain-qwd278
4. Steps to reproduce
5. Expected behavior
The component should not get stuck as mounted
6. Video or screenshots
If applicable, add a video or screenshots to help explain the bug.
7. Environment details
Chrome 122, Mac Sonoma
The text was updated successfully, but these errors were encountered: