-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (30 loc) · 1.08 KB
/
Copy pathscript.js
File metadata and controls
36 lines (30 loc) · 1.08 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
document.querySelectorAll('button').forEach(button => {
button.addEventListener('mouseover', function() {
this.style.backgroundColor = '#005bb5';
});
button.addEventListener('mouseout', function() {
this.style.backgroundColor = '#0072ff';
});
});
const revealElements = document.querySelectorAll('.animated');
const revealOnScroll = () => {
for (let element of revealElements) {
const elementTop = element.getBoundingClientRect().top;
const viewportHeight = window.innerHeight;
if (elementTop < viewportHeight - 50) {
element.classList.add('visible');
} else {
element.classList.remove('visible');
}
}
};
window.addEventListener('scroll', revealOnScroll);
document.addEventListener('DOMContentLoaded', revealOnScroll);
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});