-
Notifications
You must be signed in to change notification settings - Fork 498
Expand file tree
/
Copy pathGsapTimeline.jsx
More file actions
78 lines (70 loc) · 2.23 KB
/
GsapTimeline.jsx
File metadata and controls
78 lines (70 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import { useGSAP } from "@gsap/react";
import gsap from "gsap";
const GsapTimeline = () => {
// TODO: Implement the gsap timeline
const timeLine = gsap.timeline({
repeat: -1, repeatDelay: 1, yoyo: true,
});
useGSAP(() => {
timeLine.to("#yellow-box", {
x: 200,
rotation: 360,
borderRadius: "100%",
ease: 'power1.inOut',
backgroundColor: "green"
})
timeLine.to("#yellow-box", {
x: 0,
y: 100,
backgroundColor: "red",
ease: "power1.inOut"
})
timeLine.to('#yellow-box', {
x:200,
ease: "power1.inOut",
backgroundColor: "blue"
})
}, []);
return (
<main>
<h1>GsapTimeline</h1>
<p className="mt-5 text-gray-500">
The <code>gsap.timeline()</code> method is used to create a timeline
instance that can be used to manage multiple animations.
</p>
<p className="mt-5 text-gray-500">
The <code>gsap.timeline()</code> method is similar to the{" "}
<code>gsap.to()</code>, <code>gsap.from()</code>, and{" "}
<code>gsap.fromTo()</code> methods, but the difference is that the{" "}
<code>gsap.timeline()</code> method is used to create a timeline
instance that can be used to manage multiple animations, while the{" "}
<code>gsap.to()</code>, <code>gsap.from()</code>, and{" "}
<code>gsap.fromTo()</code> methods are used to animate elements from
their current state to a new state, from a new state to their current
state, and from a new state to a new state, respectively.
</p>
<p className="mt-5 text-gray-500">
Read more about the{" "}
<a
href="https://greensock.com/docs/v3/GSAP/gsap.timeline()"
target="_blank"
rel="noreferrer noopener nofollow"
>
gsap.timeline()
</a>{" "}
method.
</p>
<div className="mt-20 space-y-10">
<button onClick={() => {
if(timeLine.paused()) {
timeLine.play();
} else {
timeLine.pause();
}
}}>Play/Pause</button>
<div id="yellow-box" className="w-10 h-10 bg-yellow-500 rounded-lg" />
</div>
</main>
);
};
export default GsapTimeline;