feat(ui): disable card tilting on mobile/tablet and add 1D vertical optical liquid glass distortion
This commit is contained in:
+13
-12
@@ -128,7 +128,7 @@
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
/* Inverted Optical Liquid Glass Refraction Chamber */
|
||||
/* Inverted Optical Liquid Glass Refraction Chamber with Pure Vertical Distortion */
|
||||
.liquid-refraction-chamber {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
@@ -136,12 +136,12 @@
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
/* Physical Optical Inversion & 3D Cylindrical Lens Curvature */
|
||||
transform: perspective(400px) rotateX(6deg) scaleY(-1.06) scaleX(1.02);
|
||||
/* Physical Optical Inversion & 3D Cylindrical Vertical Curvature */
|
||||
transform: perspective(380px) rotateX(7deg) scaleY(-1.08) scaleX(1.015);
|
||||
transform-origin: center center;
|
||||
opacity: 0.58;
|
||||
opacity: 0.6;
|
||||
mix-blend-mode: luminosity;
|
||||
filter: blur(0.35px) contrast(124%) saturate(220%) brightness(1.06);
|
||||
filter: url("#liquid-glass-vertical-refraction") blur(0.25px) contrast(122%) saturate(215%) brightness(1.05);
|
||||
contain: strict;
|
||||
will-change: transform;
|
||||
}
|
||||
@@ -155,7 +155,7 @@
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
/* Prismatic Liquid Caustic Refraction Overlay */
|
||||
/* Prismatic Liquid Caustic Refraction Overlay - Vertical Cylindrical Lens Bands */
|
||||
.liquid-caustic-refraction {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
@@ -163,13 +163,14 @@
|
||||
background:
|
||||
linear-gradient(
|
||||
180deg,
|
||||
rgba(255, 255, 255, 0.22) 0%,
|
||||
transparent 25%,
|
||||
transparent 75%,
|
||||
rgba(255, 255, 255, 0.14) 100%
|
||||
rgba(255, 255, 255, 0.24) 0%,
|
||||
transparent 22%,
|
||||
rgba(255, 255, 255, 0.03) 50%,
|
||||
transparent 78%,
|
||||
rgba(255, 255, 255, 0.15) 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%);
|
||||
radial-gradient(ellipse 70% 45% at 30% 35%, rgba(56, 189, 248, 0.15) 0%, transparent 60%),
|
||||
radial-gradient(ellipse 70% 45% at 70% 65%, rgba(168, 85, 247, 0.13) 0%, transparent 60%);
|
||||
mix-blend-mode: overlay;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,18 @@ 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">
|
||||
{/* 1D Pure Vertical Optical Liquid Glass Refraction Filter (Single Dimension Y-axis for 120 FPS Speed) */}
|
||||
<svg className="absolute w-0 h-0 pointer-events-none overflow-hidden" aria-hidden="true" focusable="false">
|
||||
<defs>
|
||||
<filter id="liquid-glass-vertical-refraction" x="0%" y="-10%" width="100%" height="120%" colorInterpolationFilters="sRGB">
|
||||
{/* Pure vertical fluid turbulence: X frequency = 0, Y frequency = 0.032 */}
|
||||
<feTurbulence type="turbulence" baseFrequency="0 0.032" numOctaves="1" result="vertWave" />
|
||||
{/* Subtle vertical optical refraction displacement along Y-axis */}
|
||||
<feDisplacementMap in="SourceGraphic" in2="vertWave" scale="7" xChannelSelector="R" yChannelSelector="R" result="displaced" />
|
||||
</filter>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
<div
|
||||
ref={navRef}
|
||||
onMouseMove={handleMouseMove}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import React, { useRef, useState, useCallback, MouseEvent } from 'react';
|
||||
import React, { useRef, useState, useCallback, useEffect, MouseEvent } from 'react';
|
||||
|
||||
interface TiltCardProps {
|
||||
children: React.ReactNode;
|
||||
@@ -24,9 +24,25 @@ export function TiltCard({
|
||||
background: '',
|
||||
});
|
||||
const [isHovered, setIsHovered] = useState<boolean>(false);
|
||||
const [isTouchOrMobile, setIsTouchOrMobile] = useState<boolean>(true); // Default to true (safe for mobile/SSR)
|
||||
|
||||
useEffect(() => {
|
||||
// Only enable 3D card tilt & glare on desktop screens with a precision mouse (>= 1024px)
|
||||
const checkDevice = () => {
|
||||
const isFinePointer = window.matchMedia('(hover: hover) and (pointer: fine)').matches;
|
||||
const isSmallScreen = window.innerWidth < 1024;
|
||||
const hasTouch = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
|
||||
setIsTouchOrMobile(!isFinePointer || isSmallScreen || hasTouch);
|
||||
};
|
||||
|
||||
checkDevice();
|
||||
window.addEventListener('resize', checkDevice, { passive: true });
|
||||
return () => window.removeEventListener('resize', checkDevice);
|
||||
}, []);
|
||||
|
||||
const handleMouseMove = useCallback(
|
||||
(e: MouseEvent<HTMLDivElement>) => {
|
||||
if (isTouchOrMobile) return;
|
||||
const card = cardRef.current;
|
||||
if (!card) return;
|
||||
|
||||
@@ -59,18 +75,25 @@ export function TiltCard({
|
||||
});
|
||||
}
|
||||
},
|
||||
[maxTilt, scale, showGlare]
|
||||
[maxTilt, scale, showGlare, isTouchOrMobile]
|
||||
);
|
||||
|
||||
const handleMouseEnter = useCallback(() => {
|
||||
if (isTouchOrMobile) return;
|
||||
setIsHovered(true);
|
||||
}, []);
|
||||
}, [isTouchOrMobile]);
|
||||
|
||||
const handleMouseLeave = useCallback(() => {
|
||||
if (isTouchOrMobile) return;
|
||||
setIsHovered(false);
|
||||
setTransformStyle('perspective(1000px) rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)');
|
||||
setGlareStyle((prev) => ({ ...prev, opacity: 0 }));
|
||||
}, []);
|
||||
}, [isTouchOrMobile]);
|
||||
|
||||
// On phone and tablet: zero tilt, zero glare, zero compositing overhead for ultra-smooth 120 FPS
|
||||
if (isTouchOrMobile) {
|
||||
return <div className={`relative ${className}`}>{children}</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user