Reputation: 1714
According to react documentation only way to animate is by usingReactCSSTransitionGroup
. Is there anyway to do animation using only Javascript?
Thanks.
Upvotes: 1
Views: 554
Reputation: 14101
Typical way to do a fadeIn animation is:
componentDidMount()
, add a setState()
method that adds the faded-in class to your componentPS: With simple javascript, you can only add animation when the component appears, or when it updates.
When your component leaves (so if you would want a fade-out animation), it is much, much harder to do that with javascript only.
Upvotes: 1
Reputation: 1714
Finally i found this npm package It has all the basic animation.
for fadeIn animation
constructor(props) {
super(props);
this.state = {
opacity: 0
}
// react state animation wrapper
this._animate = new ReactStateAnimation(this)
}
componentDidMount () {
this._fadeIn();
}
_fadeIn = () => {
this._animate.linearIn('opacity', 0.9, 300);
};
pretty simple!
Upvotes: 1