-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
76 lines (69 loc) · 1.44 KB
/
script.js
File metadata and controls
76 lines (69 loc) · 1.44 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Register ScrollTrigger plugin
gsap.registerPlugin(ScrollTrigger);
// Animate hero text and header on load
window.addEventListener("load", () => {
gsap.from("h1", {
opacity: 0,
y: 50,
duration: 1.2,
ease: "power3.out"
});
gsap.from("header", {
y: -60,
opacity: 0,
duration: 1,
ease: "power3.out",
delay: 0.2
});
});
// Animate all section entrances
gsap.utils.toArray("section").forEach((section) => {
gsap.from(section, {
scrollTrigger: {
trigger: section,
start: "top 85%",
toggleActions: "play none none none",
},
opacity: 0,
y: 50,
duration: 1,
ease: "power2.out",
});
});
// Animate project cards
gsap.utils.toArray(".group").forEach((card, i) => {
gsap.from(card, {
scrollTrigger: {
trigger: card,
start: "top 90%",
},
y: 50,
opacity: 0,
duration: 0.8,
ease: "power3.out",
delay: i * 0.1,
});
});
// Animate footer
gsap.from("footer", {
scrollTrigger: {
trigger: "footer",
start: "top 90%",
},
opacity: 0,
y: 30,
duration: 1,
ease: "power2.out"
});
// Lenis Smooth Scroll
const lenis = new Lenis({
duration: 1.2,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // easeOutExpo
smooth: true,
smoothTouch: false
});
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);