-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
125 lines (113 loc) · 2.96 KB
/
index.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
AOS.init();
const menu = document.querySelector(".menu");
const navOpen = document.querySelector(".hamburger");
const navClose = document.querySelector(".close");
const navLeft = menu.getBoundingClientRect().left;
navOpen.addEventListener("click", () => {
if (navLeft < 0) {
menu.classList.add("show");
document.body.classList.add("show");
navBar.classList.add("show");
}
});
navClose.addEventListener("click", () => {
if (navLeft < 0) {
menu.classList.remove("show");
document.body.classList.remove("show");
navBar.classList.remove("show");
}
});
// Fixed Nav
const navBar = document.querySelector(".nav");
const navHeight = navBar.getBoundingClientRect().height;
window.addEventListener("scroll", () => {
const scrollHeight = window.pageYOffset;
if (scrollHeight > navHeight) {
navBar.classList.add("fix-nav");
} else {
navBar.classList.remove("fix-nav");
}
});
// Scroll To
const links = [...document.querySelectorAll(".scroll-link")];
links.map(link => {
link.addEventListener("click", e => {
e.preventDefault();
const id = e.target.getAttribute("href").slice(1);
const element = document.getElementById(id);
const fixNav = navBar.classList.contains("fix-nav");
let position = element.offsetTop - navHeight;
window.scrollTo({
top: position,
left: 0,
});
navBar.classList.remove("show");
menu.classList.remove("show");
document.body.classList.remove("show");
});
});
new TypeIt("#type1", {
speed: 120,
loop: true,
waitUntilVisible: true,
})
.type("Web Developer", { delay: 400 })
.pause(500)
.delete(9)
.type("Developer", { delay: 400 })
.pause(500)
.delete(9)
.go();
new TypeIt("#type2", {
speed: 120,
loop: true,
waitUntilVisible: true,
})
.type("Web Developer", { delay: 400 })
.pause(500)
.delete(9)
.type("Developer", { delay: 400 })
.pause(500)
.delete(9)
.go();
gsap.from(".logo", { opacity: 0, duration: 1, delay: 0.5, y: -10 });
gsap.from(".hamburger", { opacity: 0, duration: 1, delay: 1, x: 20 });
gsap.from(".banner", { opacity: 0, duration: 1, delay: 1.5, x: -200 });
gsap.from(".hero h3", { opacity: 0, duration: 1, delay: 2, y: -50 });
gsap.from(".hero h1", { opacity: 0, duration: 1, delay: 2.5, y: -45 });
gsap.from(".hero h4", { opacity: 0, duration: 1, delay: 3, y: -30 });
gsap.from(".hero a", { opacity: 0, duration: 1, delay: 3.5, y: 50 });
gsap.from(".nav-item", {
opacity: 0,
duration: 1,
delay: 1.2,
y: 30,
stagger: 0.2,
});
gsap.from(".icons span", {
opacity: 0,
duration: 1,
delay: 4,
x: -30,
stagger: 0.2,
});
const glide = document.querySelector(".glide");
if (glide)
new Glide(glide, {
type: "carousel",
startAt: 0,
perView: 3,
gap: 30,
hoverpause: true,
autoplay: 2000,
animationDuration: 800,
animationTimingFunc: "cubic-bezier(0.165, 0.840, 0.440, 1.000)",
breakpoints: {
996: {
perView: 2,
},
768: {
perView: 1,
},
},
}).mount();