-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
132 lines (111 loc) · 3.45 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
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
const changingText = document.getElementById("changingText");
const cngArray = [
"Web Development",
"Frontend Development",
"Backend Development",
"Mobile app Development",
"Full stack",
"Cross Platform App",
"Desktop app Development",
"Flutter",
"FrameWorks",
"E-commerce",
"Git/GitHab",
"Docker",
"DataBases",
"Server Structure",
"Linux",
];
let currentIndex = 0;
function Slider() {
changingText.textContent = cngArray[currentIndex];
currentIndex = (currentIndex + 1) % cngArray.length;
}
setInterval(Slider, 2000);
// Skill > Circle --------------//-----------///------------///
const circle = document.querySelectorAll(".circle");
const skill = document.querySelectorAll(".skill");
function isElementInViewport(element) {
const rect = element.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <=
(window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
circle.forEach((elem) => {
var dots = elem.getAttribute("data-dots");
var marked = elem.getAttribute("data-percent");
var parcent = Math.floor((dots * marked) / 100);
var points = "";
var rotate = 360 / dots;
for (let i = 0; i < dots; i++) {
points += `<div class="points" style="--i:${i}; --rot:${rotate}deg;"></div>`;
}
elem.innerHTML = points;
window.addEventListener("scroll", async function handleScroll() {
circle.forEach((element) => {
if (isElementInViewport(element)) {
const pointMarked = elem.querySelectorAll(".points");
for (let s = 0; s < parcent; s++) {
pointMarked[s].classList.add("marked");
// console.log(pointMarked[s])
}
}
});
});
});
const bar = document.querySelectorAll(".fillBar");
window.addEventListener("scroll", async function handleScroll2() {
bar.forEach((element) => {
if (isElementInViewport(element)) {
element.classList.add("run");
}
});
});
// navigation button -------------------//-------------//------------------//-------------/------------------//----
const navbtn = document.getElementById("navbtn");
const navli = document.querySelector(".navlist");
function togglehide() {
if (navli.style.display == "none") {
navli.style.display = "block";
} else {
navli.style.display = "none";
}
}
navbtn.addEventListener("click", togglehide);
window.addEventListener(
"scroll",
(navhide = () => {
if (navli.style.display === "block") {
navli.style.display = "none";
}
})
);
// light theme ///////////////////////////////////////////////////////////////
const lightTheme = document.getElementById("light-theme");
const lightbtn = document.getElementById("light");
console.log(lightTheme);
if (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
) {
lightTheme.innerHTML = `<link rel="stylesheet" href="style.css">`;
} else {
lightTheme.innerHTML = `<link rel="stylesheet" href="light.css">`;
}
// lightTheme.innerHTML = '<link rel="stylesheet" href="light.css" id="light-theme">'
function theme() {
if (lightTheme.href == "style.css") {
lightTheme.href = "light.css";
} else {
lightTheme.href = "style.css";
}
}
lightbtn.addEventListener("click", theme);
// =============== PortFolio Posts ===================
// const postParent = document.getElementById("post-parent");
// const post = postCardTemplate(data[0]);
// postParent.appendChild(post);