Next we will add a new animation to the animator instance. You can pass any element to the add method or an array of elements. The element in the sample is a simple centered div with the class name ‘.gradient’.
The second argument of the add method is the animation duration in seconds.
const gradientElm = document.querySelector('.gradient');
let animation = animator.add(gradientElm, 2, {
backgroundImage:{
keys:{
from:'repeating-radial-gradient(closest-side at 50% 50%,rgb(140,255,54) 0%,rgb(0,0,0) 24%,rgb(255,255,255) 25%,rgb(0,0,0) 48%,rgb(140,255,54) 50%)',
to:'repeating-radial-gradient(closest-side at 50% 50%,rgb(140,255,54) 50%,rgb(0,0,0) 74%,rgb(255,255,255) 75%,rgb(0,0,0) 99%,rgb(140,255,54) 100%)'
}
}
},{
timing:'linear',
delay:'0s',
direction:'normal',
iterationCount:'infinite',
fillMode:'both',
playState:'running'
});
See the animator documentation for additional information and options.