feat(ui): complete vertical layout overhaul, dynamic JSON banners, and animate-ui text motion graphics
This commit is contained in:
@@ -21,7 +21,7 @@ export function BeforeAfterSlider({
|
||||
afterLabel,
|
||||
caption,
|
||||
aspectRatio = 'aspect-[4/3] sm:aspect-[16/10]',
|
||||
autoSlide = true,
|
||||
autoSlide = false,
|
||||
className = '',
|
||||
}: BeforeAfterSliderProps) {
|
||||
return (
|
||||
|
||||
@@ -22,42 +22,36 @@ export function Cinematic3DComparison({
|
||||
afterLabel = 'AI RECONSTRUCTED',
|
||||
caption,
|
||||
aspectRatio = 'aspect-[4/3] sm:aspect-[16/10]',
|
||||
autoSlide = true,
|
||||
maxTilt = 7,
|
||||
autoSlide = false,
|
||||
maxTilt = 6,
|
||||
className = '',
|
||||
}: Cinematic3DComparisonProps) {
|
||||
const [sliderPosition, setSliderPosition] = useState(50);
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const [isUserInteracting, setIsUserInteracting] = useState(false);
|
||||
const [tilt, setTilt] = useState({ rx: 0, ry: 0, glareX: 50, glareY: 50, active: false });
|
||||
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const stageRef = useRef<HTMLDivElement>(null);
|
||||
const animFrameRef = useRef<number | null>(null);
|
||||
const resumeTimerRef = useRef<NodeJS.Timeout | null>(null);
|
||||
const startTimeRef = useRef<number>(Date.now());
|
||||
const glareRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// Auto-slide smooth sine oscillation loop
|
||||
// Auto-slide smooth sine oscillation loop (only when explicitly requested)
|
||||
useEffect(() => {
|
||||
if (!autoSlide || isDragging || isUserInteracting) {
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
return;
|
||||
}
|
||||
if (!autoSlide || isDragging) return;
|
||||
|
||||
let animId: number;
|
||||
const start = Date.now();
|
||||
const animate = () => {
|
||||
const elapsed = Date.now() - startTimeRef.current;
|
||||
// Gentle cinematic oscillation between 28% and 72%
|
||||
const newPos = 50 + 22 * Math.sin(elapsed * 0.0014);
|
||||
const elapsed = Date.now() - start;
|
||||
// Gentle cinematic oscillation between 30% and 70%
|
||||
const newPos = 50 + 20 * Math.sin(elapsed * 0.0014);
|
||||
setSliderPosition(newPos);
|
||||
animFrameRef.current = requestAnimationFrame(animate);
|
||||
animId = requestAnimationFrame(animate);
|
||||
};
|
||||
|
||||
animFrameRef.current = requestAnimationFrame(animate);
|
||||
animId = requestAnimationFrame(animate);
|
||||
|
||||
return () => {
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
if (animId) cancelAnimationFrame(animId);
|
||||
};
|
||||
}, [autoSlide, isDragging, isUserInteracting]);
|
||||
}, [autoSlide, isDragging]);
|
||||
|
||||
// Handle position calculation
|
||||
const handleMove = useCallback((clientX: number) => {
|
||||
@@ -97,7 +91,7 @@ export function Cinematic3DComparison({
|
||||
};
|
||||
}, [isDragging, handleMouseMove, handleMouseUp, handleTouchMove]);
|
||||
|
||||
// 3D Spatial Tilt Tracking
|
||||
// 3D Spatial Tilt - Pure Direct DOM Manipulation (Zero React Re-renders on mousemove!)
|
||||
const handleStageMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!containerRef.current) return;
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
@@ -107,27 +101,20 @@ export function Cinematic3DComparison({
|
||||
const rx = -(y - 0.5) * maxTilt * 2;
|
||||
const ry = (x - 0.5) * maxTilt * 2;
|
||||
|
||||
setTilt({
|
||||
rx,
|
||||
ry,
|
||||
glareX: x * 100,
|
||||
glareY: y * 100,
|
||||
active: true,
|
||||
});
|
||||
};
|
||||
|
||||
const handleMouseEnter = () => {
|
||||
setIsUserInteracting(true);
|
||||
if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current);
|
||||
containerRef.current.style.transform = `rotateX(${rx.toFixed(2)}deg) rotateY(${ry.toFixed(2)}deg) scale3d(1.012, 1.012, 1.012)`;
|
||||
if (glareRef.current) {
|
||||
glareRef.current.style.opacity = '0.55';
|
||||
glareRef.current.style.background = `radial-gradient(circle 380px at ${(x * 100).toFixed(1)}% ${(y * 100).toFixed(1)}%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 50%, transparent 80%)`;
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
setTilt((prev) => ({ ...prev, rx: 0, ry: 0, active: false }));
|
||||
if (resumeTimerRef.current) clearTimeout(resumeTimerRef.current);
|
||||
resumeTimerRef.current = setTimeout(() => {
|
||||
setIsUserInteracting(false);
|
||||
startTimeRef.current = Date.now();
|
||||
}, 2800);
|
||||
if (containerRef.current) {
|
||||
containerRef.current.style.transform = 'rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)';
|
||||
}
|
||||
if (glareRef.current) {
|
||||
glareRef.current.style.opacity = '0';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -136,21 +123,12 @@ export function Cinematic3DComparison({
|
||||
<div
|
||||
ref={containerRef}
|
||||
onMouseMove={handleStageMouseMove}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
onMouseDown={() => {
|
||||
setIsDragging(true);
|
||||
setIsUserInteracting(true);
|
||||
}}
|
||||
onTouchStart={() => {
|
||||
setIsDragging(true);
|
||||
setIsUserInteracting(true);
|
||||
}}
|
||||
className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden cursor-ew-resize preserve-3d transition-transform duration-200 ease-out shadow-cinematic-3d hover:shadow-cinematic-hover border border-slate-900/[0.08] bg-slate-950`}
|
||||
onMouseDown={() => setIsDragging(true)}
|
||||
onTouchStart={() => setIsDragging(true)}
|
||||
className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden cursor-ew-resize preserve-3d transition-transform duration-150 ease-out shadow-cinematic-3d hover:shadow-cinematic-hover border border-slate-900/[0.08] bg-slate-950`}
|
||||
style={{
|
||||
transform: tilt.active
|
||||
? `rotateX(${tilt.rx.toFixed(2)}deg) rotateY(${tilt.ry.toFixed(2)}deg) scale3d(1.015, 1.015, 1.015)`
|
||||
: 'rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)',
|
||||
transform: 'rotateX(0deg) rotateY(0deg) scale3d(1, 1, 1)',
|
||||
touchAction: 'pan-y',
|
||||
}}
|
||||
>
|
||||
@@ -165,10 +143,10 @@ export function Cinematic3DComparison({
|
||||
|
||||
{/* Dynamic 3D Cursor Specular Light Glint */}
|
||||
<div
|
||||
className="absolute inset-0 pointer-events-none transition-opacity duration-300 z-10"
|
||||
ref={glareRef}
|
||||
className="absolute inset-0 pointer-events-none transition-opacity duration-300 z-10 opacity-0"
|
||||
style={{
|
||||
opacity: tilt.active ? 0.65 : 0,
|
||||
background: `radial-gradient(circle 380px at ${tilt.glareX}% ${tilt.glareY}%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 50%, transparent 80%)`,
|
||||
background: 'radial-gradient(circle 380px at 50% 50%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.08) 50%, transparent 80%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ interface NavbarProps {
|
||||
export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
const [isScrolled, setIsScrolled] = useState(false);
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [mousePos, setMousePos] = useState({ x: 50, y: 50, active: false });
|
||||
const pathname = usePathname();
|
||||
const navRef = useRef<HTMLDivElement>(null);
|
||||
const glintRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
@@ -28,14 +28,18 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
}, []);
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
if (!glintRef.current) return;
|
||||
const rect = e.currentTarget.getBoundingClientRect();
|
||||
const x = ((e.clientX - rect.left) / rect.width) * 100;
|
||||
const y = ((e.clientY - rect.top) / rect.height) * 100;
|
||||
setMousePos({ x, y, active: true });
|
||||
glintRef.current.style.opacity = '0.6';
|
||||
glintRef.current.style.background = `radial-gradient(ellipse 260px 80px at ${x.toFixed(1)}% ${y.toFixed(1)}%, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.08) 40%, transparent 70%)`;
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
setMousePos((prev) => ({ ...prev, active: false }));
|
||||
if (glintRef.current) {
|
||||
glintRef.current.style.opacity = '0';
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -51,13 +55,10 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
|
||||
{/* Optical Glass Caustic Reflection Sheen */}
|
||||
<div className="liquid-caustic-refraction" aria-hidden="true" />
|
||||
|
||||
{/* Dynamic Specular Caustic Glint - Subtle gloss on cursor interaction */}
|
||||
{/* Dynamic Specular Caustic Glint - Direct DOM, 0 React re-renders */}
|
||||
<div
|
||||
className="absolute inset-0 pointer-events-none transition-opacity duration-300 z-[2]"
|
||||
style={{
|
||||
opacity: mousePos.active ? 0.6 : 0,
|
||||
background: `radial-gradient(ellipse 260px 80px at ${mousePos.x}% ${mousePos.y}%, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.08) 40%, transparent 70%)`,
|
||||
}}
|
||||
ref={glintRef}
|
||||
className="absolute inset-0 pointer-events-none transition-opacity duration-300 z-[2] opacity-0"
|
||||
/>
|
||||
|
||||
{/* Foreground Content: 100% Crisp, High-Contrast, Rock-Solid Static (Zero Wobble) */}
|
||||
|
||||
@@ -9,13 +9,13 @@ export function SmoothScroll() {
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||
|
||||
const lenis = new Lenis({
|
||||
duration: 0.95,
|
||||
duration: 0.75, // Extra smooth, luxurious gliding friction
|
||||
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
||||
orientation: 'vertical',
|
||||
gestureOrientation: 'both', // Allows trackpad horizontal and vertical gestures
|
||||
gestureOrientation: 'vertical',
|
||||
smoothWheel: true,
|
||||
syncTouch: false, // Preserves hardware 120Hz momentum touch scrolling on phones & tablets
|
||||
wheelMultiplier: 1.0,
|
||||
syncTouch: false,
|
||||
wheelMultiplier: 1.05,
|
||||
touchMultiplier: 1.0,
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ export function SmoothScroll() {
|
||||
const targetEl = document.querySelector(href);
|
||||
if (targetEl) {
|
||||
e.preventDefault();
|
||||
lenis.scrollTo(targetEl as HTMLElement, { offset: -90, duration: 1.2 });
|
||||
lenis.scrollTo(targetEl as HTMLElement, { offset: -90, duration: 0.75 });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user