-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
66 lines (51 loc) · 2 KB
/
script.js
File metadata and controls
66 lines (51 loc) · 2 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
/*
FINTECH LANDING PAGE SCRIPTS
Handles: Scroll Reveal Animations & Mobile Menu Toggle
*/
document.addEventListener('DOMContentLoaded', () => {
// --- 1. Scroll Reveal Animation Logic ---
const revealElements = document.querySelectorAll('.reveal-on-scroll');
const revealOnScroll = () => {
const windowHeight = window.innerHeight;
const elementVisible = 100; // Pixels before bottom of screen to trigger
revealElements.forEach((element) => {
const elementTop = element.getBoundingClientRect().top;
if (elementTop < windowHeight - elementVisible) {
element.classList.add('visible');
}
});
};
// Trigger once on load in case elements are already in view
revealOnScroll();
// Listen for scroll events
window.addEventListener('scroll', revealOnScroll);
// --- 2. Mobile Navigation Toggle ---
const menuBtn = document.getElementById('mobileMenuBtn');
const navLinks = document.getElementById('navLinks');
menuBtn.addEventListener('click', () => {
navLinks.classList.toggle('active');
// Optional: Change icon from hamburger to X
if (navLinks.classList.contains('active')) {
menuBtn.textContent = '✕';
} else {
menuBtn.textContent = '☰';
}
});
// Close mobile menu when a link is clicked
document.querySelectorAll('.nav-links a').forEach(link => {
link.addEventListener('click', () => {
navLinks.classList.remove('active');
menuBtn.textContent = '☰';
});
});
// --- 3. Navbar Background on Scroll ---
// Add a subtle background when scrolling down
const navbar = document.querySelector('.navbar');
window.addEventListener('scroll', () => {
if (window.scrollY > 50) {
navbar.style.boxShadow = '0 4px 20px rgba(0,0,0,0.3)';
} else {
navbar.style.boxShadow = 'none';
}
});
});