-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
53 lines (46 loc) · 1.3 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
// Typewriter Effect.
var typeName = document.getElementById("name");
var myName = ["Basim Ahmed Khan", "A Frontend Developer", "A Web Designer", "A Freelancer", "An Automation Developer"];
let charPosition = 0;
let textPosition = 0;
typeWriter = () => {
typeName.innerText = myName[textPosition].substring(0, charPosition);
if(charPosition++ != myName[textPosition].length)
{
setTimeout(typeWriter, 100);
}
let text = myName[textPosition];
if(charPosition === text.length+1)
{
setTimeout(delChar, 3000);
}
};
delChar = () => {
typeName.innerText = myName[textPosition].substring(0, charPosition);
if(--charPosition >= 0)
{
setTimeout(delChar, 50);
}
if(charPosition === 0)
{
if(textPosition === myName.length-1)
{
textPosition = 0;
}
else
{
textPosition++;
}
setTimeout(typeWriter, 1000);
}
};
typeWriter();
// Hamburger Nav.
var collapse = document.getElementById("nav");
var navItem = document.getElementsByClassName("nav-item");
document.getElementById("hamburger").addEventListener("click", hameffect = () => {
collapse.classList.toggle("hamCollapse");
for(let i=0; i<navItem.length; i++){
navItem[i].classList.toggle("display");
}
});