-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (44 loc) · 1.24 KB
/
Copy pathindex.js
File metadata and controls
44 lines (44 loc) · 1.24 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
document.addEventListener("contextmenu",(e) => {
e.preventDefault();
})
const targetText = "Hello,World!";
const speed = 120;
let index = 0;
const HelloWorldText = document.getElementById("HelloWorldText");
const projectDiv = document.getElementById("project-div");
const lookMore = document.getElementById("look-more");
const moreProject = document.getElementById("more-project");
const moreReturn = document.getElementById("more-return");
function typeDel() {
if (index > 0) {
index--;
HelloWorldText.innerHTML = targetText.substring(0, index);
setTimeout(typeDel, speed);
}
else {
setTimeout(() => {
typeWriter();
},2000)
}
}
function typeWriter() {
if (index < targetText.length) {
HelloWorldText.innerHTML = targetText.substring(0, index + 1);
index++;
setTimeout(typeWriter, speed);
}
else {
setTimeout(typeDel, 2000);
}
}
typeWriter();
lookMore.onclick = () => {
moreProject.style.visibility = "visible";
moreProject.style.opacity = "1";
}
moreReturn.onclick = () => {
moreProject.style.opacity = "0";
setTimeout(() => {
moreProject.style.visibility = "hidden";
},500)
}