-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
39 lines (35 loc) · 1 KB
/
script.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
35
36
37
38
39
const burger = document.querySelector("nav svg");
burger.addEventListener("click", () => {
if (burger.classList.contains("active")) {
gsap.to(".links", { x: "100%" });
gsap.to(".line", { stroke: "white" });
gsap.set("body", { overflow: "auto" });
gsap.set("body", { overflowX: "hidden" });
} else {
gsap.to(".links", { x: "0%" });
gsap.to(".line", { stroke: "black" });
gsap.fromTo(
".links a",
{ opacity: 0, y: 0 },
{ opacity: 1, y: 20, delay: 0.25, stagger: 0.25 }
);
gsap.set("body", { overflow: "hidden" });
}
burger.classList.toggle("active");
});
const videos = gsap.utils.toArray(".video");
gsap.set(videos, { opacity: 0 });
videos.forEach((video) => {
ScrollTrigger.create({
trigger: video,
start: "top center",
end: "bottom center",
onEnter: () => {
gsap.to(video, { opacity: 1 });
video.play();
},
onEnterBack: () => video.play(),
onLeave: () => video.pause(),
onLeaveBack: () => video.pause(),
});
});