-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
127 lines (106 loc) · 3.47 KB
/
app.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
126
127
// varibales
const menu = document.querySelector(".menu");
const navLinks = document.querySelector(".nav-links");
const introItems = document.querySelectorAll(".task-text-items .item");
let timoutTime = 7500;
introItems.forEach((item) => {
item.addEventListener("click", function (e) {
// each click on item
// remove active from everyone
// apply this active
introItems.forEach((item) => {
if (item.classList.contains("activeItem")) {
item.classList.remove("activeItem");
}
});
// if the users click on the div we want to give more time to the setTimeOut
// changing the class
item.classList.add("activeItem");
item.style.backgroundColor = item.getAttribute("data-color");
//seeting the correct img
const attrImg = item.getAttribute("data-img");
const currentImg = document.querySelector(".images img");
currentImg.src = `images/${attrImg}`;
currentImg.style.animation = "";
// chage the background main img
const attrBgimage = item.getAttribute("data-backgorund");
document.querySelector(
".tasks"
).style.backgroundImage = `url("images/${attrBgimage}")`;
if (!document.querySelector(".images").style.animation) {
document.querySelector(".images").style.animation =
"opacityImg 0.2s ease-in-out 0.3s normal backwards ";
document
.querySelector(".images")
.addEventListener("animationend", function () {
document.querySelector(".images").style.animation = "";
});
}
//if were clickin on anything beside grid
if (item.querySelector("p").innerHTML != "Grid") {
document.querySelectorAll(".images img")[1].style.display = "none";
} else {
document.querySelectorAll(".images img")[1].style.display = "block";
}
introItems.forEach((item) => {
if (!item.classList.contains("activeItem")) {
item.style.backgroundColor = "transparent";
}
});
});
});
// eventListners
menu.addEventListener("click", function (e) {
document.body.style.overflow = "hidden";
const closeBtn = menu.querySelector("a");
closeBtn.textContent = "X";
closeBtn.classList.add("closeMenu");
if (!navLinks.classList.contains("active")) {
menu.style.zIndex = "2";
document.querySelector(".logo").style.pointerEvents = "none";
navLinks.classList.add("active");
navLinks.style.opacity = "1";
gsap.to(menu.querySelector("a"), 0.5, {
color: "white",
borderColor: "white",
});
gsap.fromTo(navLinks, 1, { translateX: "100%" }, { translateX: "0%" });
navLinks.style.pointerEvents = "all";
} else {
closeBtn.classList.remove("closeMenu");
document.querySelector(".logo").style.pointerEvents = "All";
navLinks.classList.remove("active");
document.body.style.overflowY = "scroll";
closeBtn.textContent = "";
gsap.to(navLinks, 1, { translateX: "100%", onComplete: myfunc });
navLinks.style.pointerEvenets = "none";
}
});
// functions
function myfunc() {
menu.querySelector("a").textContent = "Menu";
gsap.to(menu.querySelector("a"), {
color: "#f82b60",
borderColor: "#f82b60",
});
navLinks.style = "";
}
// setInterval to change to backgrounds
// setInterval(function () {
// //preform a click event on the next tdiv
// // get the currentDiv
// console.log(timoutTime);
// let nextIndex;
// let items = Array.from(introItems);
// for (i in items) {
// if (items[i].classList.contains("activeItem")) {
// i = parseInt(i);
// nextIndex = i + 1;
// if (nextIndex >= items.length) {
// nextIndex = 0;
// }
// }
// }
// const nextItem = items[nextIndex];
// nextItem.click();
// }, timoutTime);