Issue #3155Opened November 24, 2020by Abhisheknanda13444630 reactions

Adding Animations

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 (2)

artfNovember 27, 20200 reactions

You forgot changeProp: 1 on the animation trait

Abhisheknanda1344463January 20, 20210 reactions

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

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.