DEV Community

Discussion on: Making an animated slider - WotW

Collapse
 
nestedsoftware profile image
Nested Software • Edited

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

Collapse
 
ederchrono profile image
Eder Díaz

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.