Closed maguskrool closed 4 years ago
Define an object calls animationParameters
, put your variables into this object, update stop-color
manually inside onChange
lifecycle, this may work.
another thing, have you tried syntax like this?
{
'stop-color': rc2,
}
add a quote will fix your syntax error.
Thank you so much @Losses, using quotes did the trick! I'll also keep in mind your first suggestion in case I come across something that's not solved by the quotes.
Hello. First of all, congratulations on your work, I've been using anime.js and it's amazing!
What I'm trying to do I'm trying to animate an SVG radial gradient, changing the color values for the 'color-stop' attribute on the
<stop>
element. I want to use anime.js, but so far no luck.What I've got so far I've had success using
<animate>
inside<stop>
, and I have a working codepen here. Here's my code:So
<rect>
is filled with the#radial-grad-01gradient
, and that gradient is animated.However, I'd really like to do the same thing using anime.js because the solution with poses some difficulties for me, like synchronising it with other anime.js animations using events like "complete".
I'm using anime.js to morph svg polygons with some randomness, and I'd like to add random hsla colors to the animation. I have a function that returns a random hsla color, but I can't get it to work with anime.js. The problem, however, lies with targeting the "stop-color" attribute for animation. Here's what I have:
Other things I tried If I use "stop-color" instead of "stopColor" on animGradient() I get an error:
Uncaught SyntaxError: Unexpected token '-'
I've also tried to replace rc1 and rc2 with hardcoded values like 'hsla(80,70%,50%,1)', so I know the error is not coming from there.
Any thoughts on this? I'm not sure if what I'm trying to do is possible with animejs, maybe 'stop-color' is not animatable, or maybe I'm just not writing the function correctly.
Thank you!