feat(ui): restore inverted optical liquid glass reflection with cylindrical lens distortion and 120 FPS performance

This commit is contained in:
2026-11-03 15:46:35 +05:30
parent 48f8c456bc
commit e14192d2a8
3 changed files with 68 additions and 50 deletions
+30 -13
View File
@@ -136,25 +136,42 @@
overflow: hidden;
pointer-events: none;
z-index: 1;
opacity: 0.6;
filter: url("#glass-liquid-warp");
/* Physical Optical Inversion & 3D Cylindrical Lens Curvature */
transform: perspective(400px) rotateX(6deg) scaleY(-1.06) scaleX(1.02);
transform-origin: center center;
opacity: 0.58;
mix-blend-mode: luminosity;
transform: translateZ(0);
filter: blur(0.35px) contrast(124%) saturate(220%) brightness(1.06);
contain: strict;
will-change: transform;
}
.liquid-fluid-wave {
.liquid-refraction-mirror {
position: absolute;
top: -120px;
left: -25%;
width: 150%;
height: 600px;
top: 0;
left: 0;
width: 100vw;
pointer-events: none;
will-change: transform;
}
/* Prismatic Liquid Caustic Refraction Overlay */
.liquid-caustic-refraction {
position: absolute;
inset: 0;
pointer-events: none;
background:
radial-gradient(ellipse 65% 35% at 25% 30%, rgba(56, 189, 248, 0.35) 0%, transparent 60%),
radial-gradient(ellipse 70% 45% at 75% 70%, rgba(124, 58, 237, 0.32) 0%, transparent 65%),
radial-gradient(ellipse 85% 55% at 50% 50%, rgba(37, 99, 235, 0.25) 0%, transparent 70%);
will-change: transform;
transform: translateZ(0) scaleY(-1);
linear-gradient(
180deg,
rgba(255, 255, 255, 0.22) 0%,
transparent 25%,
transparent 75%,
rgba(255, 255, 255, 0.14) 100%
),
radial-gradient(ellipse 65% 50% at 25% 35%, rgba(56, 189, 248, 0.16) 0%, transparent 60%),
radial-gradient(ellipse 70% 50% at 75% 65%, rgba(168, 85, 247, 0.14) 0%, transparent 60%);
mix-blend-mode: overlay;
z-index: 2;
}
/* Liquid Glass Mobile Dropdown */
+35 -35
View File
@@ -28,42 +28,64 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
return () => window.removeEventListener('scroll', handleScroll);
}, []);
// Ultra-Fast Hardware-Accelerated Optical Liquid Refraction Wave (120 FPS on Mobile & Desktop)
// Optical Inverted Liquid Glass Refraction Pipeline (120 FPS on all devices)
useEffect(() => {
let rafId: number;
const updateWave = () => {
if (!mirrorRef.current) return;
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;
// Invert on Y (scaleY(-1)) and translate in opposite optical direction on scroll
const offset = (scrollY * 0.45) % 400;
mirrorRef.current.style.transform = `translate3d(0, -${offset}px, 0) scaleY(-1)`;
mirrorRef.current.style.left = `-${navRect.left}px`;
mirrorRef.current.style.transform = `translate3d(0, -${scrollY + navRect.top}px, 0)`;
};
// Populate inverted reflection mirror with a lightweight visual clone of <main>
const setupMirror = () => {
const mainEl = document.querySelector('main');
if (mainEl && mirrorRef.current) {
mirrorRef.current.innerHTML = '';
const clone = mainEl.cloneNode(true) as HTMLElement;
// Strip heavy non-visual, interactive, and duplicated elements
clone.querySelectorAll('[id]').forEach((el) => el.removeAttribute('id'));
clone.querySelectorAll('canvas, script, noscript, iframe, video, audio').forEach((el) => el.remove());
clone.querySelectorAll('a, button, input, select, textarea').forEach((el) => {
el.setAttribute('tabindex', '-1');
(el as HTMLElement).style.pointerEvents = 'none';
});
mirrorRef.current.appendChild(clone);
updateMirror();
}
};
// Allow DOM to settle on mount or route transition
const timer = setTimeout(setupMirror, 60);
const onScroll = () => {
cancelAnimationFrame(rafId);
rafId = requestAnimationFrame(updateWave);
rafId = requestAnimationFrame(updateMirror);
};
const lenis = (window as any).lenis;
if (lenis && typeof lenis.on === 'function') {
lenis.on('scroll', updateWave);
lenis.on('scroll', updateMirror);
}
window.addEventListener('scroll', onScroll, { passive: true });
window.addEventListener('resize', onScroll, { passive: true });
updateWave();
return () => {
clearTimeout(timer);
if (lenis && typeof lenis.off === 'function') {
lenis.off('scroll', updateWave);
lenis.off('scroll', updateMirror);
}
window.removeEventListener('scroll', onScroll);
window.removeEventListener('resize', onScroll);
cancelAnimationFrame(rafId);
};
}, []);
}, [pathname]);
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
const rect = e.currentTarget.getBoundingClientRect();
@@ -78,29 +100,6 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
return (
<header className="fixed top-3 sm:top-5 left-0 right-0 z-50 px-3 sm:px-6 lg:px-8 pointer-events-none transition-all duration-300">
{/* SVG Optical Liquid Glass Refraction & Distortion Filter (Single Octave Ultra-Fast GPU Shader) */}
<svg className="absolute w-0 h-0 pointer-events-none overflow-hidden" aria-hidden="true" focusable="false">
<defs>
<filter id="glass-liquid-warp" x="-20%" y="-20%" width="140%" height="140%" colorInterpolationFilters="sRGB">
{/* Smooth fluid waves with single octave for 120 FPS mobile GPU efficiency */}
<feTurbulence type="fractalNoise" baseFrequency="0.012 0.045" numOctaves="1" result="fluidWarp" />
{/* Complete liquid displacement - completely liquefies without a hint of legible shapes */}
<feDisplacementMap in="SourceGraphic" in2="fluidWarp" scale="36" xChannelSelector="R" yChannelSelector="G" result="displaced" />
{/* Prismatic chromatic dispersion */}
<feColorMatrix
type="matrix"
in="displaced"
result="chroma"
values="1.08 0 0 0 0
0 1.0 0 0 0
0 0 1.22 0 0
0 0 0 1 0"
/>
<feColorMatrix type="saturate" values="2.4" in="chroma" result="finalDistorted" />
</filter>
</defs>
</svg>
<div
ref={navRef}
onMouseMove={handleMouseMove}
@@ -111,7 +110,8 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
>
{/* Optical Inverted Liquid Glass Refraction Chamber */}
<div className="liquid-refraction-chamber" aria-hidden="true">
<div ref={mirrorRef} className="liquid-fluid-wave" />
<div ref={mirrorRef} className="liquid-refraction-mirror" />
<div className="liquid-caustic-refraction" />
</div>
{/* Dynamic Specular Caustic Glint - Crystal clear at rest, subtle gloss on cursor interaction */}
+3 -2
View File
@@ -9,13 +9,14 @@ export function SmoothScroll() {
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
const lenis = new Lenis({
duration: 1.2,
duration: 1.15,
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
orientation: 'vertical',
gestureOrientation: 'vertical',
smoothWheel: true,
syncTouch: false, // Preserves hardware 120Hz momentum touch scrolling on phones & tablets
wheelMultiplier: 0.95,
touchMultiplier: 1.5,
touchMultiplier: 1.0,
});
let rafId: number;