-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
70 lines (60 loc) · 2.08 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
// Access the elements of DOM
let navBar = document.querySelector('header');
let year = document.querySelector('[year]');
let bar1 = document.querySelector(".bar1");
let bar2 = document.querySelector(".bar2");
let bar3 = document.querySelector(".bar3");
let navUl = document.querySelector('[nav-ul]');
let moreProjects = document.querySelectorAll('[seeMore]');
const moreButton = document.querySelector('[see-more-button]');
// Global variable creation.
let prevScroll = window.scrollY;
let date = new Date();
let shown = false;
year.textContent = date.getFullYear();
//Evenet listners.
window.addEventListener('scroll', handleNav);
// functions.
function handleNav(){
let curScroll = window.scrollY;
if(curScroll > prevScroll){
navBar.classList.remove('show');
}else{
navBar.classList.add('show');
if(curScroll ==0){
navBar.style.backgroundColor = "rgba(2,2,2,0.2)";
}else{
navBar.style.backgroundColor = "rgba(2,2,2,0.9)";
}
}
prevScroll = curScroll;
}
function displayNav(){
if(!shown){
shown = true;
navUl.classList.add("active");
bar2.classList.add("hide-Bar");
bar1.classList.add("bar-rotate-1");
bar3.classList.add("bar-rotate-3");
}else{
shown = false;
navUl.classList.remove("active");
bar2.classList.remove("hide-Bar");
bar1.classList.remove("bar-rotate-1");
bar3.classList.remove("bar-rotate-3");
}
}
function loadProjects(){
moreButton.style.display = "none";
moreProjects.forEach((project)=>{
project.style.display = "block";
})
}
document.addEventListener('DOMContentLoaded', function () {
const progressBars = document.querySelectorAll('.progress-bar');
progressBars.forEach(bar => {
const percentage = bar.getAttribute('data-percentage');
bar.style.setProperty('--percentage', percentage + '%');
bar.querySelector('::before').style.width = percentage + '%';
});
});