-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
65 lines (52 loc) · 2 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Dot loading logic
window.addEventListener('load', function() {
// Get the overlay element
var overlay = document.getElementById('loading-overlay');
// Add a class to fade out the overlay
overlay.classList.add('fade-out');
// Remove the overlay from the DOM after the fade-out animation
setTimeout(function() {
overlay.style.display = 'none';
}, 1000); // Match this time with the CSS transition duration
});
// smoother navigation
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
// slid up In hero class
document.addEventListener('DOMContentLoaded', () => {
const slideElements = document.querySelectorAll('.slide-up');
const checkVisibility = () => {
slideElements.forEach(element => {
const rect = element.getBoundingClientRect();
const windowHeight = window.innerHeight;
if (rect.top < windowHeight * 0.8) {
setTimeout(() => {
element.classList.add('visible');
}, 300); // Delay of 300 milliseconds
}
});
};
checkVisibility();
window.addEventListener('scroll', checkVisibility);
});
/* function toggleNav() {
var nav = document.querySelector('nav.main-nav');
nav.classList.toggle('open');
} */
function toggleNav() {
const menu = document.querySelector('nav.main-nav');
const button = document.querySelector('.menu-toggle');
if (menu.classList.contains('open')) {
menu.classList.remove('open');
button.innerHTML = '☰'; // Change icon back to "hamburger"
} else {
menu.classList.add('open');
button.innerHTML = '✖'; // Change icon to "close"
}
}