GSAP Context
Utility
GSAP
JS
- With GSAP Context, we can pass class names directly into our timeline, and it will only target children of the current component.
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".your-section").forEach((component) => {
gsap.context(() => {
let tl = gsap.timeline();
tl.from(component, { opacity: 0, y: "2rem" });
tl.from(".child-image", { scale: 1.2 }, "<");
}, component);
});
});
</script>- Without GSAP Context....
tl.from(component.querySelectorAll(".child-image"), { scale: 1.2 }, "<");- With GSAP Context....
tl.from(".child-image", { scale: 1.2 }, "<");Preview Links
Custom JS
Enable custom code in preview or view on published site.
Enable custom code?
Last Updated: Dec 3, 2025
- With GSAP Context, we can pass class names directly into our timeline, and it will only target children of the current component.
<script src="https://cdn.jsdelivr.net/npm/gsap@3.13.0/dist/gsap.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".your-section").forEach((component) => {
gsap.context(() => {
let tl = gsap.timeline();
tl.from(component, { opacity: 0, y: "2rem" });
tl.from(".child-image", { scale: 1.2 }, "<");
}, component);
});
});
</script>- Without GSAP Context....
tl.from(component.querySelectorAll(".child-image"), { scale: 1.2 }, "<");- With GSAP Context....
tl.from(".child-image", { scale: 1.2 }, "<");