[42555b]: / web / about / about.js

Download this file

172 lines (144 with data), 5.9 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
166
167
168
169
170
171
172
/*
* DNAnalyzer About Page JavaScript
* Copyright © 2025 Piyush Acharya
*/
document.addEventListener('DOMContentLoaded', function() {
// Mobile navigation toggle
const mobileToggle = document.getElementById('mobileToggle');
const navLinks = document.getElementById('navLinks');
if (mobileToggle && navLinks) {
mobileToggle.addEventListener('click', function() {
navLinks.classList.toggle('active');
mobileToggle.querySelector('i').classList.toggle('fa-bars');
mobileToggle.querySelector('i').classList.toggle('fa-times');
});
}
// Navbar scroll behavior
const navbar = document.getElementById('navbar');
window.addEventListener('scroll', function() {
if (window.scrollY > 100) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
// Timeline animation - Adding view animation
const timelineItems = document.querySelectorAll('.timeline-item');
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const timelineObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = entry.target.classList.contains('timeline-item:nth-child(odd)')
? 'translateX(0)'
: 'translateX(0)';
observer.unobserve(entry.target);
}
});
}, observerOptions);
timelineItems.forEach(item => {
item.style.opacity = '0';
item.style.transform = item.classList.contains('timeline-item:nth-child(odd)')
? 'translateX(-20px)'
: 'translateX(20px)';
item.style.transition = 'all 0.7s ease-out';
timelineObserver.observe(item);
});
// Handle Vision Hexagon Hover/Click Interaction
const hexagons = document.querySelectorAll('.hexagon');
const visionDetails = document.querySelectorAll('.vision-detail');
// Set first vision detail as active by default
if (visionDetails.length > 0) {
visionDetails[0].classList.add('active');
}
hexagons.forEach((hexagon, index) => {
hexagon.addEventListener('mouseenter', () => {
// Remove active class from all vision details
visionDetails.forEach(detail => {
detail.classList.remove('active');
});
// Add active class to corresponding vision detail
if (visionDetails[index]) {
visionDetails[index].classList.add('active');
}
});
hexagon.addEventListener('click', () => {
// Remove active class from all vision details
visionDetails.forEach(detail => {
detail.classList.remove('active');
});
// Add active class to corresponding vision detail
if (visionDetails[index]) {
visionDetails[index].classList.add('active');
// If on mobile, scroll to the detail
if (window.innerWidth < 992) {
visionDetails[index].scrollIntoView({
behavior: 'smooth',
block: 'center'
});
}
}
});
});
// Add some interactivity to stats
animateStats();
});
/**
* Animates the stat numbers with a counting effect
*/
function animateStats() {
const statNumbers = document.querySelectorAll('.stat-number[data-count]');
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const statsObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const targetNumber = parseInt(entry.target.getAttribute('data-count'), 10);
const duration = 2000; // Animation duration in milliseconds
const startTime = performance.now();
function updateCounter(currentTime) {
const elapsedTime = currentTime - startTime;
const progress = Math.min(elapsedTime / duration, 1);
const easeProgress = easeOutQuad(progress);
const currentCount = Math.floor(easeProgress * targetNumber);
entry.target.textContent = currentCount;
if (progress < 1) {
requestAnimationFrame(updateCounter);
} else {
entry.target.textContent = targetNumber;
}
}
requestAnimationFrame(updateCounter);
observer.unobserve(entry.target);
}
});
}, observerOptions);
statNumbers.forEach(statNumber => {
statsObserver.observe(statNumber);
});
}
/**
* Easing function for smoother animation
* @param {number} t - Progress value between 0 and 1
* @return {number} Eased value
*/
function easeOutQuad(t) {
return t * (2 - t);
}
// Add a subtle parallax effect to the background blobs
window.addEventListener('mousemove', function(e) {
const blobs = document.querySelectorAll('.bg-blob');
blobs.forEach(blob => {
const speed = blob.classList.contains('bg-blob-1') ? 0.03 : 0.02;
const x = (window.innerWidth / 2 - e.clientX) * speed;
const y = (window.innerHeight / 2 - e.clientY) * speed;
blob.style.transform = `translate(${x}px, ${y}px)`;
});
});