Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Styles set using CSS rules are overridden by inline styles after transition exited #1666

Closed
233mawile opened this issue Aug 15, 2022 · 1 comment
Labels
bug Something isn't working wontfix This will not be worked on

Comments

@233mawile
Copy link

233mawile commented Aug 15, 2022

1. Read the FAQs 馃憞

2. Describe the bug

The inline styles that created by framer-motion are alaways keeped on dom even through transition exited. This will cause styles cannot be changed by css rule after transition.

3. IMPORTANT: Provide a CodeSandbox reproduction of the bug

https://codesandbox.io/s/framer-motion-inline-css-bug-su6e1p

4. Steps to reproduce

  1. hover bug button
  2. Click on disable button 猬嗭笍 button
  3. bg color of bug button is not changed

5. Expected behavior

bg color of bug button should be changed to grey

6. Video or screenshots

2022-08-15.20.56.07.mov

7. Environment details

chrome: Version 104.0.5112.79 (Official Build) (arm64)
OS: MacOS 12.4

@233mawile 233mawile added the bug Something isn't working label Aug 15, 2022
@mattgperry mattgperry added the wontfix This will not be worked on label Aug 15, 2022
@mattgperry mattgperry added wontfix This will not be worked on and removed wontfix This will not be worked on labels Aug 15, 2022
@mattgperry
Copy link
Collaborator

mattgperry commented Aug 15, 2022

Once values are handled by Framer Motion, they'll continue to take priority of CSS. Doing it any other way is impractical.

Consider this specific interaction. We can safely read the initial value out of the DOM because we haven't yet applied styles. To animate back from this whileHover style to CSS we'd need to unapply the style (a DOM write), read the computed style (DOM read) and then animate to that (a write). This is not performant, some kind of batching approach could be taken but I don't think the overhead is worth it.

An alternative would be to delete the style once the animation has finished and there's no other - this could easily result in a visual switch from the value we thought we should be animating to, to the actual latest underlying style, which is also not ideal. This latter approach is much more feasible but looking at the linked dupe with Reorder would definitely impact that example negatively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants