-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.js
More file actions
29 lines (24 loc) · 973 Bytes
/
Copy pathscript2.js
File metadata and controls
29 lines (24 loc) · 973 Bytes
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
// Wait for the DOM to fully load
document.addEventListener('DOMContentLoaded', function() {
// GSAP ScrollTrigger to animate containers when scrolling
gsap.registerPlugin(ScrollTrigger);
// Select all container elements
const containers = document.querySelectorAll('.container');
// Loop through each container and create a scroll-triggered animation
containers.forEach((container, index) => {
gsap.fromTo(container, {
opacity: 0,
y: 50 // Start position for the animation (50px down)
}, {
opacity: 1,
y: 0,
duration: 1.2,
ease: "power2.out",
scrollTrigger: {
trigger: container, // The element that triggers the animation
start: "top 80%", // Trigger when the top of the element is 80% from the top of the viewport
toggleActions: "play none none none", // Play the animation when it enters the viewport
}
});
});
});