Last active
June 15, 2018 11:34
-
-
Save jeremybarbet/1e6ca2885b4f452c4a90fd8fe6f1113f to your computer and use it in GitHub Desktop.
Register animations through GsapTools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { PureComponent } from 'react'; | |
| import { TimelineLite } from 'gsap'; | |
| import { add } from 'gsap-tools'; | |
| export default class Example1 extends PureComponent { | |
| componentDidMount() { | |
| this.animate(); | |
| } | |
| animate = () => { | |
| const tl = new TimelineLite({ id: 'main' }); | |
| const t1 = new TimelineLite({ id: 'child1' }); | |
| const t2 = new TimelineLite({ id: 'child2' }); | |
| const t3 = new TimelineLite({ id: 'child3' }); | |
| const t4 = new TimelineLite({ id: 'child4' }); | |
| const t5 = new TimelineLite({ id: 'child5' }); | |
| t1.to('.blue', 1, { x: 520, rotate: '90deg' }); | |
| t2.to('.red', 0.6, { x: 200 }); | |
| t3.to('.green', 1.4, { x: 285, rotate: '-25deg' }); | |
| t4.to('.orange', 0.8, { x: 456 }); | |
| t5.to('.purple', 1.2, { x: 481, skewX: 5 }); | |
| tl | |
| .add(t1) | |
| .add(t2) | |
| .add(t3) | |
| .add(t4) | |
| .add(t5); | |
| this.disposer = add(tl); | |
| } | |
| componentWillUnmount() { | |
| this.disposer(); | |
| } | |
| render() { | |
| return ( | |
| <div> | |
| <div className="box blue" /> | |
| <div className="box red" /> | |
| <div className="box green" /> | |
| <div className="box orange" /> | |
| <div className="box purple" /> | |
| </div> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment