perf(animations): refactor ShiftableToolsGrid, cursor, hero & sections to locked 60-120fps with zero layout thrashing
This commit is contained in:
@@ -78,16 +78,16 @@ export function FaqSection({
|
||||
return (
|
||||
<div
|
||||
key={idx}
|
||||
className="rounded-2xl border border-slate-200/90 bg-white overflow-hidden shadow-cream-sm hover:shadow-cream-md transition-all duration-200"
|
||||
className="rounded-2xl border border-slate-200/90 bg-white overflow-hidden shadow-cream-sm hover:border-blue-300 transition-[border-color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpenIndex(isOpen ? null : idx)}
|
||||
className="w-full p-6 text-left flex items-center justify-between gap-4 font-bold text-slate-900 hover:text-blue-600 transition-colors"
|
||||
className="w-full p-6 text-left flex items-center justify-between gap-4 font-bold text-slate-900 hover:text-blue-600 transition-colors duration-200"
|
||||
>
|
||||
<span className="text-base sm:text-lg font-display">{item.q}</span>
|
||||
<ChevronDown
|
||||
className={`w-5 h-5 text-slate-400 shrink-0 transition-transform duration-200 ${
|
||||
className={`w-5 h-5 text-slate-400 shrink-0 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||
isOpen ? 'rotate-180 text-blue-600' : ''
|
||||
}`}
|
||||
/>
|
||||
|
||||
@@ -167,14 +167,14 @@ export function HeroSection({
|
||||
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
|
||||
<a
|
||||
href={primaryCtaHref}
|
||||
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-9 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-all duration-300 hover:scale-105 hover:from-blue-600 hover:to-indigo-600 active:scale-95"
|
||||
className="group inline-flex items-center gap-3 rounded-full bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 px-9 py-4 text-xs sm:text-sm font-bold text-white border border-white/15 shadow-xl shadow-slate-900/20 transition-[transform,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 active:scale-95"
|
||||
>
|
||||
<span>{primaryCtaLabel}</span>
|
||||
<ArrowDown className="w-4 h-4 transition-transform group-hover:translate-y-0.5" />
|
||||
<ArrowDown className="w-4 h-4 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-y-0.5" />
|
||||
</a>
|
||||
<a
|
||||
href={secondaryCtaHref}
|
||||
className="inline-flex items-center gap-2.5 rounded-full border border-slate-300/80 bg-white/90 backdrop-blur-md px-8 py-4 text-xs sm:text-sm font-semibold text-slate-800 shadow-sm transition-all duration-300 hover:scale-105 hover:border-blue-400 hover:text-blue-600 hover:bg-white active:scale-95"
|
||||
className="inline-flex items-center gap-2.5 rounded-full border border-slate-300/80 bg-white/90 backdrop-blur-md px-8 py-4 text-xs sm:text-sm font-semibold text-slate-800 shadow-sm transition-[transform,opacity,border-color,color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 hover:border-blue-400 hover:text-blue-600 hover:bg-white active:scale-95"
|
||||
>
|
||||
<Smartphone className="w-4 h-4 text-blue-600" />
|
||||
<span>{secondaryCtaLabel}</span>
|
||||
@@ -250,16 +250,14 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
||||
|
||||
// Geometry: Floating Octahedron Crystal Prism
|
||||
const geometry = new THREE.OctahedronGeometry(1.65, 0);
|
||||
const material = new THREE.MeshPhysicalMaterial({
|
||||
const material = new THREE.MeshStandardMaterial({
|
||||
color: 0x2563eb,
|
||||
emissive: 0x1d4ed8,
|
||||
emissiveIntensity: 0.15,
|
||||
roughness: 0.25,
|
||||
metalness: 0.1,
|
||||
transmission: 0.85,
|
||||
emissiveIntensity: 0.25,
|
||||
roughness: 0.2,
|
||||
metalness: 0.2,
|
||||
transparent: true,
|
||||
opacity: 0.75,
|
||||
ior: 1.5,
|
||||
opacity: 0.8,
|
||||
});
|
||||
|
||||
const crystal = new THREE.Mesh(geometry, material);
|
||||
|
||||
@@ -120,8 +120,13 @@ export function RecommendedAppsSection({
|
||||
return (
|
||||
<div
|
||||
key={slug}
|
||||
className="group relative flex flex-col justify-between rounded-3xl bg-white border border-slate-200/90 p-7 shadow-cream-sm hover:shadow-cream-lg transition-all duration-300 hover:-translate-y-1 hover:border-blue-400/60"
|
||||
className="group relative flex flex-col justify-between rounded-3xl bg-white border border-slate-200/90 p-7 shadow-cream-sm transition-[transform,border-color] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:-translate-y-1 hover:border-blue-400/60 will-change-transform transform-gpu"
|
||||
>
|
||||
{/* GPU Shadow Elevation Layer */}
|
||||
<div
|
||||
className="absolute -inset-px rounded-3xl shadow-cream-lg opacity-0 group-hover:opacity-100 transition-opacity duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div>
|
||||
{/* Top App Icon & Rating */}
|
||||
<div className="flex items-center justify-between mb-5">
|
||||
@@ -168,10 +173,10 @@ export function RecommendedAppsSection({
|
||||
<div className="pt-6 mt-5 border-t border-slate-100">
|
||||
<Link
|
||||
href={`/apps/${slug}`}
|
||||
className="w-full flex items-center justify-center gap-2 py-3.5 rounded-xl text-xs font-bold text-white bg-slate-950 group-hover:bg-blue-600 transition-all duration-300 shadow-sm group-hover:shadow-md"
|
||||
className="w-full flex items-center justify-center gap-2 py-3.5 rounded-xl text-xs font-bold text-white bg-slate-950 group-hover:bg-blue-600 transition-colors duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] shadow-sm"
|
||||
>
|
||||
<span>Get App & QR Code</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 transition-transform group-hover:translate-x-1" />
|
||||
<ArrowRight className="w-3.5 h-3.5 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-x-1" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,7 +163,7 @@ function ReviewCard({
|
||||
tool: string;
|
||||
}) {
|
||||
return (
|
||||
<figure className="relative w-80 sm:w-96 cursor-pointer overflow-hidden rounded-2xl border border-slate-200/90 bg-white p-5 shadow-cream-sm hover:shadow-cream-md hover:border-blue-300 transition-all duration-300">
|
||||
<figure className="relative w-80 sm:w-96 cursor-pointer overflow-hidden rounded-2xl border border-slate-200/90 bg-white p-5 shadow-cream-sm hover:border-blue-300 transition-[border-color,transform] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)]">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 rounded-full bg-gradient-to-tr from-blue-600 to-indigo-600 flex items-center justify-center text-white text-xs font-bold tracking-wider shadow-sm">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { ArrowRight, Sparkles, Video, Sliders, Image as ImageIcon } from 'lucide-react';
|
||||
import { TextAnimate } from '@/components/magicui/text-animate';
|
||||
@@ -18,7 +18,7 @@ export interface ToolMediaItem {
|
||||
afterUrl?: string;
|
||||
}
|
||||
|
||||
interface ShiftableToolsGridProps {
|
||||
export interface ShiftableToolsGridProps {
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
tools?: ToolItem[];
|
||||
@@ -26,7 +26,7 @@ interface ShiftableToolsGridProps {
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
||||
// ROW 1 (4 items) - Landscape 16:9 assets
|
||||
{
|
||||
id: 'tool-blemish',
|
||||
@@ -134,7 +134,7 @@ export function ShiftableToolsGridSection({
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* 2-Row Shiftable Grid Container (Pure Horizontal Expansion, Fixed Height, No Vertical Shifts) */}
|
||||
{/* 2-Row Shiftable Grid Container (Slow, Calm, Pure Horizontal Expansion with Locked Height) */}
|
||||
<div className="space-y-6 sm:space-y-8">
|
||||
<ShiftableRow items={row1} />
|
||||
<ShiftableRow items={row2} />
|
||||
@@ -144,10 +144,10 @@ export function ShiftableToolsGridSection({
|
||||
<div className="pt-6 text-center">
|
||||
<Link
|
||||
href="/tools"
|
||||
className="group inline-flex items-center gap-2.5 px-8 py-4 rounded-full font-bold text-xs sm:text-sm text-white bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 hover:from-blue-600 hover:to-indigo-600 border border-white/10 shadow-lg shadow-slate-900/15 transition-all duration-300 hover:scale-105 active:scale-95"
|
||||
className="group inline-flex items-center gap-2.5 px-8 py-4 rounded-full font-bold text-xs sm:text-sm text-white bg-gradient-to-r from-slate-950 via-slate-900 to-indigo-950 hover:from-blue-600 hover:to-indigo-600 border border-white/10 shadow-lg shadow-slate-900/15 transition-[transform,opacity] duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-105 active:scale-95"
|
||||
>
|
||||
<span>See More Tools</span>
|
||||
<ArrowRight className="w-4 h-4 transition-transform group-hover:translate-x-1" />
|
||||
<ArrowRight className="w-4 h-4 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-x-1" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
@@ -164,31 +164,44 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
||||
const isHovered = hoveredId === item.id;
|
||||
const hasOtherHovered = hoveredId !== null && !isHovered;
|
||||
|
||||
// Luxurious, slow, and smooth horizontal expansion (flex weighting)
|
||||
// No vertical scaling, no height changes, purely horizontal shift
|
||||
const flexClass = isHovered
|
||||
? 'md:flex-[1.75]'
|
||||
: hasOtherHovered
|
||||
? 'md:flex-[0.75]'
|
||||
: 'md:flex-1';
|
||||
// Slow, calm, luxurious horizontal expansion:
|
||||
// When hovered: 1.85 flex-grow (~46% width)
|
||||
// When other is hovered: 0.716 flex-grow (~18% width)
|
||||
// At rest: 1.0 flex-grow (25% width each)
|
||||
// Sum is always mathematically conserved at exactly 4.0 (1.85 + 3 * 0.716 = 4.00)
|
||||
// Fixed flex-basis: 0 eliminates conflicting layout calculations
|
||||
const flexGrowValue = isHovered ? 1.85 : hasOtherHovered ? 0.716 : 1;
|
||||
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
onMouseEnter={() => setHoveredId(item.id)}
|
||||
onMouseLeave={() => setHoveredId(null)}
|
||||
className={`w-full ${flexClass} transition-[flex-grow,flex-basis] duration-700 ease-[cubic-bezier(0.25,1,0.5,1)] flex flex-col flex-shrink-0 min-w-0`}
|
||||
style={{
|
||||
flexGrow: flexGrowValue,
|
||||
flexShrink: 1,
|
||||
flexBasis: '0%',
|
||||
}}
|
||||
className="w-full transition-[flex-grow] duration-1000 ease-[cubic-bezier(0.16,1,0.3,1)] will-change-[flex-grow] flex flex-col min-w-0"
|
||||
>
|
||||
{/* Window Container with strictly locked pixel height & landscape aspect */}
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="group block relative w-full h-[220px] sm:h-[240px] lg:h-[260px] rounded-2xl sm:rounded-3xl overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm hover:shadow-cream-lg transition-shadow duration-500"
|
||||
className="group block relative w-full h-[220px] sm:h-[240px] lg:h-[260px] rounded-2xl sm:rounded-3xl overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm"
|
||||
>
|
||||
{/* GPU-Composited Shadow Elevation Layer (Opacity-only transition, zero paint thrash) */}
|
||||
<div
|
||||
className="absolute -inset-px rounded-2xl sm:rounded-3xl shadow-cream-lg opacity-0 group-hover:opacity-100 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none z-30"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
{/* Media Renderer */}
|
||||
<ToolWindowMedia item={item} isHovered={isHovered} />
|
||||
|
||||
{/* Hover Media Type Pill */}
|
||||
<div className="absolute top-3 left-3 z-20 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500">
|
||||
{/* Hover Media Type Pill (Smooth GPU Opacity Transition) */}
|
||||
<div
|
||||
className="absolute top-3 left-3 z-20 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-500 ease-[cubic-bezier(0.16,1,0.3,1)]"
|
||||
>
|
||||
<span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[10px] font-mono font-bold tracking-wider uppercase bg-slate-950/85 backdrop-blur-md text-white border border-white/20">
|
||||
{item.mediaType === 'video' && <Video className="w-3 h-3 text-cyan-400" />}
|
||||
{item.mediaType === 'comparison' && <Sliders className="w-3 h-3 text-amber-400" />}
|
||||
@@ -201,10 +214,10 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
||||
{/* Little Title Below Window (Fixed height, no vertical jumping) */}
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="mt-2.5 h-6 px-1 flex items-center justify-between text-xs sm:text-sm font-display font-semibold text-slate-800 hover:text-blue-600 transition-colors group"
|
||||
className="mt-2.5 h-6 px-1 flex items-center justify-between text-xs sm:text-sm font-display font-semibold text-slate-800 hover:text-blue-600 transition-colors duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group"
|
||||
>
|
||||
<span className="truncate">{item.title}</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 text-slate-400 group-hover:text-blue-600 group-hover:translate-x-0.5 transition-all flex-shrink-0 ml-1.5" />
|
||||
<ArrowRight className="w-3.5 h-3.5 text-slate-400 group-hover:text-blue-600 group-hover:translate-x-0.5 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] flex-shrink-0 ml-1.5" />
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
@@ -215,9 +228,26 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
||||
|
||||
function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered: boolean }) {
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
const [sliderPos, setSliderPos] = useState<number>(50);
|
||||
const [isManualHover, setIsManualHover] = useState(false);
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const dividerRef = useRef<HTMLDivElement>(null);
|
||||
const afterImgRef = useRef<HTMLImageElement>(null);
|
||||
|
||||
// High performance refs - completely eliminates per-frame React re-renders!
|
||||
const isManualRef = useRef(false);
|
||||
const animFrameRef = useRef<number | null>(null);
|
||||
const pointerRafRef = useRef<number | null>(null);
|
||||
const cachedRectRef = useRef<{ left: number; width: number } | null>(null);
|
||||
|
||||
// Directly mutate DOM styles on the GPU layer without triggering React reconciliation
|
||||
const setSliderDOM = useCallback((percent: number) => {
|
||||
const clamped = Math.max(8, Math.min(92, percent));
|
||||
if (dividerRef.current) {
|
||||
dividerRef.current.style.left = `${clamped}%`;
|
||||
}
|
||||
if (afterImgRef.current) {
|
||||
afterImgRef.current.style.clipPath = `inset(0 ${100 - clamped}% 0 0)`;
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Video Autoplay Muted Loop only on Hover (No zoom, no scale)
|
||||
useEffect(() => {
|
||||
@@ -231,23 +261,28 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
}
|
||||
}, [isHovered, item.mediaType]);
|
||||
|
||||
// Before/After Smooth Automatic Oscillating Scan when hovered
|
||||
// Smooth Automatic Oscillating Scan when hovered:
|
||||
// Runs at 60-120fps directly mutating DOM refs (0 React re-renders!)
|
||||
useEffect(() => {
|
||||
if (item.mediaType !== 'comparison') return;
|
||||
|
||||
if (!isHovered) {
|
||||
setSliderPos(50);
|
||||
setIsManualHover(false);
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
isManualRef.current = false;
|
||||
if (animFrameRef.current) {
|
||||
cancelAnimationFrame(animFrameRef.current);
|
||||
animFrameRef.current = null;
|
||||
}
|
||||
setSliderDOM(50);
|
||||
return;
|
||||
}
|
||||
|
||||
let startTime = Date.now();
|
||||
const sweep = () => {
|
||||
if (!isManualHover) {
|
||||
const elapsed = (Date.now() - startTime) / 1000;
|
||||
const pos = 50 + Math.sin(elapsed * 2.2) * 24;
|
||||
setSliderPos(pos);
|
||||
const startTime = performance.now();
|
||||
const sweep = (now: number) => {
|
||||
if (!isManualRef.current) {
|
||||
const elapsed = (now - startTime) / 1000;
|
||||
// Calm, breathing oscillation: 1.4 rad/s sine wave with 22% sweep amplitude
|
||||
const pos = 50 + Math.sin(elapsed * 1.4) * 22;
|
||||
setSliderDOM(pos);
|
||||
}
|
||||
animFrameRef.current = requestAnimationFrame(sweep);
|
||||
};
|
||||
@@ -255,22 +290,53 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
animFrameRef.current = requestAnimationFrame(sweep);
|
||||
|
||||
return () => {
|
||||
if (animFrameRef.current) cancelAnimationFrame(animFrameRef.current);
|
||||
if (animFrameRef.current) {
|
||||
cancelAnimationFrame(animFrameRef.current);
|
||||
animFrameRef.current = null;
|
||||
}
|
||||
};
|
||||
}, [isHovered, isManualHover, item.mediaType]);
|
||||
}, [isHovered, item.mediaType, setSliderDOM]);
|
||||
|
||||
// Pointer position tracking when mouse moves over the comparison window
|
||||
const handleMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {
|
||||
// Pointer position tracking:
|
||||
// Caches container bounding rect on enter to avoid layout thrashing in pointermove.
|
||||
// Updates slider DOM in requestAnimationFrame with zero React state calls.
|
||||
const handlePointerEnter = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (item.mediaType !== 'comparison') return;
|
||||
setIsManualHover(true);
|
||||
const rect = e.currentTarget.getBoundingClientRect();
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
||||
const percent = Math.max(10, Math.min(90, (x / rect.width) * 100));
|
||||
setSliderPos(percent);
|
||||
cachedRectRef.current = { left: rect.left, width: rect.width };
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
setIsManualHover(false);
|
||||
const handlePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (item.mediaType !== 'comparison') return;
|
||||
isManualRef.current = true;
|
||||
|
||||
const clientX = e.clientX;
|
||||
if (pointerRafRef.current) {
|
||||
cancelAnimationFrame(pointerRafRef.current);
|
||||
}
|
||||
|
||||
pointerRafRef.current = requestAnimationFrame(() => {
|
||||
let rect = cachedRectRef.current;
|
||||
if (!rect && containerRef.current) {
|
||||
const r = containerRef.current.getBoundingClientRect();
|
||||
rect = { left: r.left, width: r.width };
|
||||
cachedRectRef.current = rect;
|
||||
}
|
||||
if (!rect || rect.width <= 0) return;
|
||||
|
||||
const x = Math.max(0, Math.min(clientX - rect.left, rect.width));
|
||||
const percent = (x / rect.width) * 100;
|
||||
setSliderDOM(percent);
|
||||
});
|
||||
};
|
||||
|
||||
const handlePointerLeave = () => {
|
||||
isManualRef.current = false;
|
||||
cachedRectRef.current = null;
|
||||
if (pointerRafRef.current) {
|
||||
cancelAnimationFrame(pointerRafRef.current);
|
||||
pointerRafRef.current = null;
|
||||
}
|
||||
};
|
||||
|
||||
// 1. VIDEO (Strictly locked to fixed 680px centered width - ZERO ZOOM)
|
||||
@@ -284,9 +350,10 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
muted
|
||||
loop
|
||||
playsInline
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-slate-950/10 group-hover:bg-transparent transition-colors duration-500" />
|
||||
{/* GPU-composited overlay (opacity only) */}
|
||||
<div className="absolute inset-0 bg-slate-950/10 opacity-100 group-hover:opacity-0 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -295,51 +362,57 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
if (item.mediaType === 'comparison' && item.beforeUrl && item.afterUrl) {
|
||||
return (
|
||||
<div
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
className="relative w-full h-full select-none cursor-ew-resize overflow-hidden bg-slate-950"
|
||||
ref={containerRef}
|
||||
onPointerEnter={handlePointerEnter}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerLeave={handlePointerLeave}
|
||||
className="relative w-full h-full select-none cursor-ew-resize overflow-hidden bg-slate-950 transform-gpu [backface-visibility:hidden]"
|
||||
>
|
||||
{/* BEFORE Image (Base layer, fixed scale & position, 0% zoom) */}
|
||||
<img
|
||||
src={item.beforeUrl}
|
||||
alt="Before"
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||
loading="lazy"
|
||||
/>
|
||||
|
||||
{/* AFTER Image (Top layer, exact same position & scale, clipped via clip-path) */}
|
||||
<img
|
||||
ref={afterImgRef}
|
||||
src={item.afterUrl}
|
||||
alt="After"
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||
style={{
|
||||
clipPath: `inset(0 ${100 - sliderPos}% 0 0)`,
|
||||
clipPath: 'inset(0 50% 0 0)',
|
||||
}}
|
||||
loading="lazy"
|
||||
/>
|
||||
|
||||
{/* Glowing Slider Divider Line */}
|
||||
{/* Glowing Slider Divider Line (Direct GPU transform & position) */}
|
||||
<div
|
||||
className="absolute top-0 bottom-0 w-[2px] bg-white shadow-[0_0_12px_rgba(255,255,255,1)] pointer-events-none z-10"
|
||||
style={{ left: `${sliderPos}%` }}
|
||||
ref={dividerRef}
|
||||
className="absolute top-0 bottom-0 w-[2px] bg-white shadow-[0_0_12px_rgba(255,255,255,1)] pointer-events-none z-10 will-change-transform transform-gpu -translate-x-1/2"
|
||||
style={{ left: '50%' }}
|
||||
>
|
||||
{/* Circular Grab Handle with Before/After Arrow Cue */}
|
||||
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-7 h-7 rounded-full bg-white shadow-lg border border-slate-200/90 flex items-center justify-center text-[10px] font-bold text-slate-900 pointer-events-none">
|
||||
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-7 h-7 rounded-full bg-white shadow-lg border border-slate-200/90 flex items-center justify-center text-[10px] font-bold text-slate-900 pointer-events-none">
|
||||
↔
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Clean Badges Visible on Hover */}
|
||||
{isHovered && (
|
||||
<div className="absolute bottom-3 inset-x-3 flex justify-between pointer-events-none z-20 text-[9px] font-mono font-bold uppercase tracking-wider text-white">
|
||||
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
||||
AFTER
|
||||
</span>
|
||||
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
||||
BEFORE
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{/* Badges with Smooth GPU Opacity Transition (No DOM mounting/unmounting) */}
|
||||
<div
|
||||
className={`absolute bottom-3 inset-x-3 flex justify-between pointer-events-none z-20 text-[9px] font-mono font-bold uppercase tracking-wider text-white transition-opacity duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||
isHovered ? 'opacity-100' : 'opacity-0'
|
||||
}`}
|
||||
>
|
||||
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
||||
AFTER
|
||||
</span>
|
||||
<span className="bg-slate-950/80 px-2 py-0.5 rounded backdrop-blur border border-white/10">
|
||||
BEFORE
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -350,10 +423,11 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
<img
|
||||
src={item.imageUrl || item.afterUrl || item.beforeUrl || '/brand/og-default.png'}
|
||||
alt={item.title}
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none"
|
||||
className="absolute inset-y-0 left-1/2 -translate-x-1/2 h-full w-[680px] max-w-none object-cover pointer-events-none transform-gpu will-change-transform [backface-visibility:hidden]"
|
||||
loading="lazy"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-slate-950/10 group-hover:bg-transparent transition-colors duration-500" />
|
||||
{/* GPU-composited overlay (opacity only) */}
|
||||
<div className="absolute inset-0 bg-slate-950/10 opacity-100 group-hover:opacity-0 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ export function TrendyBentoSection({
|
||||
<button
|
||||
key={cat.id}
|
||||
onClick={() => setActiveCategory(cat.id)}
|
||||
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-all duration-200 ${
|
||||
className={`flex items-center gap-1.5 px-4 py-2 rounded-full transition-[transform,background-color,color] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] ${
|
||||
isActive
|
||||
? 'bg-slate-950 text-white shadow-md shadow-slate-900/15 scale-105'
|
||||
: 'bg-white/90 text-slate-700 hover:bg-slate-100 border border-slate-200 shadow-sm'
|
||||
@@ -259,18 +259,24 @@ export function TrendyBentoSection({
|
||||
return (
|
||||
<div
|
||||
key={tile.id}
|
||||
className={`group relative flex flex-col justify-between overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm hover:shadow-cream-lg transition-all duration-300 hover:-translate-y-1.5 transform-gpu ${tileClasses}`}
|
||||
className={`group relative flex flex-col justify-between overflow-hidden bg-slate-950 border border-slate-900/[0.08] shadow-cream-sm transition-[transform] duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] hover:-translate-y-1.5 transform-gpu will-change-transform ${tileClasses}`}
|
||||
>
|
||||
{/* GPU-composited shadow elevation layer */}
|
||||
<div
|
||||
className="absolute -inset-px rounded-[36px] sm:rounded-[42px] shadow-cream-lg opacity-0 group-hover:opacity-100 transition-opacity duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none z-30"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
{/* Background Image (Covering the squarical tile) */}
|
||||
<img
|
||||
src={tile.imageUrl}
|
||||
alt={tile.name}
|
||||
className="absolute inset-0 w-full h-full object-cover transition-transform duration-500 group-hover:scale-105"
|
||||
className="absolute inset-0 w-full h-full object-cover transition-transform duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:scale-105 will-change-transform transform-gpu"
|
||||
loading="lazy"
|
||||
/>
|
||||
|
||||
{/* Vignette Overlay for Readability */}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/90 via-slate-950/30 to-slate-950/20 group-hover:via-slate-950/15 transition-all duration-300 pointer-events-none" />
|
||||
{/* Vignette Overlay for Readability (GPU Opacity) */}
|
||||
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/90 via-slate-950/30 to-slate-950/20 opacity-100 group-hover:opacity-85 transition-opacity duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] pointer-events-none" />
|
||||
|
||||
{/* Top Tile Bar: Badge and Quick-Settings Resize Button */}
|
||||
<div className="relative z-20 flex items-center justify-between p-5">
|
||||
@@ -282,7 +288,7 @@ export function TrendyBentoSection({
|
||||
<button
|
||||
onClick={(e) => toggleTileSize(tile.id, e)}
|
||||
title={tile.isWide ? 'Shrink tile' : 'Expand tile'}
|
||||
className="w-9 h-9 rounded-2xl bg-white/90 hover:bg-white text-slate-800 shadow-md flex items-center justify-center transition-all duration-200 hover:scale-110 active:scale-95"
|
||||
className="w-9 h-9 rounded-2xl bg-white/90 hover:bg-white text-slate-800 shadow-md flex items-center justify-center transition-[transform,background-color] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] hover:scale-110 active:scale-95"
|
||||
>
|
||||
{tile.isWide ? (
|
||||
<Minimize2 className="w-4 h-4 text-blue-600" />
|
||||
|
||||
Reference in New Issue
Block a user