In the process I noticed a small potential issue. I think if(this.gradientStart !== targetGradient.start) may be executed several times since the transition is not instantaneous. It doesn't seem to be noticeable to the user, but I modified this logic with an extra variable to make sure we only run the animation once per transition.
Awesome, and also nice catch. As you said, it might not be noticeable but on a larger system (or slower hardware) it could have issues.
The extra variable would be the way to go for me too.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I used your code to create a React version :)
It's a bit rough but it works.
In the process I noticed a small potential issue. I think
if(this.gradientStart !== targetGradient.start)
may be executed several times since the transition is not instantaneous. It doesn't seem to be noticeable to the user, but I modified this logic with an extra variable to make sure we only run the animation once per transition.if(this.activeGradientStart !== targetGradient.start) {
this.activeGradientStart = targetGradient.start
Awesome, and also nice catch. As you said, it might not be noticeable but on a larger system (or slower hardware) it could have issues.
The extra variable would be the way to go for me too.