'use client'; import React, { useEffect, useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import Image from 'next/image'; const PRELOAD_VIDEOS = [ '/assets/videos/web/hero-bohrung.mp4' ]; export function InitialLoader({ shouldShowLoader = true }: { shouldShowLoader?: boolean }) { const [isLoading, setIsLoading] = useState(shouldShowLoader); useEffect(() => { if (!shouldShowLoader) 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); }, [shouldShowLoader]); const finishLoading = () => { // Set a session cookie so the server knows not to render the loader again document.cookie = "etib_initial_loader_v5=true; path=/; samesite=lax"; setIsLoading(false); }; // Wenn wir serverseitig rendern und es nicht zeigen sollen, return null if (!shouldShowLoader) return null; return ( {isLoading && ( {/* Subtle grid background */}
{/* Deep Glow */}
{/* Single Masked Logo Container to prevent double-logo offset */}
{/* Base logo color (slightly dimmed to make the sweep visible) */}
{/* Sweeping intense white light */}
{/* Elegant Progress Bar */}
System Online
)} ); }