-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
84 lines (72 loc) · 2.26 KB
/
Copy pathscript.js
File metadata and controls
84 lines (72 loc) · 2.26 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
function handleLinkNav(goTo) {
toggleSection(goTo);
toggleNavbar(goTo);
}
function toggleNavbar(goTo) {
var navLink = document.getElementById(goTo + "Link");
var activeLink = document.querySelector('.selected');
activeLink.classList.remove("selected");
navLink.classList.add("selected");
}
function toggleSection(goTo) {
var activeSection = document.querySelector('.contentSection.active');
activeSection.classList.add("hidden");
activeSection.classList.remove("active");
var navigateTo = document.getElementById(goTo);
navigateTo.classList.remove("hidden");
navigateTo.classList.add("active");
}
function typingAnimation(className ,text, animator, speed, delay) {
var options = {
strings: [text],
typeSpeed: speed || 50,
showCursor: false,
loop: false,
startDelay: delay || 0,
preStringTyped: function(self) {animator.start()},
onStringTyped: function(self) {animator.pause()}
};
var typed = new Typed(`.${className}`, options);
}
document.addEventListener('DOMContentLoaded', function() {
var animator = new EmoteAnimator();
typingAnimation("typed-title" ,"Hallo", animator, 75);
typingAnimation("typed-subtitle" ,"Ich bin Daniel.", animator, 75, 1300);
});
class EmoteAnimator {
constructor() {
this.emote = document.querySelector('.emote');
this.emoteList = ["^=^", "^-^", "^≈^", "^o^", "^-^"];
this.index = 0;
this.run = true;
this.animationInterval = setInterval(() => {
if (this.run) {
this.updateEmote();
}
}, 100);
}
updateEmote() {
this.emote.textContent = this.emoteList[this.index];
this.index = (this.index + 1) % this.emoteList.length;
}
start() {
this.run = true;
}
pause() {
this.run = false;
setTimeout(() => {
this.emote.textContent = "°-°";
}, 200);
}
}
function handleArrowVisibility(arrowIcon) {
if(window.scrollY > 0) {
arrowIcon.style.opacity = 0;
} else {
arrowIcon.style.opacity = 1;
}
}
window.addEventListener('scroll', function() {
var arrowIcon = document.getElementById("arrowIcon");
handleArrowVisibility(arrowIcon);
});