-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (41 loc) · 1.55 KB
/
script.js
File metadata and controls
48 lines (41 loc) · 1.55 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
function toggleMenu() {
const menu = document.querySelector(".menu-links"); // select the menu-links class
const icon = document.querySelector(".hamburger-icon"); // select the hamburger-icon class
menu.classList.toggle("open"); // toggle the open class on the menu
icon.classList.toggle("open"); // toggle the open class on the icon
}
const div = document.querySelector(".title");
const text = "Naveed"; // Ensure the space is included between first and last name
function textTypingEffect(element, text, i = 0) {
if (i === 0) {
element.innerText = ""; // Clear text initially
}
if (i < text.length) {
element.innerText += text[i];
setTimeout(() => textTypingEffect(element, text, i + 1), 250); // Adjust the timeout to slow down the typing effect
}
}
document.addEventListener("DOMContentLoaded", () => {
if (div) {
textTypingEffect(div, text);
}
// Intersection Observer for fade-in animations
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.15
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
const sections = document.querySelectorAll('section');
sections.forEach(section => {
section.classList.add('fade-in-section');
observer.observe(section);
});
});