-
Notifications
You must be signed in to change notification settings - Fork 1
/
gsap.js
34 lines (31 loc) · 1.08 KB
/
gsap.js
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
//Scroller
const container = document.querySelector('.timeline_project');
const selections = gsap.utils.toArray('.timeline_project section');
const etxts = gsap.utils.toArray('.anim');
const mask = document.querySelector('.mask');
// Calculate the total width of all text sections
let totalWidth = 0;
selections.forEach(section => {
totalWidth += section.offsetWidth;
});
//scroll trigger (scrolling = moving right on timeline)
let scrollTween = gsap.to(selections, {
xPercent: -100 * (selections.length - 1), // x-axis scroll
ease: "none", // constant speed of animation
scrollTrigger: {
trigger: ".timeline_project",
pin: true, // element will be pinned to the viewport (while scrolling trigger, no down scrolling)
scrub: 1, // scroll and movement of text happens synchronized
end: "+=1500" // End point when all text sections are fully shown
}
});
//mask black filling gray SVG
gsap.to(mask, {
width: "100%",
scrollTrigger: {
trigger: ".timeline_project",
start: "top top",
scrub: 1,
end: "+=1800"
}
});