-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
62 lines (52 loc) · 1.98 KB
/
Copy pathscript.js
File metadata and controls
62 lines (52 loc) · 1.98 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
// Hamburger Menu Toggle
const hamburgerMenu = document.querySelector('.hamburger-menu');
const navMenu = document.querySelector('.nav-menu');
const navLinks = document.querySelectorAll('.nav-link');
hamburgerMenu.addEventListener('click', () => {
hamburgerMenu.classList.toggle('active');
navMenu.classList.toggle('mobile-active');
navMenu.classList.toggle('show');
});
// Close menu when a link is clicked
navLinks.forEach(link => {
link.addEventListener('click', () => {
hamburgerMenu.classList.remove('active');
navMenu.classList.remove('show');
// Note: keep mobile-active class visible but not shown
});
});
// Typing Animation
const typingText = document.querySelector('.typing-text');
const typingPhrases = [
'this.name = "André Pereira de Sá";',
'this.role = ["Estudante", "Desenvolvedor"];',
'this.skills = ["JavaScript", "Python"];',
'this.target = "Construir soluções"'
];
let currentPhraseIndex = 0;
let currentCharIndex = 0;
let isDeleting = false;
function typeAnimation() {
const currentPhrase = typingPhrases[currentPhraseIndex];
if (isDeleting) {
typingText.textContent = currentPhrase.substring(0, currentCharIndex - 1);
currentCharIndex--;
} else {
typingText.textContent = currentPhrase.substring(0, currentCharIndex + 1);
currentCharIndex++;
}
let typeSpeed = isDeleting ? 50 : 100;
if (!isDeleting && currentCharIndex === currentPhrase.length) {
typeSpeed = 2000; // Pause at the end
isDeleting = true;
} else if (isDeleting && currentCharIndex === 0) {
isDeleting = false;
currentPhraseIndex = (currentPhraseIndex + 1) % typingPhrases.length;
typeSpeed = 500; // Pause before next phrase
}
setTimeout(typeAnimation, typeSpeed);
}
// Start typing animation when page loads
document.addEventListener('DOMContentLoaded', () => {
typeAnimation();
});