-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
98 lines (84 loc) · 2.85 KB
/
main.js
File metadata and controls
98 lines (84 loc) · 2.85 KB
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
// ============================ start Header ===========================//
let allLinks = document.querySelectorAll('.nav li a');
let menuBtn = document.querySelector('.mean');
let menuSpans = document.querySelector('.mean').children;
let menuLayOut = document.querySelector('.layout');
let nav = document.querySelector('.nav');
let isOpen = false ;
allLinks.forEach(link => {
link.onclick = (from) => {
from.preventDefault();
window.scrollTo({
top : document.querySelector(`.${link.dataset.url}`).offsetTop - 50 ,
behavior : 'smooth' ,
})
if(isOpen) {
isOpen = false ;
fixedNav() ;
}
}
})
let scrollBtn = document.querySelector('#sceollBtn') ;
window.onscroll = () => {
if( window.scrollY >= 500 ) {
scrollBtn.style.opacity = '1';
} else {
scrollBtn.style.opacity = '0';
}
}
// open navpar in screen phone
menuBtn.onclick = () => {
isOpen = !isOpen;
changeNavigationPosition()
}
// fixed the navbar
function changeNavigationPosition() {
for( let i = 0 ; i < menuSpans.length ; ++ i ) {
menuSpans[i].classList.toggle('open') ;
}
if( isOpen ) {
menuLayOut.setAttribute('aria-hidden',false)
nav.setAttribute('aria-hidden',false)
menuBtn.setAttribute('aria-expanded',true)
}else {
menuLayOut.setAttribute('aria-hidden',true)
nav.setAttribute('aria-hidden',true)
menuBtn.setAttribute('aria-expanded',false)
}
}
scrollBtn.onclick = () => {
window.scrollTo({
top : 0 ,
behavior : 'smooth' ,
})
}
// ============================ end Header ===========================//
// ============================ start Landing ===========================//
let str = document.querySelector('.landing .info h1 #text') ;
writerWorld(str,300);
function writerWorld(srcCode,speed) {
let innerName = srcCode.textContent ;
let index = 0 , test = true;
srcCode.innerHTML = innerName[index++] ;
let write = setInterval(()=>{
if( index < innerName.length && test ) {
srcCode.innerHTML += innerName[index++] ;
}else {
let index_2 = 0 ;
srcCode.innerHTML = innerName[index_2++];
for( ; index_2 < index ; index_2 ++ ) {
srcCode.innerHTML += innerName[index_2];
}
index--; test = false ;
if(index == -1 ) {
test = true ;
index = 1 ;
}
}
},speed)
}
// ============================ end Landing ===========================//
// ============================ start Skills ==========================//
let allBox = [...document.querySelectorAll('.skills .container .box') ] ,
mainContainer = document.querySelector('.skills .container') ;
// ============================ end Skills ==========================//