Animate React component on disconnect / exit
I want to use Velocity to fade out the component when the component exits. I am calling the callback but there is no animation. What's wrong with the code below?
export class Foo extends Component { componentWillEnter (cb) { cb (); } componentWillLeave (cb) { const node = findDOMNode (el); Velocity (node, {opacity: 0}, {duration: 200}); cb (); } }
+1
source to share
1 answer
Found it on GSAP message . The callback must be passed to Velocity as a complete function.
export class Foo extends Component {
componentWillEnter(cb) {
cb();
}
componentWillLeave(cb) {
const node = findDOMNode(el);
Velocity(node, { opacity: 0 }, { duration:200, complete: cb });
}
...
}
+1
source to share