'use client'; import React, { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; const PRELOAD_VIDEOS = [ '/assets/videos/web/hero-bohrung.mp4' ]; export function InitialLoader() { const [isLoading, setIsLoading] = useState(true); const [isClient, setIsClient] = useState(false); useEffect(() => { setIsClient(true); // Prüfen, ob wir in dieser Session schon geladen haben const hasLoaded = sessionStorage.getItem('etib_initial_load'); if (hasLoaded) { setIsLoading(false); return; } // Fallback Timeout (4 Sekunden), falls Videos hängen const timeout = setTimeout(() => { finishLoading(); }, 4000); let videosLoaded = 0; const checkAllLoaded = () => { videosLoaded++; if (videosLoaded === PRELOAD_VIDEOS.length) { clearTimeout(timeout); // Kleine Verzögerung für die smootheness setTimeout(finishLoading, 800); } }; PRELOAD_VIDEOS.forEach((src) => { const video = document.createElement('video'); video.preload = 'auto'; video.oncanplaythrough = checkAllLoaded; video.onerror = checkAllLoaded; // bei Fehler trotzdem weitermachen video.src = src; video.load(); }); // Cleanup return () => clearTimeout(timeout); }, []); const finishLoading = () => { sessionStorage.setItem('etib_initial_load', 'true'); setIsLoading(false); }; // Wir rendern serverseitig nichts blockierendes (Hydration Mismatch verhindern) if (!isClient) return null; return ( {isLoading && ( {/* E-TIB Premium Glow */}
{/* Minimalistisches Logo oder Loader */}
E-TIB
Loading Infrastructure
)} ); }