function CarAnimation() { const sectionRef = React.useRef(null); const [p, setP] = React.useState(0); const [, force] = React.useState(0); React.useEffect(() => { const onLang = () => force(n => n + 1); window.addEventListener('langchange', onLang); let ticking = false; const onScroll = () => { if (ticking) return; ticking = true; requestAnimationFrame(() => { const el = sectionRef.current; if (el) { const rect = el.getBoundingClientRect(); const total = rect.height - window.innerHeight; const prog = total > 0 ? Math.min(1, Math.max(0, -rect.top / total)) : 0; setP(prog); } ticking = false; }); }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); return () => { window.removeEventListener('scroll', onScroll); window.removeEventListener('langchange', onLang); }; }, []); React.useEffect(() => { const s = document.createElement('style'); s.id = 'car-anim-kf-v6'; s.textContent = ` @keyframes wheelSpinV6 { to { transform: rotate(360deg); } } @keyframes dashFlowV6 { to { background-position: -80px 0; } } @keyframes hintBobV6 { 0%,100% { transform: translateY(0); } 50% { transform: translateY(6px); } } `; document.head.appendChild(s); return () => { const el = document.getElementById('car-anim-kf-v6'); if (el) el.remove(); }; }, []); const t = window.t; const km = Math.round(p * 500); const moving = p > 0.001 && p < 0.999; const stat = (threshold) => Math.min(1, Math.max(0, (p - threshold) / 0.12)); const stats = [ { v: `${km}`, sub: 'km / 500', appear: 0.0, accent: 'text-[#171717]' }, { v: '4h 50m', sub: t('car.time'), appear: 0.35, accent: 'text-[#171717]' }, { v: '€18.50', sub: t('car.seat'), accent: 'text-[#0096F7]', appear: 0.7 }, ]; return (
{/* Header */}
{t('car.from')} — {t('car.to')}

{t('car.from')} {t('car.to')}

{/* Road Stage */}
{/* Pins */}
{t('car.from')}
{t('car.to')}
{/* Moving Car */}
{[44, 112].map((cx) => ( ))}
{/* Live Stats */}
{stats.map((s, i) => { const a = stat(s.appear); return (
{s.v}
{s.sub}
); })}
); } window.CarAnimation = CarAnimation;