-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
127 lines (112 loc) · 4.09 KB
/
Copy pathscript.js
File metadata and controls
127 lines (112 loc) · 4.09 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// ===== Navigation scroll effect =====
const nav = document.getElementById('nav');
let lastScroll = 0;
window.addEventListener('scroll', () => {
const currentScroll = window.scrollY;
if (currentScroll > 50) {
nav.classList.add('scrolled');
} else {
nav.classList.remove('scrolled');
}
lastScroll = currentScroll;
});
// ===== Mobile menu toggle =====
const navToggle = document.getElementById('nav-toggle');
const navLinks = document.getElementById('nav-links');
navToggle.addEventListener('click', () => {
navLinks.classList.toggle('open');
const spans = navToggle.querySelectorAll('span');
if (navLinks.classList.contains('open')) {
spans[0].style.transform = 'rotate(45deg) translate(5px, 5px)';
spans[1].style.opacity = '0';
spans[2].style.transform = 'rotate(-45deg) translate(5px, -5px)';
} else {
spans[0].style.transform = '';
spans[1].style.opacity = '';
spans[2].style.transform = '';
}
});
// Close mobile menu on link click
navLinks.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('open');
const spans = navToggle.querySelectorAll('span');
spans[0].style.transform = '';
spans[1].style.opacity = '';
spans[2].style.transform = '';
});
});
// ===== Scroll animations (Intersection Observer) =====
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Add fade-in class to elements we want to animate
document.addEventListener('DOMContentLoaded', () => {
const animateElements = [
...document.querySelectorAll('.feature-card'),
...document.querySelectorAll('.tool-category'),
...document.querySelectorAll('.interaction-card'),
...document.querySelectorAll('.provider-card'),
...document.querySelectorAll('.security-card'),
...document.querySelectorAll('.security-extra'),
...document.querySelectorAll('.flow-step'),
...document.querySelectorAll('.section-header'),
];
animateElements.forEach((el, i) => {
el.classList.add('fade-in');
el.style.transitionDelay = `${(i % 4) * 0.1}s`;
observer.observe(el);
});
});
// ===== Smooth scroll for anchor links =====
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', (e) => {
e.preventDefault();
const target = document.querySelector(anchor.getAttribute('href'));
if (target) {
const offsetTop = target.offsetTop - 80;
window.scrollTo({
top: offsetTop,
behavior: 'smooth'
});
}
});
});
// ===== Stat counter animation =====
function animateCounter(el, target, duration = 1500) {
const start = 0;
const startTime = performance.now();
function update(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
const eased = 1 - Math.pow(1 - progress, 3);
const current = Math.round(start + (target - start) * eased);
el.textContent = current;
if (progress < 1) {
requestAnimationFrame(update);
}
}
requestAnimationFrame(update);
}
// Observe stat numbers and animate when visible
const statObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const target = parseInt(entry.target.textContent);
animateCounter(entry.target, target);
statObserver.unobserve(entry.target);
}
});
}, { threshold: 0.5 });
document.querySelectorAll('.stat-number').forEach(el => {
statObserver.observe(el);
});