GSAP Flashcards

1
Q

What are the three primary methods of the GSAP object for creating tweens?

A

gsap.to(), gsap.from(), and gsap.fromTo(). These methods animate properties over time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a tween do in GSAP?

A

A tween animates a property of an object over time, specifying targets, properties, and optional special properties like duration.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How is the x or y property used in GSAP animations?

A

It is a shorthand for the CSS translateX or translateY property, used to move elements along the horizontal axis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are staggered animations in GSAP?

A

They animate multiple objects with delayed start times using the stagger property.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a GSAP timeline?

A

A container for multiple tweens, enabling sequencing, overlap, nested timelines, and repeat delays.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the basic syntax for a gsap.to() tween?

A
gsap.to(".fred", { x: 400 });

This animates the element with the class “fred” to an x position of 400.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

For best performance, which CSS properties should you animate with GSAP?

A
  1. x
  2. y
  3. rotation
  4. rotationX
  5. rotationY
  6. skewX and skewY
  7. scaleX, scaleY, or scale
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the delay property do in GSAP?

A

The delay property specifies how much time should transpire before the animation begins.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the repeat property do in GSAP?

A

The repeat property defines how many times the animation should repeat.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens if you set repeat: -1 in GSAP?

A

The animation will repeat indefinitely.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you play an animation back and forth in GSAP?

A

With yoyo set to true:

yoyo: true,

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you delay, when an animation repeats in GSAP?

A

The repeatDelay property specifies how much time should transpire between each repeat of the animation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the start property in ScrollTrigger define? (GSAP)

A

The start property defines when the animation begins relative to the scroll position. Example: “start”: “top 75%”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does “start”: “top top” mean in ScrollTrigger? (GSAP)

A

It means the top of the trigger element matches the top of the viewport (default behavior).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the end property in ScrollTrigger do? (GSAP)

A

The end property defines when the animation ends relative to the scroll position.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you set an absolute end value in ScrollTrigger? in GSAP

A

By using a relative value like “end”: “+=500”, which ends 500px after start.

17
Q

What does toggleActions control in ScrollTrigger? in GSAP

A

It controls the behavior when the trigger point is crossed - “onEnter, onLeave, onEnterBack, onLeaveBack”.

18
Q

Which 8 toggleActions can be used for the scrollTrigger in GSAP?

A

play, pause, resume, reverse, complete, restart, reset, none

19
Q

What does scrub do in GSAP?

A

scrub:true or scrub:1 (eased for mouse scrolling) scroll the element according to the scrolling.

A higher value adds delay to the scrolling.

20
Q

How can you fix an animated element in gsap while using scrollTrigger, so it does not scroll with the page?

A

With:

pin:true,
21
Q

What does pinSpacing do in GSAP’s ScrollTrigger?

A

pinSpacing controls whether space is added to push content down when an element is pinned.

pinSpacing: true (default)

adds padding/margin to keep the layout intact.

pinSpacing: false

removes this spacing, causing content to overlap the pinned element.

22
Q

What does the pin property do in GSAP ScrollTrigger?

A

When pin: true is set, ScrollTrigger wraps the target element in a pin-spacer div to preserve its layout in the document flow while making it fixed. This allows the element to appear stationary while other content scrolls.

23
Q

What is the purpose of the pin-spacer element in ScrollTrigger?

A

The pin-spacer is an automatically added wrapper element that maintains the original space occupied by the pinned element. This prevents layout shifts and keeps surrounding content in place while the element is pinned.

24
Q

What padding adjustments does pin add by default?

A

By default, the pin-spacer wrapper includes padding to prevent visual layout changes. This padding matches the pinned element’s dimensions and offsets to simulate its original position.

25
Q
A
26
Q

What can you use to simulate vh or % for responsiveness in GSAP?

A

Use:

height: () => window.innerHeight * 0.7

This equals height: 70% or height: 70vh

27
Q

What does the stagger property do in GSAP animations?

A

The stagger property allows you to animate multiple elements in sequence with a delay between each animation, creating a staggered effect.

28
Q

How do you use stagger to apply a delay between each element?

A
gsap.to(".box", {
  x: 100,
  stagger: 0.2, // Delay of 0.2 seconds between each animation
});
29
Q

What does stagger: { each: 0.1 } do in a GSAP animation?

A

The each property specifies the amount of delay per element, ensuring a consistent delay between each animation.

gsap.to(".box", {
  x: 100,
  stagger: { each: 0.1 },
});
30
Q

What is stagger: { amount: 2 } in GSAP, and how does it work?

A

amount defines the total duration for all the staggered animations combined. GSAP automatically divides the duration among the elements.

gsap.to(".box", {
  y: 100,
  stagger: { amount: 2 },
});

This animates all elements with a total stagger duration of 2 seconds.

31
Q

How can you control the direction of staggered animations in GSAP?

A

Use the from property:

  • “start” animates from the first to the last element.
  • “center” animates from the middle to the edges.
  • “edge” animates from the edges to the middle.
  • “end” animates from the last to the first.Example:
gsap.to(".box", {
  opacity: 1,
  stagger: { each: 0.2, from: "end" },
});
32
Q

How can you customize the point, where a transformation will happen in GSAP?

A

With transformOrigin

gsap.to(".truck", {
  transformOrigin:"65px 160px",
rotation:-40,
repeat:1,
yoyo:true})
33
Q

How can you use % values in GSAP?

A

With xPercent or yPercent**

e.g.

gsap.timeline()
         .from("#demo", {xPercent:100})
         .from("#demo", {yPercent:-100})
34
Q

What are the 5 ways to offset the start time of tweens in a GSAP timeline?

A
var tl = gsap.timeline();
  tl.to(object, {y:300}, "+=1")  // start 1 second after previous tween ends
  tl.to(object, {x:300}, "-=1")  // start 1 second before previous tween ends
  tl.to(object, {rotation:90}, "<")  // start when previous tween begins
  tl.to(object, {opacity:0.5}, "<1") // start 1 second after previous tween begins
  tl.to(object2, {x:200}, 1) // start exactly at a time of 1
35
Q

How do you create and control a timeline in GSAP?

A

Create a timeline reference with gsap.timeline(). You can control it using:

  • play() – Start or resume the timeline.
  • pause() – Pause the timeline.
  • restart() – Restart the timeline from the beginning.
  • reverse() – Reverse the timeline direction.
var animation = gsap.timeline();  
animation.play();  
animation.pause();
36
Q

How do you add a label to a timeline in GSAP?

A

Use the add() method to add a label.

animation.add("test");

Labels mark specific points in the timeline for precise control.

37
Q

How do you play a GSAP timeline from a specific label?

A

Use the play() method with the label name:

animation.play("test");

This starts the timeline from the “test” label.

38
Q

What is the purpose of using labels in a GSAP timeline?

A

Labels mark specific points in time within a timeline, making it easier to control or navigate to those points.