Only the first one of multiple comma-separated animations is played
See original GitHub issueCurrent behavior:
I’m migrating from styled-components to emotion and a few of my animations broke: only the first one of multiple comma-separated animations is applied to the component. Specifying multiple keyframes work as expected.
To reproduce:
CodeSandbox: https://codesandbox.io/s/emotion-multiple-animations-error-srnk1?file=/src/App.tsx
Expected behavior:
All of the animations are applied to the component.
Environment information:
react
version:17.0.1
@emotion/react
version:11.4.0
@emotion/styled
version:11.3.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Play multiple CSS animations at the same time
With a comma, you can specify multiple animations each with their own properties ... First, the syntax you use only specifies one animation....
Read more >animation-iteration-count - CSS: Cascading Style Sheets | MDN
The animation-iteration-count property is specified as one or more comma-separated values. Values. infinite. The animation will repeat forever.
Read more >CSS Animation 34 - multiple animations - YouTube
Your browser can't play this video. Learn more. Switch camera.
Read more >Applying Multiple Animation Keyframes To A Loading ...
Applying Multiple Animation Keyframes To A Loading Indicator In CSS ... And then, we can use comma-delimited sets of properties to define ...
Read more >Keyframe Animation Syntax
You can comma-separate the values to declare multiple animations on a selector. .animate-this { animation: first-animation 2s infinite, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@iChenLei thank you for investigating this - the provided information was helpful to me and I could start thinking about the problem sooner thank that
The line in question has fixed some other issues that were there in the past: https://github.com/emotion-js/emotion/pull/1560 . I’m afraid that given how things are handled it’s not really possible to fix this issue here easily. I’m also not really sure if this is an issue - it might differ from what was working in Styled Components but conceptually the result of
css
has always been a class name. Class names represent valid CSS declarations and smth like this (spin 4s infinite linear
) ain’t a valid declaration (or a declaration list~).I’ve quickly hacked some helpers that could be used to pass around animation definitions like this: https://codesandbox.io/s/emotion-multiple-animations-error-forked-bl9r4?file=/src/App.tsx:1728-1763 . The code in this codesandbox could be probably vastly improved and I won’t guarantee that it works for all cases - this is just a very quick experiment.
All things considered - I don’t think it’s a bug in Emotion, the behavior is just different from Styled Components.
To make it clear - this is not technically true for
css
coming from@emotion/react
. It is true forcss
from@emotion/css
- but conceptually they represent the same thing (in case of@emotion/react
it’s just an alternative representation of a class name).If you think we could improve our docs anyhow - let us know.