-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (40 loc) · 1.11 KB
/
script.js
File metadata and controls
46 lines (40 loc) · 1.11 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
document.addEventListener("DOMContentLoaded", () => {
// Initialize AOS (Animate On Scroll) library
AOS.init({
duration: 1000, // Animation duration
offset: 100, // Trigger animation when element is 100px in viewport
});
// Smooth scrolling for navigation links
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
document.querySelector(this.getAttribute("href")).scrollIntoView({
behavior: "smooth",
});
});
});
});
//typing animation
const texts = [
"A Passionate Web Developer",
"A Cloud Enthusiast",
"Software Engineer",
];
let count = 0;
let index = 0;
let currentText = "";
let letter = "";
const type = () => {
if (count === texts.length) count = 0;
currentText = texts[count];
letter = currentText.slice(0, ++index);
document.querySelector(".typing").textContent = letter;
if (letter.length === currentText.length) {
count++;
index = 0;
setTimeout(type, 1500);
} else {
setTimeout(type, 100);
}
};
document.addEventListener("DOMContentLoaded", type);