The documented way to parse @keyframes does not work
Hi @wunksert there was an issue related to keyframes here which was already fixed but not yet released.
Read full answer below ↓Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Chrome v107
Describe the bug
How to reproduce the bug?
- Follow this instructions here to create your own CSS parser, and put in a @keyframes rule css string. I used the pre-built posts parser here: here
- The structure comes out of the parser and matches the documentation fine (see attached screenshot), but no animation occurs <img width="302" alt="Screen Shot 2022-12-01 at 8 59 53 PM" src="https://user-images.githubusercontent.com/12617956/205198051-0dc468a7-c0cb-4649-9429-a92c001e4117.png">
What is the expected behavior? An animation
What is the current behavior?
The element does not animate. This is the HTML structure... I may be wrong but I don't think it can parse that as an animation. The element with animation-name: spinAnimation is definitely not seeing it.
<img width="483" alt="Screen Shot 2022-12-01 at 9 07 50 PM" src="https://user-images.githubusercontent.com/12617956/205198530-5668bcea-2d17-4f8e-8774-9996e7310b3d.png">
If I use the CssComposer workaround documented here, the animation works. However this isn't a good approach because I need a unique animation name for each component I drop on the editor. For instance, I might have 5 different components that rotate at different speeds, and I'd need to manually manage all the animation names if I use the CssComposer, which I believe is a global scope.
If is necessary to execute some code in order to reproduce the bug, paste it here below: Here is my model definition:
const child = {
model: {
defaults:{
tagName: 'div',
attributes:{
class:'spin-element_child'
},
draggable:false,
removable:false,
droppable:false,
highlightable:false,
locked:true,
styles: `
@keyframes spinAnimation{
0% {
transform:rotate(0deg)
}
100% {
transform:rotate(360deg)
}
}
.spin-element_child{
display:inherit;
height:inherit;
width:inherit;
background-color:rgb(0 0 255);
animation-name: spinAnimation;
animation-duration: 1000ms;
}
`
}
}
}
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (4)
Hi @wunksert there was an issue related to keyframes here which was already fixed but not yet released.
The fix is available in the latest version https://github.com/artf/grapesjs/releases/tag/v0.20.2
@artf super! Do you know when the release will be?
Thanks for reporting this, @wunksert.
Great question about The documented way to parse @keyframes does not work. The recommended approach with StyleManager is to use the event-driven API.
Start here:
- Check the GrapesJS documentation for your specific module
- Look for the
on()event listener method - Most operations can be achieved by listening to editor and component events
Common patterns:
// Listen for changes
editor.on('change', () => console.log('something changed'));
// Component lifecycle
editor.on('component:mount', (c) => console.log('component ready', c));
editor.on('component:update', (c) => console.log('component updated', c));
If you're still stuck:
- Share a minimal CodeSandbox reproduction
- Include what you've already tried
- Mention your GrapesJS version
- The community is here to help!
Related Questions and Answers
Continue research with similar issue discussions.
Issue #6458
sector.setName doesn't work
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link https://jsfi...
Issue #4336
"Import template" don't work for removing extra styles
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Version 101.0.4951.64 Reproducible demo li...
Issue #3832
The css classes are removed and the autogenerated ids for each html tags gets changed ( Example : ivj5m-2) after each reload
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome Reproducible demo link Not there De...
Issue #5982
Component styles such as md:flex-row(tailwind) are removed
GrapesJS version[x] I confirm to use the latest version of GrapesJSWhat browser are you using? Chrome 126.0.6478.127Reproducible demo link...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
Find the Right GrapesJS Plugin in Seconds: Smarter Discovery Is Live
We're shipping a set of discovery upgrades. New label filters, a proper compatibility switch for GrapesJS vs Studio, one-click and a smarter sort bar.
Tutorial
GrapesJS vs Webflow vs Tilda: What to Choose for Your Business in 2026
Choosing the right website platform in 2026 is no longer just about building a site
Tutorial
GJS Market 2.0 - Donations, Tracking, Labels and Better Product Discovery
We’ve rolled out a new set of GrapesJS marketplace updates across GJS Market, focused on improving how creators distribute products
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.