From e3aa629c7f8f8827dd540d5582e50b67dc53de07 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 14 Nov 2025 20:45:04 -0500 Subject: progress --- js/parallax-header.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 js/parallax-header.js (limited to 'js/parallax-header.js') diff --git a/js/parallax-header.js b/js/parallax-header.js new file mode 100644 index 0000000..c4ce1fc --- /dev/null +++ b/js/parallax-header.js @@ -0,0 +1,20 @@ +const targetMin = -10; +const targetMax = 25; +let currentPercent = targetMin; +let targetPercent = targetMin; +const tweenSpeed = 0.040; + +document.addEventListener("scroll", () => { + const scrollTop = window.scrollY; + const docHeight = document.documentElement.scrollHeight - window.innerHeight; + let scrollFraction = scrollTop / docHeight; + targetPercent = targetMin + (targetMax - targetMin) * scrollFraction; +}); + +function animate() { + currentPercent += (targetPercent - currentPercent) * tweenSpeed; + document.documentElement.style.setProperty('--scroll-percent', currentPercent + '%'); + requestAnimationFrame(animate); +} + +animate(); -- cgit v1.2.3