-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (32 loc) · 1.69 KB
/
script.js
File metadata and controls
40 lines (32 loc) · 1.69 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
// Add interactive elements and additional animations
document.addEventListener('DOMContentLoaded', () => {
// Logo is static - no interactive effects needed for now
// Auto-scroll to mission section after 2 seconds (only on first visit, not on refresh)
const hasVisited = sessionStorage.getItem('hasVisited');
if (!hasVisited && window.scrollY === 0) {
setTimeout(() => {
const missionSection = document.querySelector('.mission-section');
if (missionSection) {
sessionStorage.setItem('hasVisited', 'true');
// Custom slow scroll animation
const targetPosition = missionSection.offsetTop;
const startPosition = window.scrollY;
const distance = targetPosition - startPosition;
const duration = 2000; // 2 seconds for the scroll
let start = null;
function animation(currentTime) {
if (start === null) start = currentTime;
const timeElapsed = currentTime - start;
const progress = Math.min(timeElapsed / duration, 1);
// Easing function for smooth deceleration
const ease = progress * (2 - progress); // ease-out quad
window.scrollTo(0, startPosition + (distance * ease));
if (timeElapsed < duration) {
requestAnimationFrame(animation);
}
}
requestAnimationFrame(animation);
}
}, 2000);
}
});