-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
93 lines (71 loc) · 2.92 KB
/
main.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
let spanProgress = document.querySelectorAll(".skill-bar span");
let textProgress = document.querySelectorAll(".text-progress");
let skillSection = document.querySelector(".skills")
var flag = false;
window.onscroll = function () {
if (window.scrollY >= skillSection.offsetTop - 300 && (!flag)) {
flag = true
spanProgress.forEach((ele) => (ele.style.width = ele.dataset.progress));
textProgress.forEach(function(ele, index) {
var limit = parseFloat(spanProgress[index].dataset.progress)
let counter = setInterval(function(){
ele.textContent++
if(ele.textContent >= parseFloat(spanProgress[index].dataset.progress)) {
clearInterval(counter)
}
}, 2000 / limit)
})
}
};
// Gallery
let gallerySwitcher = document.querySelectorAll(".switcher")
let category = document.querySelectorAll(".projects-container article")
function showElements(category, type) {
category.forEach(function(ele) {
if(ele.classList.contains(type)) {
ele.style.display = "flex"
setTimeout(() => {ele.style.opacity = "1"}, 500)
}
ele.classList.contains(type)
? ele.style.display = "flex"
: ""
})
}
addEventListener("click", function(evt) {
if(evt.target.classList.contains("switcher")) {
category.forEach(ele => ele.style.cssText = "display: none; opacity: 0")
gallerySwitcher.forEach(ele => ele.classList.remove("active"))
evt.target.classList.add("active")
}
if(evt.target.dataset.category === "landing-category") {
showElements(category, evt.target.dataset.category)
} else if (evt.target.dataset.category === "webapp-category") {
showElements(category, evt.target.dataset.category)
} else if (evt.target.dataset.category === "api-category") {
showElements(category, evt.target.dataset.category)
} else if (evt.target.dataset.category === "all") {
category.forEach(function(ele) {
ele.style.display = "flex"
setTimeout(() => {ele.style.opacity = "1"}, 500)
})
}
})
// Burger Menu
let navBar = document.querySelector("nav")
function showMenu() {
navBar.classList.toggle("menu")
}
window.onresize = () => window.innerWidth >= 720 ? navBar.classList.remove("menu") : ""
// Load Content
let portfolioSection = document.querySelector(".portfolio")
let aboutSection = document.querySelector(".about")
let contactSection = document.querySelector(".contact")
function loadContent(ele) {
console.log(window.scrollY)
if (window.scrollY >= ele.offsetTop - 400) {
ele.style.cssText = "opacity: 1; transform: translateX(0) scale(1, 1)"
}
}
window.addEventListener("scroll", () => loadContent(portfolioSection))
window.addEventListener("scroll", () => loadContent(aboutSection))
window.addEventListener("scroll", () => loadContent(contactSection))