-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
39 lines (34 loc) · 1.45 KB
/
script.js
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
document.addEventListener('DOMContentLoaded', () => {
AOS.init({
duration: 1000,
once: true,
offset: 100
});
const nav = document.querySelector('nav');
const sections = document.querySelectorAll('.section');
const goToTop = document.querySelector('.go-to-top');
nav.addEventListener('click', (e) => {
if (e.target.tagName === 'I') {
e.preventDefault();
const targetId = e.target.parentElement.getAttribute('href');
const targetSection = document.querySelector(targetId);
targetSection.scrollIntoView({ behavior: 'smooth' });
}
});
window.addEventListener('scroll', () => {
if (window.pageYOffset > 100) {
goToTop.classList.add('show');
} else {
goToTop.classList.remove('show');
}
});
goToTop.addEventListener('click', () => {
window.scrollTo({ top: 0, behavior: 'smooth' });
});
const form = document.querySelector('.contact-form');
form.addEventListener('submit', (e) => {
e.preventDefault();
alert('Thank you for your message. I will get back to you soon!');
form.reset();
});
});