diff --git a/src/app/globals.css b/src/app/globals.css index b14999b..dc1934e 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -128,7 +128,7 @@ z-index: 3; } -/* Inverted Optical Liquid Glass Refraction Chamber with Pure Vertical Distortion */ +/* Inverted Optical Liquid Glass Refraction Chamber with Dynamic Fluid Wobble */ .liquid-refraction-chamber { position: absolute; inset: 0; @@ -136,12 +136,12 @@ overflow: hidden; pointer-events: none; z-index: 1; - /* Physical Optical Inversion & 3D Cylindrical Vertical Curvature */ - transform: perspective(360px) rotateX(8deg) scaleY(-1.12) scaleX(1.02); + /* Exact 1:1 speed matching inversion with 3D perspective */ + transform: perspective(380px) rotateX(6deg) scaleY(-1); transform-origin: center center; - opacity: 0.75; - mix-blend-mode: luminosity; - filter: url("#liquid-glass-vertical-refraction") blur(0.2px) contrast(124%) saturate(220%) brightness(1.05); + opacity: 0.78; + mix-blend-mode: normal; + filter: url("#liquid-glass-vertical-refraction") blur(0.2px) contrast(124%) saturate(210%) brightness(1.05); contain: strict; will-change: transform; } diff --git a/src/components/ui/Navbar.tsx b/src/components/ui/Navbar.tsx index fc8f3c5..f65c0fd 100644 --- a/src/components/ui/Navbar.tsx +++ b/src/components/ui/Navbar.tsx @@ -19,7 +19,9 @@ export function Navbar({ config, currentLocale }: NavbarProps) { const pathname = usePathname(); const navRef = useRef(null); const mirrorRef = useRef(null); + const chamberRef = useRef(null); const waveOffsetRef = useRef(null); + const dispMapRef = useRef(null); useEffect(() => { const handleScroll = () => { @@ -29,23 +31,69 @@ export function Navbar({ config, currentLocale }: NavbarProps) { return () => window.removeEventListener('scroll', handleScroll); }, []); - // Optical Inverted Liquid Glass Refraction Pipeline (120 FPS on all devices) + // Optical Inverted Liquid Glass Refraction Pipeline (Synchronized 120 FPS on all devices) useEffect(() => { let rafId: number; + let lastY = 0; + let lastTime = performance.now(); + let velocity = 0; + let wobblePhase = 0; + let navTop = 20; + let navLeft = 0; + + // Cache navbar rect outside of scroll handler to avoid synchronous layout reflows on mobile + const measureNav = () => { + if (navRef.current) { + const rect = navRef.current.getBoundingClientRect(); + navTop = rect.top; + navLeft = rect.left; + } + }; + measureNav(); const updateMirror = () => { - if (!mirrorRef.current || !navRef.current) return; - const navRect = navRef.current.getBoundingClientRect(); - const lenis = (window as any).lenis; - const scrollY = lenis && typeof lenis.scroll === 'number' ? lenis.scroll : window.scrollY; + if (!mirrorRef.current) return; + // Direct hardware scroll position: 100% synchronized with native touch & desktop scroll + const scrollY = window.scrollY || window.pageYOffset || document.documentElement.scrollTop; + const now = performance.now(); + const dt = Math.max(now - lastTime, 16); + const dist = Math.abs(scrollY - lastY); + const instantVelocity = (dist / dt) * 1000; + lastY = scrollY; + lastTime = now; - mirrorRef.current.style.left = `-${navRect.left}px`; - mirrorRef.current.style.transform = `translate3d(0, -${scrollY + navRect.top}px, 0)`; + // Smooth velocity interpolation + velocity += (instantVelocity - velocity) * 0.35; - // Dynamically ripple and displace the vertical liquid wave as text moves through the navbar + // Exact 1:1 speed matching parity with hardware GPU translate3d + mirrorRef.current.style.left = `-${navLeft}px`; + mirrorRef.current.style.transform = `translate3d(0, -${scrollY + navTop}px, 0)`; + + // Dynamic liquid wobble: 14 at rest, ramps up to 44 when scrolling (completely wobbles) + const currentWobble = Math.min(14 + velocity * 0.038, 44); + if (dispMapRef.current) { + dispMapRef.current.setAttribute('scale', currentWobble.toFixed(1)); + } + + // Wobbly phase oscillation + wobblePhase = (wobblePhase + dist * 0.4 + (velocity > 12 ? 2.2 : 0.4)) % 360; if (waveOffsetRef.current) { - const offset = (scrollY * 0.45) % 200; - waveOffsetRef.current.setAttribute('dy', offset.toString()); + const dy = Math.sin(wobblePhase * 0.05) * 26 + ((scrollY * 0.35) % 150); + const dx = Math.cos(wobblePhase * 0.04) * (currentWobble * 0.35); + waveOffsetRef.current.setAttribute('dy', dy.toFixed(1)); + waveOffsetRef.current.setAttribute('dx', dx.toFixed(1)); + } + + // 3D liquid fluid slosh & wobble on the chamber itself + if (chamberRef.current) { + const wobbleSkew = Math.sin(wobblePhase * 0.06) * Math.min(velocity * 0.007, 3.6); + chamberRef.current.style.transform = `perspective(380px) rotateX(6deg) scaleY(-1) skewX(${wobbleSkew.toFixed(2)}deg)`; + } + + // Smooth deceleration loop + if (velocity > 1.2) { + cancelAnimationFrame(rafId); + rafId = requestAnimationFrame(updateMirror); } }; @@ -63,6 +111,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) { (el as HTMLElement).style.pointerEvents = 'none'; }); mirrorRef.current.appendChild(clone); + measureNav(); updateMirror(); } }; @@ -77,18 +126,23 @@ export function Navbar({ config, currentLocale }: NavbarProps) { const lenis = (window as any).lenis; if (lenis && typeof lenis.on === 'function') { - lenis.on('scroll', updateMirror); + lenis.on('scroll', onScroll); } window.addEventListener('scroll', onScroll, { passive: true }); - window.addEventListener('resize', onScroll, { passive: true }); + window.addEventListener('touchmove', onScroll, { passive: true }); + window.addEventListener('resize', () => { + measureNav(); + onScroll(); + }, { passive: true }); return () => { clearTimeout(timer); if (lenis && typeof lenis.off === 'function') { - lenis.off('scroll', updateMirror); + lenis.off('scroll', onScroll); } window.removeEventListener('scroll', onScroll); + window.removeEventListener('touchmove', onScroll); window.removeEventListener('resize', onScroll); cancelAnimationFrame(rafId); }; @@ -107,16 +161,16 @@ export function Navbar({ config, currentLocale }: NavbarProps) { return (
- {/* 1D Pure Vertical Optical Liquid Glass Refraction Filter (Single Dimension Y-axis for 120 FPS Speed) */} + {/* Dynamic Liquid Glass Optical Wobble & Refraction Filter (120 FPS on all devices) */} @@ -130,7 +184,7 @@ export function Navbar({ config, currentLocale }: NavbarProps) { }`} > {/* Optical Inverted Liquid Glass Refraction Chamber */} -