juliangarnier / anime

JavaScript animation engine
https://animejs.com
MIT License
49.7k stars 3.67k forks source link

Anyway to add static value for properties css via anime function? #856

Open docodev opened 1 year ago

docodev commented 1 year ago

Hi everyone,

This library is awesome for animation. I just very excited to try it.

So today I have a problem, in my case, I just want to add static value like url for background-image or italic for text-style, because I don't want split my object properties, It's too much objects, I swear, so anyone can help me?

Thank so you much.

manake commented 1 year ago

Please post a code example.

You can set static styles in style.css:

.box {
    opacity: 0;
    background-image: url('image.jpg');
}

And in anime.js you would only animate dynamic properties, there is no need to set static properties using anime.js:

anime({
   targets: '.box',
   opacity: 1,
});
docodev commented 1 year ago

@manake Thanks for your reply, so I think currently it's only way to add normal styles to the elements with animejs, so I decide use .css() of jQuery and static Class css as your reply.