428th-website-2026/terminal.js
2026-07-16 16:21:09 +02:00

48 lines
1.7 KiB
JavaScript

initLangSwitch();
initTheme();
const terminalHero = document.querySelector('.terminal-hero');
const terminalBrand = document.querySelector('.terminal-brand');
const terminalBrandInner = document.getElementById('terminalBrandInner');
function syncTerminalLogoFit(){
const logo = terminalBrandInner?.querySelector('.terminal-logo');
if (!logo || !terminalBrand) return;
document.documentElement.style.setProperty('--hero-terminal-fit', '1');
const brandWidth = terminalBrand.clientWidth;
const logoW = terminalBrandInner.offsetWidth;
const overflow = readCssPx('--hero-terminal-overflow', 1, terminalHero);
const targetWidth = brandWidth * overflow;
const fit = logoW > 0 ? targetWidth / logoW : 1;
document.documentElement.style.setProperty('--hero-terminal-fit', fit.toFixed(4));
}
initHeroScroll({
section: terminalHero,
stage: document.querySelector('.terminal-stage'),
brand: terminalBrand,
brandInner: terminalBrandInner,
mobileAnimClass: 'terminal--mobile-anim',
scrollDrivenClass: 'terminal--scroll-driven',
brandScaleAnimation: 'terminal-brand-scale',
syncFit: syncTerminalLogoFit,
brandGapFromSection: true,
setMobileScaleVar: true,
subtractRunwayOnMobile: true,
clearSectionVars(section){
if (section) section.style.removeProperty('--hero-max-scale-mobile');
},
clampMobileScale(maxScale, brand, brandInner, section){
const brandWidth = brand.clientWidth;
const unscaledWidth = brandInner.offsetWidth;
const overflow = readCssPx('--hero-terminal-overflow', 1, section);
if (brandWidth > 0 && unscaledWidth > 0){
return Math.min(maxScale, (brandWidth * overflow) / unscaledWidth);
}
return maxScale;
}
});
initReveal();
initContactForm();