### Animation with Timeline Start Reference
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/to().md
This example uses the "timelineStart" reference point to position an animation at the beginning of the timeline with the to() method. Useful for animations that should always start first.
```javascript
tl.to(".green-box", { x: 100, duration: 1, position: "timelineStart" });
```
--------------------------------
### Basic Timeline Setup with from()
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/from().md
This snippet demonstrates the fundamental usage of GSAP's TimelineLite/Max with the from() method to animate elements from a specific starting point. It requires GSAP to be included in the project.
```javascript
console.clear();
gsap.registerPlugin(Draggable, CustomEase, CustomWiggle);
CustomWiggle.create("wiggle", {wiggles:5, type:"easeInOut"});
new Vue({
el: "#app",
data() {
return {
labelPosition: 1,
paused: false,
roundedMilliseconds: 0,
percentRange: 200,
secondsRange: 5,
useRecent: false,
referencePoint: "timelineStart",
offsetType: "seconds",
offsetNumber: 1,
position: 0,
hidePosition: false,
lastSecond: 1,
lastPercent: 50,
endX: 500,
timelineItems: [],
timelineData: [
{ class: "purple gradient-purple" },
{ class: "green gradient-green" }
]
}
},
mounted() {
this.setScrubber = gsap.quickSetter(this.$refs.scrubber, "x", "px");
this.clampSeconds = gsap.utils.clamp(-this.secondsRange, this.secondsRange);
this.clampPercent = gsap.utils.clamp(-this.percentRange, this.percentRange);
this.mapSize = gsap.utils.mapRange(30, 90, 1.1, 0.65);
this.timeline = gsap.timeline();
this.createScrubber();
this.renderTimeline();
window.addEventListener("resize", this.onResize);
this.$nextTick(() => {
this.onResize();
this.timeline.eventCallback("onUpdate", this.updateScrubber);
gsap.to("#app", { opacity: 1 });
});
},
computed: {
formattedPosition() {
if (this.hidePosition) {
return "";
}
if (this.referencePoint !== "timelineStart") {
return `"${this.position}"`;
}
return this.position;
},
range() {
return this.offsetType === "percent" ? this.percentRange : this.secondsRange;
},
usePrevious() {
return this.referencePoint.includes("previous") && this.offsetType === "percent";
}
},
watch: {
formattedPosition: "animatePosition",
useRecent: "renderTimeline",
referencePoint(value) {
if (value === "timelineStart") {
this.offsetType = "seconds";
}
this.renderTimeline();
},
offsetNumber(value) {
value = parseFloat(value);
if (isNaN(value)) return;
if (this.offsetType === "percent") {
this.offsetNumber = this.clampPercent(value);
} else {
this.offsetNumber = this.clampSeconds(value);
}
this.renderTimeline();
},
offsetType(value) {
if (value === "percent") {
this.lastSecond = this.offsetNumber;
this.offsetNumber = this.lastPercent;
} else {
this.lastPercent = this.offsetNumber;
this.offsetNumber = this.lastSecond;
}
this.renderTimeline();
}
},
methods: {
renderTimeline() {
this.position = this.getPosition();
this.endX = this.scrubber.maxX - 56;
let tl = this.timeline;
tl.progress(0)
.clear(true)
.addLabel("myLabel", this.labelPosition)
.to(this.$refs.purple, {
ease: "none",
duration: 2,
x: this.endX,
data: this.timelineData[0]
}, 0)
.to(this.$refs.green, {
ease: "none",
duration: 1,
x: this.endX,
data: this.timelineData[1]
}, this.position);
let timelineItems = [];
let time = tl.duration();
let children = tl.getChildren();
let milliseconds = time * 10;
this.roundedMilliseconds = Math.floor(milliseconds) + 1;
let fontSize = this.mapSize(this.roundedMilliseconds);
document.documentElement.style.setProperty('--number-size', fontSize + "rem");
children.forEach((child, index) => {
let duration = child.totalDuration();
let startTime = child.startTime();
let width = (duration / time) * 100;
let startPosition = (startTime / time) * 100;
timelineItems[index] = {
...child.data,
style: {
width: `${width}%`,
marginLeft: `${startPosition}%`
}
};
});
this.timelineItems = timelineItems;
},
getPosition() {
this.hidePosition = false;
let value = parseFloat(this.offsetNumber);
let isNegative = value < 0;
let isPercent = this.offsetType === "percent";
if (this.referencePoint !== "timelineStart") {
value = Math.abs(value);
}
```
--------------------------------
### Timeline `from()` Method Example
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/from().md
Demonstrates the basic usage of the `from()` method to animate elements from a specified starting state. This is useful for creating entry animations.
```javascript
let tl = gsap.timeline();
tl.from(".box", { x: 100, opacity: 0, duration: 1 });
```
--------------------------------
### ScrambleTextPlugin Usage Examples
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/Plugins/ScrambleTextPlugin.html
Examples demonstrating how to use the ScrambleTextPlugin with default and customized settings.
```javascript
// Use the defaults
gsap.to(element, {duration: 1, scrambleText: "THIS IS NEW TEXT"});
// Customize things:
gsap.to(element, {
duration: 1,
scrambleText: {
text: "THIS IS NEW TEXT",
chars: "XO",
revealDelay: 0.5,
speed: 0.3,
newClass: "myClass"
}
});
```
--------------------------------
### quickTo() with Optional Numeric Start Value
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.quickTo().html
Demonstrates overriding the default starting value for a quickTo() animation. The first parameter is the target value, and the second is the explicit starting value.
```javascript
let xTo = gsap.quickTo("#id", "x", { duration: 0.8 });
xTo(100); // animates to 100 from current value inside the tween at its current progress
xTo(100, 500); // animates to 100 from 500
```
--------------------------------
### CSS for matchMedia Responsive Example
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.matchMedia().md
This CSS styles the elements for the matchMedia() example, including responsive adjustments for smaller screens.
```css
/* external styles https://codepen.io/GreenSock/pen/xxmzBrw/fcaef74061bb7a76e5263dfc076c363e.css */
body {
text-align: center;
font-weight: 300;
}
header {
padding: 0 1rem;
margin: 0 auto;
}
h1 {
margin: 0;
padding: 35px 10px;
font-weight: 400;
}
.gray {
position: relative;
width: 100%;
height: 100vh;
}
.mobile, .desktop {
width: 200px;
height: 100px;
border-radius: 5px;
background: var(--purple);
position: absolute;
z-index: 0;
left: 30%;
top: 50%;
transform: translate3d(-50%, -50%, 0);
text-align: center;
font-size: 1.5em;
font-weight: 400;
line-height: 100px;
color: white;
}
.desktop {
left: 70%;
background: var(--green);
}
.gray p {
margin: 0;
padding: 30px;
}
.bottom {
width: 100%;
text-align: center;
padding: 150px 30px;
font-size: 1.5em;
box-sizing: border-box;
}
a {
text-decoration: none;
font-weight: 400;
}
a:hover {
text-decoration: underline;
}
@media (max-width: 799px) {
.mobile, .desktop {
width: 100px;
}
}
```
--------------------------------
### Get and Set Timeline startTime
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/startTime().html
Use startTime() without parameters to get the current start time of an animation on its parent timeline. Provide a numeric value to set a new start time, enabling easier chaining.
```javascript
var start = tl.startTime();
tl.startTime(2);
```
--------------------------------
### Basic Desktop/Mobile Setup with MatchMedia
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.matchMedia().html
Use matchMedia to add different animation setups for desktop and mobile breakpoints. The function passed to add() will execute when the specified media query matches.
```javascript
let mm = gsap.matchMedia();
mm.add("(min-width: 800px)", () => {
// desktop setup code here...
});
mm.add("(max-width: 799px)", () => {
// mobile setup code here...
});
```
--------------------------------
### gsap.quickSetter() Usage
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.quickSetter().md
This example demonstrates how to use gsap.quickSetter() to create efficient setters for element properties. It sets initial properties and then uses the created setters to update the 'x' and 'y' properties of a '.flair' element based on mouse movement.
```APIDOC
## gsap.quickSetter()
### Description
Creates a highly optimized function that instantly sets a specific property on a target element. This is useful for performance-critical scenarios where immediate updates are needed, such as following the mouse cursor.
### Method
`gsap.quickSetter(target, property, unit)`
### Parameters
- **target** (string | object | array): The element(s) to target. Can be a CSS selector, a DOM element, or an array of elements.
- **property** (string): The CSS property to set (e.g., "x", "y", "opacity").
- **unit** (string, optional): The unit to append to the value (e.g., "px", "%"). Defaults to "".
### Returns
A function that accepts a value and applies it to the specified property of the target element(s).
### Example
```javascript
// Set initial properties for elements with the class 'flair'
gsap.set(".flair", {xPercent: -50, yPercent: -50});
// Create a quick setter for the 'x' property with 'px' units
let xSetter = gsap.quickSetter(".flair", "x", "px");
// Create a quick setter for the 'y' property with 'px' units
let ySetter = gsap.quickSetter(".flair", "y", "px");
// Add an event listener to update the element's position on mouse move
window.addEventListener("mousemove", e => {
xSetter(e.x); // Update x position
ySetter(e.y); // Update y position
});
```
### Note
If you need to animate to new values instead of instantly setting them, consider using `gsap.quickTo()`.
```
--------------------------------
### Basic Usage and Defining Start Value with quickTo()
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.quickTo().md
Demonstrates how to use gsap.quickTo() to create an animation function for the 'x' property. The first call animates from the current value, while the second call specifies both the target value (100) and a starting value (500).
```javascript
let xTo = gsap.quickTo("#id", "x", { duration: 0.8 });
xTo(100); // animates to 100 from current value inside the tween at its current progress
xTo(100, 500); // animates to 100 from 500
```
--------------------------------
### Get Scroll Position for Animation
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/HelperFunctions/helpers/getScrollPosition.html
Use this function to get the scroll position for a GSAP animation with a ScrollTrigger. It accepts the animation object and an optional progress value (0 for start, 1 for end).
```javascript
function getScrollPosition(animation, progress) {
let p = gsap.utils.clamp(0, 1, progress || 0),
st = animation.scrollTrigger,
containerAnimation = st.vars.containerAnimation;
if (containerAnimation) {
let time = st.start + (st.end - st.start) * p;
st = containerAnimation.scrollTrigger;
return (
st.start + (st.end - st.start) * (time / containerAnimation.duration())
);
}
return st.start + (st.end - st.start) * p;
}
```
--------------------------------
### Get Tweens of Multiple Objects
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.getTweensOf().html
This example shows how to get all active tweens for an array of targets, including obj1 and obj2. This is helpful when you need to manage animations across multiple elements simultaneously.
```javascript
gsap.to(obj1, { x: 100 });
gsap.to(obj2, { x: 100 });
gsap.to([obj1, obj2], { opacity: 0 });
var a2 = gsap.getTweensOf([obj1, obj2]); //finds 3 tweens
```
--------------------------------
### GSAP Timeline Setup and Basic Animation
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/fromTo().md
This snippet demonstrates the basic setup of a GSAP timeline, including registering plugins, creating custom eases, and rendering animations. It shows how to use `gsap.timeline()` and add tweens with specific durations and positions.
```javascript
console.clear();
// "<25%" (use recent), "<+=25%" (use inserting)
gsap.registerPlugin(Draggable, CustomEase, CustomWiggle);
CustomWiggle.create("wiggle", {wiggles:5, type:"easeInOut"});
new Vue({
el: "#app",
data() {
return {
labelPosition: 1,
paused: false,
roundedMilliseconds: 0,
percentRange: 200,
secondsRange: 5,
useRecent: false,
referencePoint: "timelineStart",
offsetType: "seconds",
offsetNumber: 1,
position: 0,
hidePosition: false,
lastSecond: 1,
lastPercent: 50,
endX: 500,
timelineItems: [],
timelineData: [
{ class: "purple gradient-purple" },
{ class: "green gradient-green" }
]
}
},
mounted() {
this.setScrubber = gsap.quickSetter(this.$refs.scrubber, "x", "px");
this.clampSeconds = gsap.utils.clamp(-this.secondsRange, this.secondsRange);
this.clampPercent = gsap.utils.clamp(-this.percentRange, this.percentRange);
this.mapSize = gsap.utils.mapRange(30, 90, 1.1, 0.65);
this.timeline = gsap.timeline();
this.createScrubber();
this.renderTimeline();
window.addEventListener("resize", this.onResize);
this.$nextTick(() => {
this.onResize();
this.timeline.eventCallback("onUpdate", this.updateScrubber);
gsap.to("#app", { opacity: 1 });
});
},
computed: {
formattedPosition() {
if (this.hidePosition) {
return "";
}
if (this.referencePoint !== "timelineStart") {
return `"${this.position}"`;
}
return this.position;
},
range() {
return this.offsetType === "percent" ? this.percentRange : this.secondsRange;
},
usePrevious() {
return this.referencePoint.includes("previous") && this.offsetType === "percent";
}
},
watch: {
formattedPosition: "animatePosition",
useRecent: "renderTimeline",
referencePoint(value) {
if (value === "timelineStart") {
this.offsetType = "seconds";
}
this.renderTimeline();
},
offsetNumber(value) {
value = parseFloat(value);
if (isNaN(value)) return;
if (this.offsetType === "percent") {
this.offsetNumber = this.clampPercent(value);
} else {
this.offsetNumber = this.clampSeconds(value);
}
this.renderTimeline();
},
offsetType(value) {
if (value === "percent") {
this.lastSecond = this.offsetNumber;
this.offsetNumber = this.lastPercent;
} else {
this.lastPercent = this.offsetNumber;
this.offsetNumber = this.lastSecond;
}
this.renderTimeline();
}
},
methods: {
renderTimeline() {
this.position = this.getPosition();
this.endX = this.scrubber.maxX - 56;
let tl = this.timeline;
tl.progress(0)
.clear(true)
.addLabel("myLabel", this.labelPosition)
.to(this.$refs.purple, {
ease: "none",
duration: 2,
x: this.endX,
data: this.timelineData[0]
}, 0)
.to(this.$refs.green, {
ease: "none",
duration: 1,
x: this.endX,
data: this.timelineData[1]
}, this.position);
let timelineItems = [];
let time = tl.duration();
let children = tl.getChildren();
let milliseconds = time * 10;
this.roundedMilliseconds = Math.floor(milliseconds) + 1;
let fontSize = this.mapSize(this.roundedMilliseconds);
document.documentElement.style.setProperty('--number-size', fontSize + "rem");
children.forEach((child, index) => {
let duration = child.totalDuration();
let startTime = child.startTime();
let width = (duration / time) * 100;
let startPosition = (startTime / time) * 100;
timelineItems[index] = {
...child.data,
style: {
width: `${width}%`,
marginLeft: `${startPosition}%`
}
};
});
this.timelineItems = timelineItems;
},
getPosition() {
this.hidePosition = false;
let value = parseFloat(this.offsetNumber);
let isNegative = value < 0;
let isPercent = this.offsetType === "percent";
if (this.referencePoint !== "timelineStart") {
value = Math.abs(value);
}
```
--------------------------------
### Timeline with onStart and Parameters
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/vars.md
Shows how to define an onStart callback function and its parameters for a GSAP Timeline.
```javascript
gsap.timeline({onStart: myFunction, onStartParams: ["param1", "param2"]});
```
--------------------------------
### ScrollTrigger.start
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/Plugins/ScrollTrigger/start.md
The read-only 'start' property of a ScrollTrigger instance returns its calculated starting scroll position in pixels. This value is dynamic and gets recalculated whenever the ScrollTrigger is refreshed, such as during window or scroller resizing.
```APIDOC
## ScrollTrigger.start
### Description
The read-only `start` property of a ScrollTrigger instance returns its calculated starting scroll position in pixels. This value is dynamic and gets recalculated whenever the ScrollTrigger is refreshed, such as during window or scroller resizing.
### Property
- **start** (Number) - Read-only. The scroll position in pixels where the ScrollTrigger becomes active.
### Details
This value is automatically calculated when the ScrollTrigger is refreshed. For instance, if a trigger element is positioned 100px below the viewport and the ScrollTrigger's `start` variable was set to "top bottom", the calculated `start` property would be 100 pixels. Both `start` and `end` properties are always numeric and represent scroll positions in pixels.
```
--------------------------------
### Basic Timeline Setup with to()
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/to().md
Demonstrates the fundamental setup of a GSAP timeline and adding animations using the to() method. This is useful for sequencing multiple animations.
```javascript
console.clear();
gsap.registerPlugin(Draggable, CustomEase, CustomWiggle);
CustomWiggle.create("wiggle", {wiggles:5, type:"easeInOut"});
new Vue({
el: "#app",
data() {
return {
labelPosition: 1,
paused: false,
roundedMilliseconds: 0,
percentRange: 200,
secondsRange: 5,
useRecent: false,
referencePoint: "timelineStart",
offsetType: "seconds",
offsetNumber: 1,
position: 0,
hidePosition: false,
lastSecond: 1,
lastPercent: 50,
endX: 500,
timelineItems: [],
timelineData: [
{ class: "purple gradient-purple" },
{ class: "green gradient-green" }
]
}
},
mounted() {
this.setScrubber = gsap.quickSetter(this.$refs.scrubber, "x", "px");
this.clampSeconds = gsap.utils.clamp(-this.secondsRange, this.secondsRange);
this.clampPercent = gsap.utils.clamp(-this.percentRange, this.percentRange);
this.mapSize = gsap.utils.mapRange(30, 90, 1.1, 0.65);
this.timeline = gsap.timeline();
this.createScrubber();
this.renderTimeline();
window.addEventListener("resize", this.onResize);
this.$nextTick(() => {
this.onResize();
this.timeline.eventCallback("onUpdate", this.updateScrubber);
gsap.to("#app", { opacity: 1 });
});
},
computed: {
formattedPosition() {
if (this.hidePosition) {
return "";
}
if (this.referencePoint !== "timelineStart") {
return `"${this.position}"`;
}
return this.position;
},
range() {
return this.offsetType === "percent" ? this.percentRange : this.secondsRange;
},
usePrevious() {
return this.referencePoint.includes("previous") && this.offsetType === "percent";
}
},
watch: {
formattedPosition: "animatePosition",
useRecent: "renderTimeline",
referencePoint(value) {
if (value === "timelineStart") {
this.offsetType = "seconds";
}
this.renderTimeline();
},
offsetNumber(value) {
value = parseFloat(value);
if (isNaN(value)) return;
if (this.offsetType === "percent") {
this.offsetNumber = this.clampPercent(value);
} else {
this.offsetNumber = this.clampSeconds(value);
}
this.renderTimeline();
},
offsetType(value) {
if (value === "percent") {
this.lastSecond = this.offsetNumber;
this.offsetNumber = this.lastPercent;
} else {
this.lastPercent = this.offsetNumber;
this.offsetNumber = this.lastSecond;
}
this.renderTimeline();
}
},
methods: {
renderTimeline() {
this.position = this.getPosition();
this.endX = this.scrubber.maxX - 56;
let tl = this.timeline;
tl.progress(0)
.clear(true)
.addLabel("myLabel", this.labelPosition)
.to(this.$refs.purple, {
ease: "none",
duration: 2,
x: this.endX,
data: this.timelineData[0]
}, 0)
.to(this.$refs.green, {
ease: "none",
duration: 1,
x: this.endX,
data: this.timelineData[1]
}, this.position);
let timelineItems = [];
let time = tl.duration();
let children = tl.getChildren();
let milliseconds = time * 10;
this.roundedMilliseconds = Math.floor(milliseconds) + 1;
let fontSize = this.mapSize(this.roundedMilliseconds);
document.documentElement.style.setProperty('--number-size', fontSize + "rem");
children.forEach((child, index) => {
let duration = child.totalDuration();
let startTime = child.startTime();
let width = (duration / time) * 100;
let startPosition = (startTime / time) * 100;
timelineItems[index] = {
...child.data,
style: {
width: `${width}%`,
marginLeft: `${startPosition}%`
}
};
});
this.timelineItems = timelineItems;
},
getPosition() {
this.hidePosition = false;
let value = parseFloat(this.offsetNumber);
let isNegative = value < 0;
let isPercent = this.offsetType === "percent";
if (this.referencePoint !== "timelineStart") {
value = Math.abs(value);
}
```
--------------------------------
### Get and Set startTime for GSAP Tween
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Tween/startTime().md
Use the startTime() method to retrieve the current start time of an animation or to set a new start time. When setting the time, the method returns the animation instance for chaining.
```javascript
//gets current start time
var start = myAnimation.startTime();
//sets the start time
myAnimation.startTime(2);
```
--------------------------------
### onLeaveBack Callback Example
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/Plugins/ScrollTrigger/index.html
Use this callback when the scroll position moves backward past the 'start' of the trigger. It receives the ScrollTrigger instance.
```javascript
onLeaveBack: ({progress, direction, isActive}) => console.log(progress, direction, isActive)
```
--------------------------------
### Example Usage
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/UtilityMethods/clamp().html
Demonstrates how to use the clamp() utility method to create a reusable clamping function and then apply it to various values.
```javascript
var clamper = gsap.utils.clamp(0, 100);
console.log(clamper(105)); // Output: 100
console.log(clamper(-50)); // Output: 0
console.log(clamper(20)); // Output: 20
```
--------------------------------
### gsap.matchMedia()
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.matchMedia().html
Initializes a MatchMedia instance for managing responsive animations.
```APIDOC
## gsap.matchMedia()
### Description
Creates a MatchMedia instance. This instance can be used to register multiple media queries and their associated callback functions. All GSAP animations and ScrollTriggers created within these callbacks are automatically managed and can be reverted.
### Method
`gsap.matchMedia()`
### Returns
- `MatchMedia` - An instance of MatchMedia that can be used to add and manage responsive animations.
```
--------------------------------
### from() Animation with Timeline
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/from().md
This example shows how to use the from() method within a GSAP Timeline. The animation starts from the specified state and is positioned on the timeline.
```javascript
tl.from(".green-box", {
x: 500,
duration: 1
}, "start");
```
--------------------------------
### Combine GSAP Utilities with quickSetter
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.quickSetter().html
This example demonstrates combining gsap.utils.clamp(), gsap.utils.snap(), and gsap.quickSetter() to create a function that sanitizes and sets a property with a specific unit. It ensures values are within a range, snapped to increments, and have a unit appended.
```javascript
let xSetter = gsap.utils.pipe(
gsap.utils.clamp(0, 100), //make sure the number is between 0 and 100
gsap.utils.snap(5), //snap to the closest increment of 5
gsap.quickSetter("#id", "x", "px") //apply it to the #id element's x property and append a "px" unit
);
//then later...
xSetter(150) //sets the #el's transform to translateX(100px) (clamped to 100)
xSetter(3) //sets it to 5px (snapped)...
```
--------------------------------
### Observer.getAll()
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/Plugins/Observer/static.getAll().md
Gets an Array of all Observers that have been created (and not killed). This can be useful if, for example, your framework requires that you kill everything like on a routing change.
```APIDOC
## Observer.getAll()
### Description
Gets an Array of all Observers that have been created (and not killed). This can be useful if, for example, your framework requires that you kill everything like on a routing change.
### Method
GET (or equivalent for SDK)
### Endpoint
Observer.getAll()
### Returns
- Array - An Array of Observer instances
### Example
```javascript
Observer.getAll((o) => o.kill());
```
```
--------------------------------
### Basic Timeline Setup and getChildren() Usage
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Timeline/getChildren().html
Demonstrates setting up a master timeline with nested tweens and a nested timeline, then using getChildren() to retrieve direct children.
```javascript
var master = gsap.timeline({ defaults: { duration: 1 } }),
nested = gsap.timeline();
nested.to("#e1", { duration: 1, x: 100 }).to("#e2", { duration: 2, y: 200 });
master
.to("#e3", { top: 200 })
.to("#e4", { left: 100 })
.to("#e5", { backgroundColor: "red" });
master.add(nested);
var children = master.getChildren(false, true, true);
console.log(children.length); //"3" (2 tweens and 1 timeline)
```
--------------------------------
### Get Tween Progress
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/Tween/progress().html
Retrieves the current progress of the tween. This value ranges from 0 (start) to 1 (end) and does not account for repeats.
```javascript
var progress = myTween.progress();
```
--------------------------------
### HTML Structure for matchMedia Example
Source: https://github.com/itziklerner-pag/gsap-docs-v3/blob/main/GSAP/gsap.matchMedia().md
This HTML sets up the basic structure for the responsive animation example, including headers and divs for mobile and desktop content.
```html
When the viewport is less than 800px, the "Mobile" <div> will animate. Otherwise, "Desktop" will. Pretty cool, right? Resize your screen. 800px is the break point. It's all dynamic! Check out GSAP today. Use matchMedia for easy, accessibility friendly animation. Pretty cool, right? You can read more about reduced motion and vestibular disorders in this blog post on CSS tricks How do I adjust my reduced motion setting? Check out GSAP today. gsap.matchMedia()
gsap.matchMedia()
Use matchMedia and the prefers-reduced-motion media feature for easy, accessibility-friendly animation.
Pretty cool, right?
You can read more about reduced motion and vestibular disorders in this blog post on CSS tricks
How do I adjust my reduced motion setting?
Check out GSAP today.