2026-11-04 17:55:18 +05:30
|
|
|
'use client';
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
2026-11-04 17:55:18 +05:30
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { ArrowRight, Sparkles, Video, Sliders, Image as ImageIcon } from 'lucide-react';
|
|
|
|
|
import { TextAnimate } from '@/components/magicui/text-animate';
|
|
|
|
|
import { ToolItem } from '@/types';
|
|
|
|
|
|
|
|
|
|
export interface ToolMediaItem {
|
|
|
|
|
id: string;
|
|
|
|
|
slug: string;
|
|
|
|
|
title: string;
|
|
|
|
|
mediaType: 'video' | 'photo' | 'comparison';
|
|
|
|
|
videoUrl?: string;
|
|
|
|
|
poster?: string;
|
|
|
|
|
imageUrl?: string;
|
|
|
|
|
beforeUrl?: string;
|
|
|
|
|
afterUrl?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
export interface ShiftableToolsGridProps {
|
2026-11-04 17:55:18 +05:30
|
|
|
title?: string;
|
|
|
|
|
subtitle?: string;
|
|
|
|
|
tools?: ToolItem[];
|
|
|
|
|
items?: ToolMediaItem[];
|
|
|
|
|
locale?: string;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
export const DEFAULT_TOOL_ITEMS: ToolMediaItem[] = [
|
2026-11-04 18:22:18 +05:30
|
|
|
// ROW 1 (4 items) - Landscape 16:9 assets
|
2026-11-04 17:55:18 +05:30
|
|
|
{
|
|
|
|
|
id: 'tool-blemish',
|
|
|
|
|
slug: 'blemish-remover',
|
2026-11-05 11:01:09 +05:30
|
|
|
title: 'Skin & Blemish Retoucher',
|
2026-11-04 17:55:18 +05:30
|
|
|
mediaType: 'comparison',
|
2026-11-04 18:22:18 +05:30
|
|
|
beforeUrl: '/management/pages/home/media/landscape_blemish_before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/home/media/landscape_blemish_after.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-bg-remover',
|
|
|
|
|
slug: 'background-remover',
|
|
|
|
|
title: 'Background Remover (Alpha Matting)',
|
|
|
|
|
mediaType: 'video',
|
|
|
|
|
videoUrl: '/management/pages/home/media/sample_reel.mp4',
|
2026-11-04 18:22:18 +05:30
|
|
|
poster: '/management/pages/home/media/landscape_bg_matting.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-enhancer',
|
|
|
|
|
slug: 'photo-enhancer',
|
|
|
|
|
title: 'Photo Enhancer 4K',
|
|
|
|
|
mediaType: 'comparison',
|
2026-11-04 18:22:18 +05:30
|
|
|
beforeUrl: '/management/pages/home/media/landscape_enhancer_before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/home/media/landscape_enhancer_after.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-restorer',
|
|
|
|
|
slug: 'old-photo-restorer',
|
|
|
|
|
title: 'Vintage Photo Restorer',
|
2026-11-04 18:22:18 +05:30
|
|
|
mediaType: 'comparison',
|
|
|
|
|
beforeUrl: '/management/pages/home/media/landscape_restore_before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/home/media/landscape_restore_after.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
// ROW 2 (4 items) - Landscape 16:9 assets
|
2026-11-04 17:55:18 +05:30
|
|
|
{
|
|
|
|
|
id: 'tool-colorization',
|
|
|
|
|
slug: 'colorization',
|
|
|
|
|
title: 'AI Colorizer',
|
|
|
|
|
mediaType: 'comparison',
|
2026-11-04 18:22:18 +05:30
|
|
|
beforeUrl: '/management/pages/home/media/landscape_color_before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/home/media/landscape_color_after.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-teeth',
|
|
|
|
|
slug: 'teeth-whitener',
|
|
|
|
|
title: 'Teeth Whitener & Brightener',
|
2026-11-04 18:22:18 +05:30
|
|
|
mediaType: 'comparison',
|
|
|
|
|
beforeUrl: '/management/pages/home/media/landscape_teeth_before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/home/media/landscape_teeth_after.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-cartoon',
|
|
|
|
|
slug: 'cartoon-avatar',
|
|
|
|
|
title: 'Cartoon & Anime Avatar',
|
|
|
|
|
mediaType: 'comparison',
|
2026-11-04 18:22:18 +05:30
|
|
|
beforeUrl: '/management/pages/home/media/landscape_cartoon_before.jpg',
|
|
|
|
|
afterUrl: '/management/pages/home/media/landscape_cartoon_after.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'tool-polaroid',
|
|
|
|
|
slug: 'polaroid-maker',
|
|
|
|
|
title: 'Vintage Polaroid Maker',
|
|
|
|
|
mediaType: 'photo',
|
2026-11-04 18:22:18 +05:30
|
|
|
imageUrl: '/management/pages/home/media/landscape_polaroid.jpg',
|
2026-11-04 17:55:18 +05:30
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
export function ShiftableToolsGridSection({
|
|
|
|
|
title = 'Our Tools',
|
|
|
|
|
subtitle = 'Click on any tool window to try with your own photos in seconds.',
|
|
|
|
|
items,
|
|
|
|
|
}: ShiftableToolsGridProps) {
|
|
|
|
|
const displayItems = items && items.length >= 8 ? items : DEFAULT_TOOL_ITEMS;
|
|
|
|
|
const row1 = displayItems.slice(0, 4);
|
|
|
|
|
const row2 = displayItems.slice(4, 8);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-04 18:37:52 +05:30
|
|
|
<section id="our-tools" className="py-14 sm:py-20 px-4 sm:px-6 md:px-8 lg:px-10 bg-[#FAF8F5] relative overflow-hidden">
|
|
|
|
|
{/* Symbolic Elemental Ambient Highlights */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute inset-0 pointer-events-none -z-10"
|
|
|
|
|
style={{
|
|
|
|
|
background: 'radial-gradient(circle at 15% 30%, rgba(37,99,235,0.06) 0%, transparent 60%), radial-gradient(circle at 85% 70%, rgba(147,51,234,0.05) 0%, transparent 60%)',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<div className="max-w-[1640px] mx-auto space-y-10">
|
2026-11-04 17:55:18 +05:30
|
|
|
{/* Header */}
|
|
|
|
|
<div className="text-center max-w-3xl mx-auto space-y-4">
|
|
|
|
|
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full text-xs font-mono font-semibold tracking-wider uppercase text-blue-700 bg-blue-50 border border-blue-200">
|
|
|
|
|
<Sparkles className="w-3.5 h-3.5 text-blue-600" />
|
|
|
|
|
<span>AI Creative Tools</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h2 className="text-3xl sm:text-5xl font-display font-extrabold text-slate-900 tracking-tight">
|
2026-11-04 18:05:26 +05:30
|
|
|
<TextAnimate animation="slideLeft" by="character">
|
2026-11-04 17:55:18 +05:30
|
|
|
{title}
|
|
|
|
|
</TextAnimate>
|
|
|
|
|
</h2>
|
|
|
|
|
|
2026-11-04 18:05:26 +05:30
|
|
|
<p className="text-sm sm:text-base text-slate-600 font-sans text-pretty">
|
2026-11-04 17:55:18 +05:30
|
|
|
<TextAnimate animation="fadeIn" by="word" delay={0.2}>
|
|
|
|
|
{subtitle}
|
|
|
|
|
</TextAnimate>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* 2-Row Shiftable Grid Container (Slow, Calm, Pure Horizontal Expansion with Locked Height) */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<div className="space-y-6 sm:space-y-8">
|
|
|
|
|
<ShiftableRow items={row1} />
|
|
|
|
|
<ShiftableRow items={row2} />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* See More Section Button Redirecting to /tools */}
|
|
|
|
|
<div className="pt-6 text-center">
|
|
|
|
|
<Link
|
|
|
|
|
href="/tools"
|
2026-11-04 18:48:24 +05:30
|
|
|
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"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
|
|
|
|
<span>See More Tools</span>
|
2026-11-04 18:48:24 +05:30
|
|
|
<ArrowRight className="w-4 h-4 transition-transform duration-300 ease-[cubic-bezier(0.16,1,0.3,1)] group-hover:translate-x-1" />
|
2026-11-04 17:55:18 +05:30
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
|
|
|
|
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-04 18:05:26 +05:30
|
|
|
<div className="flex flex-col md:flex-row gap-4 sm:gap-6 w-full items-start">
|
2026-11-04 17:55:18 +05:30
|
|
|
{items.map((item) => {
|
|
|
|
|
const isHovered = hoveredId === item.id;
|
|
|
|
|
const hasOtherHovered = hoveredId !== null && !isHovered;
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
// 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;
|
2026-11-04 17:55:18 +05:30
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
key={item.id}
|
|
|
|
|
onMouseEnter={() => setHoveredId(item.id)}
|
|
|
|
|
onMouseLeave={() => setHoveredId(null)}
|
2026-11-04 18:48:24 +05:30
|
|
|
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"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
2026-11-04 18:22:18 +05:30
|
|
|
{/* Window Container with strictly locked pixel height & landscape aspect */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<Link
|
|
|
|
|
href={`/tools/${item.slug}`}
|
2026-11-04 18:48:24 +05:30
|
|
|
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"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* 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"
|
|
|
|
|
/>
|
|
|
|
|
|
2026-11-04 17:55:18 +05:30
|
|
|
{/* Media Renderer */}
|
|
|
|
|
<ToolWindowMedia item={item} isHovered={isHovered} />
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* 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)]"
|
|
|
|
|
>
|
2026-11-04 17:55:18 +05:30
|
|
|
<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" />}
|
|
|
|
|
{item.mediaType === 'photo' && <ImageIcon className="w-3 h-3 text-emerald-400" />}
|
|
|
|
|
<span>{item.mediaType}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
|
|
|
|
|
{/* Little Title Below Window (Fixed height, no vertical jumping) */}
|
|
|
|
|
<Link
|
|
|
|
|
href={`/tools/${item.slug}`}
|
2026-11-04 18:48:24 +05:30
|
|
|
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"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
|
|
|
|
<span className="truncate">{item.title}</span>
|
2026-11-04 18:48:24 +05:30
|
|
|
<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" />
|
2026-11-04 17:55:18 +05:30
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered: boolean }) {
|
|
|
|
|
const videoRef = useRef<HTMLVideoElement>(null);
|
2026-11-04 18:48:24 +05:30
|
|
|
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);
|
2026-11-04 17:55:18 +05:30
|
|
|
const animFrameRef = useRef<number | null>(null);
|
2026-11-04 18:48:24 +05:30
|
|
|
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)`;
|
|
|
|
|
}
|
|
|
|
|
}, []);
|
2026-11-04 17:55:18 +05:30
|
|
|
|
|
|
|
|
// Video Autoplay Muted Loop only on Hover (No zoom, no scale)
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (item.mediaType === 'video' && videoRef.current) {
|
|
|
|
|
if (isHovered) {
|
|
|
|
|
videoRef.current.play().catch(() => {});
|
|
|
|
|
} else {
|
|
|
|
|
videoRef.current.pause();
|
|
|
|
|
videoRef.current.currentTime = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, [isHovered, item.mediaType]);
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
// Smooth Automatic Oscillating Scan when hovered:
|
|
|
|
|
// Runs at 60-120fps directly mutating DOM refs (0 React re-renders!)
|
2026-11-04 17:55:18 +05:30
|
|
|
useEffect(() => {
|
|
|
|
|
if (item.mediaType !== 'comparison') return;
|
|
|
|
|
|
|
|
|
|
if (!isHovered) {
|
2026-11-04 18:48:24 +05:30
|
|
|
isManualRef.current = false;
|
|
|
|
|
if (animFrameRef.current) {
|
|
|
|
|
cancelAnimationFrame(animFrameRef.current);
|
|
|
|
|
animFrameRef.current = null;
|
|
|
|
|
}
|
|
|
|
|
setSliderDOM(50);
|
2026-11-04 17:55:18 +05:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
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);
|
2026-11-04 17:55:18 +05:30
|
|
|
}
|
|
|
|
|
animFrameRef.current = requestAnimationFrame(sweep);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
animFrameRef.current = requestAnimationFrame(sweep);
|
|
|
|
|
|
|
|
|
|
return () => {
|
2026-11-04 18:48:24 +05:30
|
|
|
if (animFrameRef.current) {
|
|
|
|
|
cancelAnimationFrame(animFrameRef.current);
|
|
|
|
|
animFrameRef.current = null;
|
|
|
|
|
}
|
2026-11-04 17:55:18 +05:30
|
|
|
};
|
2026-11-04 18:48:24 +05:30
|
|
|
}, [isHovered, item.mediaType, setSliderDOM]);
|
2026-11-04 17:55:18 +05:30
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
// 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>) => {
|
2026-11-04 17:55:18 +05:30
|
|
|
if (item.mediaType !== 'comparison') return;
|
|
|
|
|
const rect = e.currentTarget.getBoundingClientRect();
|
2026-11-04 18:48:24 +05:30
|
|
|
cachedRectRef.current = { left: rect.left, width: rect.width };
|
2026-11-04 17:55:18 +05:30
|
|
|
};
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
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;
|
|
|
|
|
}
|
2026-11-04 17:55:18 +05:30
|
|
|
};
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
// 1. VIDEO (Strictly locked to fixed 680px centered width - ZERO ZOOM)
|
2026-11-04 17:55:18 +05:30
|
|
|
if (item.mediaType === 'video' && item.videoUrl) {
|
|
|
|
|
return (
|
2026-11-04 18:22:18 +05:30
|
|
|
<div className="relative w-full h-full overflow-hidden bg-slate-950">
|
2026-11-04 17:55:18 +05:30
|
|
|
<video
|
|
|
|
|
ref={videoRef}
|
|
|
|
|
src={item.videoUrl}
|
|
|
|
|
poster={item.poster}
|
|
|
|
|
muted
|
|
|
|
|
loop
|
|
|
|
|
playsInline
|
2026-11-04 18:48:24 +05:30
|
|
|
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]"
|
2026-11-04 17:55:18 +05:30
|
|
|
/>
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* 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" />
|
2026-11-04 17:55:18 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
// 2. COMPARISON: Pixel-perfect clip-path slider (ZERO ZOOM - locked fixed scale & centered position)
|
2026-11-04 17:55:18 +05:30
|
|
|
if (item.mediaType === 'comparison' && item.beforeUrl && item.afterUrl) {
|
|
|
|
|
return (
|
|
|
|
|
<div
|
2026-11-04 18:48:24 +05:30
|
|
|
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]"
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
2026-11-04 18:22:18 +05:30
|
|
|
{/* BEFORE Image (Base layer, fixed scale & position, 0% zoom) */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<img
|
|
|
|
|
src={item.beforeUrl}
|
|
|
|
|
alt="Before"
|
2026-11-04 18:48:24 +05:30
|
|
|
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]"
|
2026-11-04 17:55:18 +05:30
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
{/* AFTER Image (Top layer, exact same position & scale, clipped via clip-path) */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<img
|
2026-11-04 18:48:24 +05:30
|
|
|
ref={afterImgRef}
|
2026-11-04 17:55:18 +05:30
|
|
|
src={item.afterUrl}
|
|
|
|
|
alt="After"
|
2026-11-04 18:48:24 +05:30
|
|
|
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]"
|
2026-11-04 17:55:18 +05:30
|
|
|
style={{
|
2026-11-04 18:48:24 +05:30
|
|
|
clipPath: 'inset(0 50% 0 0)',
|
2026-11-04 17:55:18 +05:30
|
|
|
}}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* Glowing Slider Divider Line (Direct GPU transform & position) */}
|
2026-11-04 17:55:18 +05:30
|
|
|
<div
|
2026-11-04 18:48:24 +05:30
|
|
|
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%' }}
|
2026-11-04 17:55:18 +05:30
|
|
|
>
|
|
|
|
|
{/* Circular Grab Handle with Before/After Arrow Cue */}
|
2026-11-04 18:48:24 +05:30
|
|
|
<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">
|
2026-11-04 17:55:18 +05:30
|
|
|
↔
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* 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>
|
2026-11-04 17:55:18 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-04 18:22:18 +05:30
|
|
|
// 3. PHOTO (Strictly locked to fixed 680px centered width - ZERO ZOOM)
|
2026-11-04 17:55:18 +05:30
|
|
|
return (
|
2026-11-04 18:22:18 +05:30
|
|
|
<div className="relative w-full h-full overflow-hidden bg-slate-950">
|
2026-11-04 17:55:18 +05:30
|
|
|
<img
|
|
|
|
|
src={item.imageUrl || item.afterUrl || item.beforeUrl || '/brand/og-default.png'}
|
|
|
|
|
alt={item.title}
|
2026-11-04 18:48:24 +05:30
|
|
|
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]"
|
2026-11-04 17:55:18 +05:30
|
|
|
loading="lazy"
|
|
|
|
|
/>
|
2026-11-04 18:48:24 +05:30
|
|
|
{/* 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" />
|
2026-11-04 17:55:18 +05:30
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|