-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation is run at every re-render #6
Comments
Can you share your piece of code because if you are using hooks so we have to maintain some rules in hooks.. |
I faced similar situation and I found the cause of the problem. The old code cause the animation to start again every time render() {
let animate = { left: ['0px', '250px']}
return (
<Tweenful.div
className="tween-box row ml-2 mb-2 mr-2 mt-2"
duration={1500}
easing={elastic(1, 0.25)}
style={{ position: 'relative' }}
animate={animate}>
<video id="video-elem" controls width="320" height="240"></video>
</Tweenful.div>
)
} What is going on is that the One working solution is to put the constructor() {
super();
this.state = {
animate: { left: ['0px', '300px'] }
}
} And in your render function, use the <Tweenful.div
className="tween-box row ml-2 mb-2 mr-2 mt-2"
duration={1500}
easing={elastic(1, 0.25)}
style={{ position: 'relative' }}
animate={this.state.animate}>
<video id="video-elem" controls width="320" height="240"></video>
</Tweenful.div> Then it just works fine. |
Hey :). I'm using functional components and useState. Simply changing the value of a textbox (via the function provided by setState) will cause the animation to be re-run. Maybe I'm missing something :).
The text was updated successfully, but these errors were encountered: