cool stuff

This commit is contained in:
Stephen Tafoya
2026-06-11 02:20:25 -06:00
parent 7e9bc97a27
commit aa37ed3d6f
3 changed files with 171 additions and 28 deletions

View File

@@ -1004,7 +1004,11 @@
var viewport = track.parentElement;
var paused = false;
var scrollPos = 0;
var speed = 0.35;
var speed = 0.55;
while (track.scrollHeight < viewport.clientHeight * 1.5) {
track.appendChild(createElement(generateQuote()));
}
function step() {
try {
@@ -1018,6 +1022,7 @@
var distance = second.offsetTop - first.offsetTop;
if (distance > 0 && scrollPos >= distance) {
scrollPos -= distance;
track.style.transform = 'translateY(' + (-scrollPos) + 'px)';
track.removeChild(first);
track.appendChild(createElement(generateQuote()));
}
@@ -1027,8 +1032,67 @@
requestAnimationFrame(step);
}
viewport.addEventListener('mouseenter', function () { paused = true; });
viewport.addEventListener('mouseleave', function () { paused = false; });
step();
// Scroll reveal
var reveals = document.querySelectorAll('.reveal');
var revealObserver = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add('revealed');
}
});
}, { threshold: 0.1 });
reveals.forEach(function(el) { revealObserver.observe(el); });
// Stat counter
var statsSection = document.querySelector('.stats');
if (statsSection) {
var counted = false;
var statObserver = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting && !counted) {
counted = true;
var numbers = document.querySelectorAll('.stat .number[data-target]');
numbers.forEach(function(el) {
var target = parseInt(el.getAttribute('data-target'));
var suffix = el.getAttribute('data-suffix') || '';
var current = 0;
if (target <= 0) return;
var duration = parseInt(el.getAttribute('data-duration')) || 1000;
var final = el.getAttribute('data-final');
var ticks = Math.min(target, Math.floor(duration / 10));
var step = Math.max(1, Math.floor(target / ticks));
var intervalMs = Math.max(10, Math.floor(duration / ticks));
var timer = setInterval(function() {
current += step;
if (current >= target) {
current = target;
clearInterval(timer);
if (final) {
el.textContent = final;
return;
}
}
el.textContent = current + suffix;
}, intervalMs);
});
}
});
}, { threshold: 0.5 });
statObserver.observe(statsSection);
}
// Sparkle particles
for (var i = 0; i < 25; i++) {
var dot = document.createElement('div');
dot.className = 'particle';
dot.style.left = Math.random() * 100 + '%';
dot.style.top = Math.random() * 100 + '%';
dot.style.animationDelay = Math.random() * 5 + 's';
dot.style.animationDuration = (3 + Math.random() * 4) + 's';
dot.style.width = (2 + Math.random() * 3) + 'px';
dot.style.height = dot.style.width;
document.body.appendChild(dot);
}
})();