37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
/* ───────── js/home.js ───────── */
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// Hero parallax & gradient effect
|
|
const hero = document.getElementById('hero');
|
|
const about = document.getElementById('about');
|
|
const video = hero?.querySelector('video');
|
|
|
|
if (hero && about && video) {
|
|
const update = () => {
|
|
const scrollY = window.scrollY;
|
|
const viewportHeight = window.innerHeight;
|
|
const aboutTop = about.getBoundingClientRect().top;
|
|
|
|
const gradientOpacity = Math.max(0, Math.min(1, (viewportHeight - aboutTop) / (viewportHeight * 0.0125)));
|
|
hero.style.setProperty('--gradient-opacity', gradientOpacity.toString());
|
|
|
|
const aboutPadding = 15 - scrollY * 0.03;
|
|
about.style.marginTop = `${aboutPadding}rem`;
|
|
|
|
const videoOffset = Math.max(0, scrollY - viewportHeight / 2);
|
|
video.style.transform = `translateY(${videoOffset}px)`;
|
|
};
|
|
|
|
update();
|
|
window.addEventListener('scroll', update, { passive: true });
|
|
window.addEventListener('resize', update, { passive: true });
|
|
}
|
|
|
|
// Pipeline blurb injection (optional, safe-fail)
|
|
const pipeTarget = document.getElementById('pipeline-content');
|
|
if (pipeTarget) {
|
|
fetch('written/pipeline.txt')
|
|
.then(r => r.text())
|
|
.then(txt => { pipeTarget.innerHTML = `<p>${txt}</p>`; })
|
|
.catch(console.error);
|
|
}
|
|
});
|