-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
165 lines (138 loc) · 5.2 KB
/
script.js
File metadata and controls
165 lines (138 loc) · 5.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
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
163
164
165
// Fade in on scroll effect
const fadeElements = document.querySelectorAll('.stats, .features, .brand-showcase, .dashboard, .stat-card, .feature-card, .brand-card, .loan-card');
const fadeInObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
}
});
}, {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
});
fadeElements.forEach(element => {
element.classList.add('fade-in-up');
fadeInObserver.observe(element);
});
// Smooth scrolling for navigation 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 on scroll
window.addEventListener('scroll', () => {
const scrolled = window.pageYOffset;
const parallax = document.querySelector('.bg-animation');
parallax.style.transform = `translateY(${scrolled * 0.5}px)`;
});
// Animate stats on scroll
const observerOptions = {
threshold: 0.5,
rootMargin: '0px 0px -100px 0px'
};
// Mobile Menu Toggle
const mobileNavToggle = document.getElementById('mobileNavToggle');
const mobileMenu = document.getElementById('mobileMenu');
const mobileClose = document.getElementById('mobileClose');
const mobileMenuLinks = document.querySelectorAll('.mobile-menu-links a');
// Toggle mobile menu
mobileNavToggle.addEventListener('click', () => {
mobileNavToggle.classList.toggle('active');
mobileMenu.classList.toggle('active');
document.body.classList.toggle('menu-open');
});
// Close mobile menu
mobileClose.addEventListener('click', () => {
mobileNavToggle.classList.remove('active');
mobileMenu.classList.remove('active');
document.body.classList.remove('menu-open');
});
// Close menu when clicking a link
mobileMenuLinks.forEach(link => {
link.addEventListener('click', () => {
mobileNavToggle.classList.remove('active');
mobileMenu.classList.remove('active');
document.body.classList.remove('menu-open');
});
});
// Mobile connect wallet
document.querySelector('.mobile-connect-wallet').addEventListener('click', () => {
alert('Wallet connection would be implemented here');
mobileNavToggle.classList.remove('active');
mobileMenu.classList.remove('active');
document.body.classList.remove('menu-open');
});
// Highlight words pulse animation for all devices
function startHighlightAnimation() {
const highlights = document.querySelectorAll('.highlight-word');
let currentIndex = 0;
// Run on all devices
setInterval(() => {
// Remove active class from all
highlights.forEach(highlight => highlight.classList.remove('active'));
// Add active class to current
highlights[currentIndex].classList.add('active');
// Move to next, loop back to start
currentIndex = (currentIndex + 1) % highlights.length;
}, 1000); // 3 seconds interval
}
// Start the animation when page loads
document.addEventListener('DOMContentLoaded', startHighlightAnimation);
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.animation = 'fadeInUp 0.6s ease forwards';
}
});
}, observerOptions);
// Observe all cards
document.querySelectorAll('.stat-card, .feature-card, .loan-card').forEach(card => {
observer.observe(card);
});
// Add fade in animation
const style = document.createElement('style');
style.textContent = `
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(30px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
`;
document.head.appendChild(style);
// Connect wallet functionality
document.querySelector('.connect-wallet').addEventListener('click', () => {
alert('Wallet connection would be implemented here');
});
// CTA button interactions
document.querySelector('.cta-primary').addEventListener('click', () => {
document.querySelector('.dashboard').scrollIntoView({ behavior: 'smooth' });
});
document.querySelector('.cta-secondary').addEventListener('click', () => {
alert('Loan request form would open here');
});
// Day/Night Theme Toggle - Added Only
const themeToggle = document.getElementById('themeToggle');
const savedTheme = localStorage.getItem('p3-theme-mode') || 'dark';
if (savedTheme === 'light') {
document.body.classList.add('light-theme');
themeToggle.classList.add('light');
}
themeToggle.addEventListener('click', () => {
document.body.classList.toggle('light-theme');
themeToggle.classList.toggle('light');
const currentTheme = document.body.classList.contains('light-theme') ? 'light' : 'dark';
localStorage.setItem('p3-theme-mode', currentTheme);
});