-
Notifications
You must be signed in to change notification settings - Fork 4
/
script.js
48 lines (39 loc) · 1.46 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
40
41
42
43
44
45
46
47
48
document.addEventListener("DOMContentLoaded", function () {
const nav = document.querySelector("nav");
const navToggle = document.createElement("button");
const header = document.querySelector("header");
navToggle.classList.add("nav-toggle");
navToggle.innerHTML = "☰";
nav.insertBefore(navToggle, nav.firstChild);
navToggle.addEventListener("click", function () {
nav.classList.toggle("open");
navToggle.innerHTML = nav.classList.contains("open") ? "✕" : "☰";
if (nav.classList.contains("open")) {
navToggle.classList.add("rotate");
header.style.marginTop = "285px";
} else {
navToggle.classList.remove("rotate");
header.style.marginTop = "85px";
}
});
const navLinks = document.querySelectorAll("nav a");
navLinks.forEach((link) => {
link.addEventListener("click", function () {
navLinks.forEach((l) => l.classList.remove("active"));
this.classList.add("active");
if (window.innerWidth <= 600) {
nav.classList.remove("open");
navToggle.innerHTML = "☰";
header.style.marginTop = "85px";
}
});
});
new cursoreffects.springyEmojiCursor({ emoji: "🤷♂️" });
});
let currentIndex = 0;
function moveCarousel(direction) {
const items = document.querySelectorAll(".carousel-item");
items[currentIndex].classList.remove("active");
currentIndex = (currentIndex + direction + items.length) % items.length;
items[currentIndex].classList.add("active");
}