|
a |
|
b/web/features/features.js |
|
|
1 |
/** |
|
|
2 |
* DNAnalyzer - Features Page JavaScript |
|
|
3 |
* Handles animations, scroll events and interactivity |
|
|
4 |
*/ |
|
|
5 |
|
|
|
6 |
document.addEventListener('DOMContentLoaded', function() { |
|
|
7 |
// Initialize navbar |
|
|
8 |
initializeNavbar(); |
|
|
9 |
|
|
|
10 |
// Initialize animations |
|
|
11 |
initializeAnimations(); |
|
|
12 |
|
|
|
13 |
// Initialize smooth scrolling |
|
|
14 |
initializeSmoothScroll(); |
|
|
15 |
}); |
|
|
16 |
|
|
|
17 |
/** |
|
|
18 |
* Initialize navbar functionality |
|
|
19 |
*/ |
|
|
20 |
function initializeNavbar() { |
|
|
21 |
const navbar = document.getElementById('navbar'); |
|
|
22 |
const mobileToggle = document.getElementById('mobileToggle'); |
|
|
23 |
const navLinks = document.getElementById('navLinks'); |
|
|
24 |
|
|
|
25 |
// Handle scroll event to change navbar style |
|
|
26 |
window.addEventListener('scroll', function() { |
|
|
27 |
if (window.scrollY > 50) { |
|
|
28 |
navbar.classList.add('scrolled'); |
|
|
29 |
} else { |
|
|
30 |
navbar.classList.remove('scrolled'); |
|
|
31 |
} |
|
|
32 |
}); |
|
|
33 |
|
|
|
34 |
// Handle mobile menu toggle |
|
|
35 |
if (mobileToggle && navLinks) { |
|
|
36 |
mobileToggle.addEventListener('click', function() { |
|
|
37 |
navLinks.classList.toggle('active'); |
|
|
38 |
|
|
|
39 |
// Change the icon based on the state |
|
|
40 |
const icon = mobileToggle.querySelector('i'); |
|
|
41 |
if (navLinks.classList.contains('active')) { |
|
|
42 |
icon.classList.remove('fa-bars'); |
|
|
43 |
icon.classList.add('fa-times'); |
|
|
44 |
} else { |
|
|
45 |
icon.classList.remove('fa-times'); |
|
|
46 |
icon.classList.add('fa-bars'); |
|
|
47 |
} |
|
|
48 |
}); |
|
|
49 |
|
|
|
50 |
// Close mobile menu when clicking a link |
|
|
51 |
const links = navLinks.querySelectorAll('a'); |
|
|
52 |
links.forEach(link => { |
|
|
53 |
link.addEventListener('click', function() { |
|
|
54 |
navLinks.classList.remove('active'); |
|
|
55 |
const icon = mobileToggle.querySelector('i'); |
|
|
56 |
icon.classList.remove('fa-times'); |
|
|
57 |
icon.classList.add('fa-bars'); |
|
|
58 |
}); |
|
|
59 |
}); |
|
|
60 |
} |
|
|
61 |
} |
|
|
62 |
|
|
|
63 |
/** |
|
|
64 |
* Initialize animations for elements |
|
|
65 |
*/ |
|
|
66 |
function initializeAnimations() { |
|
|
67 |
// Get all elements with data-aos attribute |
|
|
68 |
const animatedElements = document.querySelectorAll('[data-aos]'); |
|
|
69 |
|
|
|
70 |
// Create Intersection Observer for animations |
|
|
71 |
const observer = new IntersectionObserver((entries) => { |
|
|
72 |
entries.forEach(entry => { |
|
|
73 |
if (entry.isIntersecting) { |
|
|
74 |
entry.target.classList.add('aos-animate'); |
|
|
75 |
observer.unobserve(entry.target); |
|
|
76 |
} |
|
|
77 |
}); |
|
|
78 |
}, { |
|
|
79 |
threshold: 0.1, |
|
|
80 |
rootMargin: '0px 0px -100px 0px' |
|
|
81 |
}); |
|
|
82 |
|
|
|
83 |
// Observe all animated elements |
|
|
84 |
animatedElements.forEach(element => { |
|
|
85 |
observer.observe(element); |
|
|
86 |
}); |
|
|
87 |
|
|
|
88 |
// Add parallax effect to feature images |
|
|
89 |
const featureImages = document.querySelectorAll('.feature-image-wrapper'); |
|
|
90 |
|
|
|
91 |
window.addEventListener('scroll', () => { |
|
|
92 |
featureImages.forEach(image => { |
|
|
93 |
const rect = image.getBoundingClientRect(); |
|
|
94 |
const isVisible = ( |
|
|
95 |
rect.top <= window.innerHeight && |
|
|
96 |
rect.bottom >= 0 |
|
|
97 |
); |
|
|
98 |
|
|
|
99 |
if (isVisible) { |
|
|
100 |
const scrollPos = window.scrollY; |
|
|
101 |
const imgOffset = rect.top + scrollPos; |
|
|
102 |
const parallaxOffset = (scrollPos - imgOffset) * 0.1; |
|
|
103 |
|
|
|
104 |
// Apply parallax effect |
|
|
105 |
image.querySelector('img').style.transform = `translateY(${parallaxOffset}px)`; |
|
|
106 |
} |
|
|
107 |
}); |
|
|
108 |
}); |
|
|
109 |
} |
|
|
110 |
|
|
|
111 |
/** |
|
|
112 |
* Initialize smooth scrolling for anchor links |
|
|
113 |
*/ |
|
|
114 |
function initializeSmoothScroll() { |
|
|
115 |
document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
|
|
116 |
anchor.addEventListener('click', function(e) { |
|
|
117 |
const targetId = this.getAttribute('href'); |
|
|
118 |
|
|
|
119 |
// Skip if it's just "#" or not an ID selector |
|
|
120 |
if (targetId === '#' || !targetId.startsWith('#')) return; |
|
|
121 |
|
|
|
122 |
const targetElement = document.querySelector(targetId); |
|
|
123 |
|
|
|
124 |
if (targetElement) { |
|
|
125 |
e.preventDefault(); |
|
|
126 |
|
|
|
127 |
const navbarHeight = document.querySelector('.navbar').offsetHeight; |
|
|
128 |
const targetPosition = targetElement.getBoundingClientRect().top + window.pageYOffset - navbarHeight - 20; |
|
|
129 |
|
|
|
130 |
window.scrollTo({ |
|
|
131 |
top: targetPosition, |
|
|
132 |
behavior: 'smooth' |
|
|
133 |
}); |
|
|
134 |
} |
|
|
135 |
}); |
|
|
136 |
}); |
|
|
137 |
} |
|
|
138 |
|
|
|
139 |
/** |
|
|
140 |
* Add hover effects for feature cards |
|
|
141 |
*/ |
|
|
142 |
document.querySelectorAll('.feature-card').forEach(card => { |
|
|
143 |
card.addEventListener('mouseenter', function() { |
|
|
144 |
const icon = this.querySelector('.feature-icon'); |
|
|
145 |
if (icon) { |
|
|
146 |
icon.style.transform = 'scale(1.1)'; |
|
|
147 |
} |
|
|
148 |
}); |
|
|
149 |
|
|
|
150 |
card.addEventListener('mouseleave', function() { |
|
|
151 |
const icon = this.querySelector('.feature-icon'); |
|
|
152 |
if (icon) { |
|
|
153 |
icon.style.transform = 'scale(1)'; |
|
|
154 |
} |
|
|
155 |
}); |
|
|
156 |
}); |
|
|
157 |
|
|
|
158 |
/** |
|
|
159 |
* Add hover effects for comparison table rows |
|
|
160 |
*/ |
|
|
161 |
document.querySelectorAll('.comparison-table tr').forEach(row => { |
|
|
162 |
row.addEventListener('mouseenter', function() { |
|
|
163 |
const cells = this.querySelectorAll('td'); |
|
|
164 |
cells.forEach(cell => { |
|
|
165 |
cell.style.transition = 'background-color 0.3s ease'; |
|
|
166 |
}); |
|
|
167 |
}); |
|
|
168 |
}); |
|
|
169 |
|
|
|
170 |
/** |
|
|
171 |
* Add animation for CTA buttons |
|
|
172 |
*/ |
|
|
173 |
document.querySelectorAll('.cta-buttons .btn').forEach(button => { |
|
|
174 |
button.addEventListener('mouseenter', function() { |
|
|
175 |
this.style.transform = 'translateY(-5px)'; |
|
|
176 |
}); |
|
|
177 |
|
|
|
178 |
button.addEventListener('mouseleave', function() { |
|
|
179 |
this.style.transform = 'translateY(0)'; |
|
|
180 |
}); |
|
|
181 |
}); |
|
|
182 |
|
|
|
183 |
// Add scale effect for feature images on hover |
|
|
184 |
document.querySelectorAll('.feature-image').forEach(image => { |
|
|
185 |
image.addEventListener('mouseenter', function() { |
|
|
186 |
const img = this.querySelector('img'); |
|
|
187 |
if (img) { |
|
|
188 |
img.style.transform = 'scale(1.03)'; |
|
|
189 |
} |
|
|
190 |
}); |
|
|
191 |
|
|
|
192 |
image.addEventListener('mouseleave', function() { |
|
|
193 |
const img = this.querySelector('img'); |
|
|
194 |
if (img) { |
|
|
195 |
img.style.transform = 'scale(1)'; |
|
|
196 |
} |
|
|
197 |
}); |
|
|
198 |
}); |