-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlanding.js
More file actions
162 lines (133 loc) · 4.57 KB
/
landing.js
File metadata and controls
162 lines (133 loc) · 4.57 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Scroll Reveal Animation
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('revealed');
}
});
}, observerOptions);
// Observe all scroll-reveal elements
document.addEventListener('DOMContentLoaded', () => {
const revealElements = document.querySelectorAll('.scroll-reveal');
revealElements.forEach(el => observer.observe(el));
});
// Platform Tab Switching
const platformTabs = document.querySelectorAll('.platform-tab');
const platformContents = document.querySelectorAll('.platform-content');
platformTabs.forEach(tab => {
tab.addEventListener('click', () => {
const platform = tab.dataset.platform;
// Remove active class from all tabs and contents
platformTabs.forEach(t => t.classList.remove('active'));
platformContents.forEach(c => c.classList.remove('active'));
// Add active class to clicked tab and corresponding content
tab.classList.add('active');
document.querySelector(`.platform-content[data-platform="${platform}"]`).classList.add('active');
});
});
// Smooth scroll for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
// Parallax effect for hero visual
let ticking = false;
function updateParallax() {
const scrolled = window.pageYOffset;
const heroVisual = document.querySelector('.hero-visual');
if (heroVisual) {
const parallaxSpeed = 0.5;
heroVisual.style.transform = `translate(-50%, calc(-50% + ${scrolled * parallaxSpeed}px))`;
}
ticking = false;
}
function requestParallaxTick() {
if (!ticking) {
window.requestAnimationFrame(updateParallax);
ticking = true;
}
}
window.addEventListener('scroll', requestParallaxTick);
// Stagger animation to feature cards
document.addEventListener('DOMContentLoaded', () => {
const featureCards = document.querySelectorAll('.feature-card');
featureCards.forEach((card, index) => {
card.style.transitionDelay = `${index * 0.1}s`;
});
const useCases = document.querySelectorAll('.use-case');
useCases.forEach((useCase, index) => {
useCase.style.transitionDelay = `${index * 0.1}s`;
});
const steps = document.querySelectorAll('.step');
steps.forEach((step, index) => {
step.style.transitionDelay = `${index * 0.15}s`;
});
});
// Nav background on scroll and fade at bottom
let lastScroll = 0;
const nav = document.querySelector('.nav');
const ctaSection = document.querySelector('.cta-section');
function updateNav() {
const currentScroll = window.pageYOffset;
const ctaPosition = ctaSection.getBoundingClientRect().top;
const windowHeight = window.innerHeight;
// Fade out nav when CTA section is in view
if (ctaPosition < windowHeight / 2) {
nav.classList.add('hidden');
} else {
nav.classList.remove('hidden');
}
lastScroll = currentScroll;
}
window.addEventListener('scroll', updateNav);
window.addEventListener('load', updateNav);
// Mouse trail effect
let mouseX = 0;
let mouseY = 0;
let mouseTrailX = 0;
let mouseTrailY = 0;
document.addEventListener('mousemove', (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
});
function animateMouseTrail() {
mouseTrailX += (mouseX - mouseTrailX) * 0.1;
mouseTrailY += (mouseY - mouseTrailY) * 0.1;
requestAnimationFrame(animateMouseTrail);
}
animateMouseTrail();
// Hover effect of buttons
const buttons = document.querySelectorAll('.btn');
buttons.forEach(button => {
button.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-2px)';
});
button.addEventListener('mouseleave', function() {
if (!this.classList.contains('btn-secondary')) {
this.style.transform = 'translateY(0)';
}
});
});
// Counter animation for hero badge
let rotationAngle = 0;
function rotateBadgeIcon() {
rotationAngle += 1;
const icon = document.querySelector('.hero-badge svg');
if (icon) {
icon.style.transform = `rotate(${rotationAngle}deg)`;
}
requestAnimationFrame(rotateBadgeIcon);
}
rotateBadgeIcon();