-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.js
107 lines (85 loc) · 2.73 KB
/
file.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
const filter_btns = document.querySelectorAll(".filter-btn");
const skills_wrap = document.querySelector(".skills");
const skills_bars = document.querySelectorAll(".skill-progress");
const records_wrap = document.querySelector(".records");
const records_numbers = document.querySelectorAll(".number");
const footer_input = document.querySelector(".footer-input");
const hamburger_menu = document.querySelector(".hamburger-menu");
const navbar = document.querySelector("header nav");
const links = document.querySelectorAll(".links a");
footer_input.addEventListener("focus", () => {
footer_input.classList.add("focus");
});
footer_input.addEventListener("blur", () => {
if (footer_input.value != "") return;
footer_input.classList.remove("focus");
});
function closeMenu() {
navbar.classList.remove("open");
document.body.classList.remove("stop-scrolling");
}
hamburger_menu.addEventListener("click", () => {
if (!navbar.classList.contains("open")) {
navbar.classList.add("open");
document.body.classList.add("stop-scrolling");
} else {
closeMenu();
}
});
links.forEach((link) => link.addEventListener("click", () => closeMenu()));
filter_btns.forEach((btn) =>
btn.addEventListener("click", () => {
filter_btns.forEach((button) => button.classList.remove("active"));
btn.classList.add("active");
let filterValue = btn.dataset.filter;
$(".grid").isotope({ filter: filterValue });
})
);
$(".grid").isotope({
itemSelector: ".grid-item",
layoutMode: "fitRows",
transitionDuration: "0.6s",
});
window.addEventListener("scroll", () => {
skillsEffect();
countUp();
});
function checkScroll(el) {
let rect = el.getBoundingClientRect();
if (window.innerHeight >= rect.top + el.offsetHeight) return true;
return false;
}
function skillsEffect() {
if (!checkScroll(skills_wrap)) return;
skills_bars.forEach((skill) => (skill.style.width = skill.dataset.progress));
}
function countUp() {
if (!checkScroll(records_wrap)) return;
records_numbers.forEach((numb) => {
const updateCount = () => {
let currentNum = +numb.innerText;
let maxNum = +numb.dataset.num;
let speed = 100;
const increment = Math.ceil(maxNum / speed);
if (currentNum < maxNum) {
numb.innerText = currentNum + increment;
setTimeout(updateCount, 1);
} else {
numb.innerText = maxNum;
}
};
setTimeout(updateCount, 400);
});
}
var mySwiper = new Swiper(".swiper-container", {
speed: 1100,
slidesPerView: 1,
loop: true,
autoplay: {
delay: 5000,
},
navigation: {
prevEl: ".swiper-button-prev",
nextEl: ".swiper-button-next",
},
});