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)
You forgot changeProp: 1 on the animation trait
@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.
Issue #2337
[BUG / QUESTION] Deleting default styles does not work
Hello, i'm trying to delete some of the default styles of the blocks. I wrote everything I changed in a plugin. I used this function to upd...
Issue #3704
BUG: load blocks closed by default?
I am using the following bit of code to collapse all the block categories, unfortunately, this is not working live demo : https://jsfiddle....
Issue #3446
Cannot Store Data Unexpected token '-'
Please Help Me, I Want To Store gjs data to mysql but i cannot get any data from front end to back end here my code: const editor = grapesj...
Issue #3225
How to Update Style from checkbox Trait?
Hi @artf I am trying to update the style using the checkbox trait but it's not calling the function. Here is the code I really appreciate a...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.