-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (44 loc) · 1.41 KB
/
Copy pathscript.js
File metadata and controls
58 lines (44 loc) · 1.41 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
// NAVBAR SCROLL
window.addEventListener('scroll', function() {
var navbar = document.querySelector('.dynamic-color-navbar');
var aboutSection = document.getElementById('about');
var aboutSectionOffset = aboutSection.offsetTop;
var scrollPosition = window.scrollY;
if (scrollPosition >= aboutSectionOffset) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// NAVBAR TOGGLE WHEN CLICKED
document.getElementById('navbarToggleBtn').addEventListener('click', function() {
document.querySelector('.overlay').classList.toggle('show');
});
// NAVBAR BEHAVIOR
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const targetElement = document.querySelector(this.getAttribute('href'));
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// ARROW ANNIMATION
const style = document.createElement('style');
style.innerHTML = `
@keyframes bounce {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
`;
document.head.appendChild(style);
const logo = document.querySelector('.bi-arrow-down');
logo.style.animation = 'bounce 1s infinite';