Closed zimond closed 8 years ago
Yes, when you update the static value (out of the animation), react-smooth will not update the animation state immediately but in a setTimeout callback. I have fixed this now but I wonder why this is not desirable.
btw, the animationManager pattern is too complicated so I will refactor it soon using a simpler pattern.
Thank you very much!
Also may I ask why this module uses setTimeout instead of requestAnimationFrame
?
react-smooth use setTimeout to complete css animation and use requestAnimationFrame to complete js animation.
Thanks very much!
Thanks for the quick reply
Currently
<Animate/>
'scomponentWillReceiveProps
will start the manager to load the animation. In which asetTimeout
is added to change styles.A common situation could be:
set
<Animate>
'sto
->state1
, some static (out of the animation) value to ->value1
<Animate>
'sfrom
->state2
,to
->state3
, the static value ->value2
Now
Animate.state.style
isstate1
. Because the.state.style
update is triggered in the animationManager in asetTimeout
, so it will be updated after current react update loop.So in this loop, the children state will be
(value2, state1)
, which is not desirable( should be(value2, state2)
).I think it's better to trigger a state update in
Animate.componentWillReceiveProps
to set current state toprops.from
, or maybe I've missed something?