-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
167 lines (134 loc) · 4.03 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
// MENU MOBILE
const all_Items = document.querySelectorAll(".nav-item");
const btn_mobile = document.querySelector(".mobile-menu");
const nav_bar = document.querySelector("nav");
const Close_Menu = () => {
nav_bar.classList.toggle("nav-active");
btn_mobile.classList.toggle("transform");
};
all_Items.forEach((data) => {
data.addEventListener("click", () => {
Close_Menu();
});
});
btn_mobile.addEventListener("click", () => {
nav_bar.classList.toggle("nav-active");
btn_mobile.classList.toggle("transform");
});
//---------------------------------------------------
// SLIDER DO PORTIFOLIO
const arrow_right = document.querySelector("#arrow-right");
const arrow_left = document.querySelector("#arrow-left");
const slider_images = document.querySelectorAll(".slider-images li");
const slider_dot = document.querySelectorAll(".slider-points div");
let slider_index = 0;
function show(index) {
slider_images.forEach((data) => {
data.style.opacity = 0;
data.style.transform = "translateX(-15%)";
});
slider_dot.forEach((data) => {
data.style.background = "#afaeae";
});
slider_images[index].style.opacity = 1;
slider_images[index].style.transform = "translateX(0%)";
slider_dot[index].style.background = "var(--secondaryColor)";
return (slider_index = index);
}
arrow_right.addEventListener("click", () => {
if (slider_index < slider_images.length - 1) {
slider_index++;
show(slider_index);
return;
}
if (slider_index === slider_images.length - 1) {
show(0);
return;
}
});
arrow_left.addEventListener("click", () => {
if (slider_index > 0) {
slider_index--;
show(slider_index);
return;
}
if (slider_index === 0) {
show(slider_images.length - 1);
return;
}
});
for (let index = 0; index < slider_dot.length; index++) {
slider_dot[index].addEventListener("click", () => {
show(index);
});
}
//---------------------------------------------------
// MUDAR COR DO HEADER
const header = document.querySelector("header");
const home = document.querySelector("#home");
const Background_Header = () => {
if (window.scrollY >= home.offsetHeight - 20 && screen.width > 650) {
header.classList.add("header-down");
} else {
header.classList.remove("header-down");
}
};
//-------------------------------------------------------
// ANIMAÇÃO DE PREENCHIMENTO DA BARRA
const progress_bar = document.querySelectorAll(" .progress-data");
function Loading_Bar() {
progress_bar.forEach((element) => {
let value = element.textContent;
element.style.animation = "progress 2s ease";
element.style.width = value;
});
}
//----------------------------------------------------------
// EFEITO ESCREVER
const MainText = document.querySelector("#home-right-side h1");
function Type_Write(el) {
const textArray = el.innerText.split("");
el.innerHTML = "";
textArray.forEach(function (letter, i) {
setTimeout(function () {
el.innerHTML += letter;
}, 550 * i);
});
}
Type_Write(MainText);
//-------------------------------------------------------------
// EFEITO FADE IN
const sections = document.querySelectorAll(".section");
const SectionsArray = Array.from(sections);
function Fade_Effect() {
SectionsArray.forEach((element) => {
const Height = element.offsetTop;
if (scrollY >= Height - 450) {
element.style.opacity = 1;
Loading_Bar();
} else {
element.style.opacity = 0;
}
});
}
//--------------------------------------------------------------
// EFEITO SCROLL SUAVE
const nav_text = document.querySelectorAll("header nav a");
nav_text.forEach((element) => {
element.addEventListener("click", Smooth_Scroll);
});
function Smooth_Scroll(e) {
e.preventDefault();
const link = event.target;
const location = link.getAttribute("href");
const move = document.querySelector(location).offsetTop;
window.scroll({
top: move - 60,
behavior: "smooth",
});
}
//--------------------------------------------------------------
document.addEventListener("scroll", () => {
Background_Header();
Fade_Effect();
});