-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
67 lines (56 loc) · 1.49 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
/* About Me + Projects */
var container = document.getElementById("container");
function aboutMe() {
document.getElementById("about").style.opacity = "1";
document.getElementById("projects").style.opacity = "0";
}
function projectsInfo() {
document.getElementById("about").style.opacity = "0";
document.getElementById("projects").style.opacity = "1";
}
/* Function to Smoothen the Scroll */
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
});
});
});
/* Type & Delete Effect */
const words = ["Designer", "Developer", "Organisational Thinker"];
let i = 0;
let timer;
function typingEffect() {
let word = words[i].split("");
var loopTyping = function () {
if (word.length > 0) {
document.getElementById("word").innerHTML += word.shift();
} else {
deletingEffect();
return false;
}
timer = setTimeout(loopTyping, 300);
};
loopTyping();
}
function deletingEffect() {
let word = words[i].split("");
var loopDeleting = function () {
if (word.length > 0) {
word.pop();
document.getElementById("word").innerHTML = word.join("");
} else {
if (words.length > i + 1) {
i++;
} else {
i = 0;
}
typingEffect();
return false;
}
timer = setTimeout(loopDeleting, 150);
};
loopDeleting();
}
typingEffect();