Issue #3155💬 AnsweredOpened November 24, 2020by Abhisheknanda13444630 reactions

Adding Animations

快速解答by artf

You forgot changeProp: 1 on the animation trait

Read full answer below ↓

Question

hi @artf I want to include animation on all the blocks Here is some snippet of code but it's not working Could you please help me here

const def = editor.Components.getType("default");

  editor.Components.addType("default", {
     model:{
        defaults:{
           traits:[
              ...def.model.prototype.defaults.traits,
              ...[{
                     type: "select",
                     label: "Animation",
                     name: 'animation',
                     options:[
                       {value: 'bounce',name: 'Bounce'},
                       //Other animations...
                     ]
               }, {
                     changeProp: 1,
                     type: "number",
                     label: "Duration(s)",
                     name: "duration",
               }, {
                     changeProp: 1,
                     type: "number",
                     label: "Delay(s)",
                     name: "delay",
               }]
            ]
         },
         init() {
            this.on('change:animation', this.onAnimationChange);
            this.onAnimationChange();
            this.on("change:duration", this.onDurationChange);
            this.onDurationChange();
            this.on("change:delay", this.onDelayChange);
            this.onDelayChange();
         },
         onAnimationChange() {
            const animation = this.get('animation')
            this.addAttributes({ 'data-anim-type': animation   });
            // this.addClass({ animation });
         },
         onDurationChange() {
            const duration = this.get("duration");
            this.addStyle({ "animation-duration": duration });
         },
         onDelayChange() {
            const delay = this.get("delay");
            this.addStyle({ "animation-delay": delay });
         },
      }
  });

Thanks

Answers (3)

artfNovember 27, 2020

You forgot changeProp: 1 on the animation trait

Abhisheknanda1344463January 20, 2021

@artf Without giving the animation name it's not working. Should i need to add css rule for this Any suggestion.Please?

ClaudeCodeMay 17, 2026

Thanks for reporting this, @Abhisheknanda1344463.

Thanks for sharing your report about Adding Animations. To help the team investigate and prioritize this:

Please provide:

  1. A minimal reproducible example (CodeSandbox/JSFiddle)
  2. Your GrapesJS version number
  3. Browser and OS information
  4. Any error messages from the browser console
  5. Steps to reproduce the issue

What helps most:

  • Minimal code example (not your full project)
  • Screen recording or screenshot showing the issue
  • Expected vs actual behavior clearly stated
  • GrapesJS configuration you're using

With these details, the maintainers can identify and prioritize a fix much faster. The GrapesJS team is very responsive to well-documented issues.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

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.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.