fix(ui): drag slider only via arrows handle on phones and make whole trendy bento card clickable
This commit is contained in:
@@ -184,64 +184,32 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
|
||||
}}
|
||||
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 */}
|
||||
{item.mediaType === 'comparison' ? (
|
||||
<div 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 */}
|
||||
<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"
|
||||
/>
|
||||
{/* Window Container with strictly locked pixel height & landscape aspect (entire card is clickable) */}
|
||||
<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 cursor-pointer"
|
||||
>
|
||||
{/* GPU-Composited Shadow Elevation Layer */}
|
||||
<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 (Interactive comparison slider with touch-action: none) */}
|
||||
<ToolWindowMedia item={item} isHovered={isHovered} />
|
||||
{/* Media Renderer */}
|
||||
<ToolWindowMedia item={item} isHovered={isHovered} />
|
||||
|
||||
{/* Dedicated Tool Link Pill on top right so sliding never accidentally navigates */}
|
||||
<Link
|
||||
href={`/tools/${item.slug}`}
|
||||
className="absolute top-3 right-3 z-30 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 hover:bg-blue-600 transition-colors shadow-sm"
|
||||
aria-label={`Open ${item.title}`}
|
||||
>
|
||||
<span>TRY TOOL</span>
|
||||
<ArrowRight className="w-2.5 h-2.5" />
|
||||
</Link>
|
||||
|
||||
{/* 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 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">
|
||||
<Sliders className="w-3 h-3 text-amber-400" />
|
||||
<span>comparison</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<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 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 ease-[cubic-bezier(0.16,1,0.3,1)]"
|
||||
>
|
||||
{/* 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 (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 === 'photo' && <ImageIcon className="w-3 h-3 text-emerald-400" />}
|
||||
<span>{item.mediaType}</span>
|
||||
</span>
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
<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
|
||||
@@ -469,21 +437,8 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
onPointerEnter={handlePointerEnter}
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={handlePointerUp}
|
||||
onPointerCancel={handlePointerUp}
|
||||
onPointerLeave={handlePointerLeave}
|
||||
onKeyDown={handleKeyDown}
|
||||
role="slider"
|
||||
aria-label="Before and after comparison slider"
|
||||
aria-valuemin={8}
|
||||
aria-valuemax={92}
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
style={{ touchAction: 'none' }}
|
||||
className="relative w-full h-full select-none cursor-ew-resize overflow-hidden bg-slate-950 transform-gpu [backface-visibility:hidden] touch-none"
|
||||
style={{ touchAction: 'pan-y' }}
|
||||
className="relative w-full h-full select-none overflow-hidden bg-slate-950 transform-gpu [backface-visibility:hidden]"
|
||||
>
|
||||
{/* BEFORE Image (Base layer, fixed scale & position, 0% zoom) */}
|
||||
<img
|
||||
@@ -505,14 +460,32 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
|
||||
loading="lazy"
|
||||
/>
|
||||
|
||||
{/* Glowing Slider Divider Line (Direct GPU transform & position) */}
|
||||
{/* Glowing Slider Divider Line (pointer-events-none so touching the line allows page scroll) */}
|
||||
<div
|
||||
ref={dividerRef}
|
||||
className="absolute top-0 bottom-0 w-[2.5px] 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 & Touch Padding */}
|
||||
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-8 h-8 rounded-full bg-white shadow-xl border border-slate-200/90 flex items-center justify-center text-xs font-bold text-blue-600 pointer-events-none before:absolute before:-inset-3 before:content-['']">
|
||||
{/* Circular Grab Handle with Before/After Arrow Cue & Touch Padding - Dedicated Drag Trigger with Pointer Capture */}
|
||||
<div
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={handlePointerUp}
|
||||
onPointerCancel={handlePointerUp}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}}
|
||||
onKeyDown={handleKeyDown}
|
||||
role="slider"
|
||||
aria-label="Before and after comparison slider"
|
||||
aria-valuemin={8}
|
||||
aria-valuemax={92}
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
style={{ touchAction: 'none' }}
|
||||
className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 left-1/2 w-8 h-8 rounded-full bg-white shadow-xl border border-slate-200/90 flex items-center justify-center text-xs font-bold text-blue-600 pointer-events-auto cursor-ew-resize touch-none before:absolute before:-inset-3 before:content-['']"
|
||||
>
|
||||
↔
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -257,9 +257,10 @@ export function TrendyBentoSection({
|
||||
: 'col-span-1 aspect-square rounded-[36px] sm:rounded-[42px]';
|
||||
|
||||
return (
|
||||
<div
|
||||
<Link
|
||||
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 transition-[transform] duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] hover:-translate-y-1.5 transform-gpu will-change-transform ${tileClasses}`}
|
||||
href={tile.href}
|
||||
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 cursor-pointer ${tileClasses}`}
|
||||
>
|
||||
{/* GPU-composited shadow elevation layer */}
|
||||
<div
|
||||
@@ -286,9 +287,10 @@ export function TrendyBentoSection({
|
||||
|
||||
{/* Android Quick Settings Size Toggle Button (1x1 to 2x1) */}
|
||||
<button
|
||||
type="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-[transform,background-color] duration-200 ease-[cubic-bezier(0.16,1,0.3,1)] 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 z-30"
|
||||
>
|
||||
{tile.isWide ? (
|
||||
<Minimize2 className="w-4 h-4 text-blue-600" />
|
||||
@@ -312,15 +314,14 @@ export function TrendyBentoSection({
|
||||
{tile.description}
|
||||
</p>
|
||||
|
||||
<Link
|
||||
href={tile.href}
|
||||
<div
|
||||
className="mt-2 inline-flex items-center gap-1.5 text-xs font-display font-bold text-cyan-300 group-hover:text-white transition-colors"
|
||||
>
|
||||
<span>{tile.cta}</span>
|
||||
<ArrowRight className="w-3.5 h-3.5 transition-transform group-hover:translate-x-1" />
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -73,10 +73,11 @@ export function CardBeforeAfterSlider({
|
||||
}
|
||||
}, [setSplit]);
|
||||
|
||||
// Unified Pointer Handlers (Flawless on iOS/Android touchscreens and desktop mouse)
|
||||
// Unified Pointer Handlers on Center Pill Handle with Left/Right Arrows
|
||||
const handlePointerDown = useCallback(
|
||||
(e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (e.button !== 0 && e.pointerType === 'mouse') return;
|
||||
e.stopPropagation();
|
||||
|
||||
isDraggingRef.current = true;
|
||||
isInteractedRef.current = true;
|
||||
@@ -88,13 +89,13 @@ export function CardBeforeAfterSlider({
|
||||
// Fallback
|
||||
}
|
||||
|
||||
// Cache rect on pointer down to eliminate layout thrashing
|
||||
const rect = e.currentTarget.getBoundingClientRect();
|
||||
cachedRectRef.current = { left: rect.left, width: rect.width };
|
||||
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
||||
const percent = (x / rect.width) * 100;
|
||||
setSplit(percent);
|
||||
if (containerRef.current) {
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
cachedRectRef.current = { left: rect.left, width: rect.width };
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
||||
const percent = (x / rect.width) * 100;
|
||||
setSplit(percent);
|
||||
}
|
||||
},
|
||||
[setSplit]
|
||||
);
|
||||
@@ -102,6 +103,7 @@ export function CardBeforeAfterSlider({
|
||||
const handlePointerMove = useCallback(
|
||||
(e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!isDraggingRef.current) return;
|
||||
e.stopPropagation();
|
||||
|
||||
const clientX = e.clientX;
|
||||
if (rafIdRef.current) {
|
||||
@@ -127,6 +129,7 @@ export function CardBeforeAfterSlider({
|
||||
|
||||
const handlePointerUp = useCallback((e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!isDraggingRef.current) return;
|
||||
e.stopPropagation();
|
||||
isDraggingRef.current = false;
|
||||
cachedRectRef.current = null;
|
||||
|
||||
@@ -147,19 +150,11 @@ export function CardBeforeAfterSlider({
|
||||
ref={containerRef}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={handleMouseLeave}
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={handlePointerUp}
|
||||
onPointerCancel={handlePointerUp}
|
||||
role="slider"
|
||||
aria-label="Before and after transformation slider"
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
style={{
|
||||
'--split': '50%',
|
||||
touchAction: 'none', // Strictly prevents mobile touch scrolling interference
|
||||
touchAction: 'pan-y', // Allows mobile vertical scrolling across the card and line
|
||||
} as React.CSSProperties}
|
||||
className={`relative w-full ${aspectRatio} overflow-hidden cursor-ew-resize select-none bg-slate-900 group/slider transition-shadow duration-300 hover:shadow-cream-lg touch-none`}
|
||||
className={`relative w-full ${aspectRatio} overflow-hidden select-none bg-slate-900 group/slider transition-shadow duration-300 hover:shadow-cream-lg`}
|
||||
>
|
||||
{/* Layer 1: After Image (Transformed Neural Result) */}
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
@@ -186,7 +181,7 @@ export function CardBeforeAfterSlider({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Layer 3: Vertical Split Divider Line */}
|
||||
{/* Layer 3: Vertical Split Divider Line (pointer-events-none so it doesn't block scrolling) */}
|
||||
<div
|
||||
className="absolute top-0 bottom-0 w-[2.5px] bg-white z-20 pointer-events-none shadow-[0_0_10px_rgba(0,0,0,0.8)] -translate-x-1/2"
|
||||
style={{ left: 'var(--split)' }}
|
||||
@@ -194,9 +189,20 @@ export function CardBeforeAfterSlider({
|
||||
{/* Glowing Aura */}
|
||||
<div className="absolute -top-4 -bottom-4 -left-1.5 w-3.5 bg-gradient-to-r from-blue-500/30 via-white/70 to-amber-400/30 blur-[2px]" />
|
||||
|
||||
{/* Center Pill Handle with Left/Right Arrows & Touch Pad */}
|
||||
<div className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-9 h-9 sm:w-10 sm:h-10 rounded-full bg-white text-slate-800 shadow-xl border border-slate-900/15 flex items-center justify-center transition-transform group-hover/slider:scale-110 before:absolute before:-inset-3 before:content-['']">
|
||||
<svg className="w-3.5 h-3.5 text-blue-700" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
{/* Center Pill Handle with Left/Right Arrows - Dedicated Drag Trigger with Pointer Capture */}
|
||||
<div
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={handlePointerUp}
|
||||
onPointerCancel={handlePointerUp}
|
||||
role="slider"
|
||||
aria-label="Before and after transformation slider"
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
style={{ touchAction: 'none' }}
|
||||
className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-9 h-9 sm:w-10 sm:h-10 rounded-full bg-white text-slate-800 shadow-xl border border-slate-900/15 flex items-center justify-center transition-transform group-hover/slider:scale-110 before:absolute before:-inset-3 before:content-[''] pointer-events-auto cursor-ew-resize touch-none"
|
||||
>
|
||||
<svg className="w-3.5 h-3.5 text-blue-700 pointer-events-none" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2.5} d="M8 9l-3 3 3 3m8-6l3 3-3 3" />
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
@@ -82,32 +82,32 @@ export function Cinematic3DComparison({
|
||||
};
|
||||
}, [autoSlide, isDragging, updatePosition]);
|
||||
|
||||
// Unified Pointer Handlers (Works with mouse on desktop + touches/pens on mobile/iOS/tablets)
|
||||
// Unified Pointer Handlers on the Slider Arrows Handle
|
||||
const handlePointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (e.button !== 0 && e.pointerType === 'mouse') return;
|
||||
e.stopPropagation();
|
||||
|
||||
isPointerDownRef.current = true;
|
||||
setIsDragging(true);
|
||||
|
||||
// Capture pointer so fast drags outside the element bounds never lose tracking
|
||||
try {
|
||||
e.currentTarget.setPointerCapture(e.pointerId);
|
||||
} catch {
|
||||
// Fallback
|
||||
}
|
||||
|
||||
// Cache rect on pointer down to eliminate layout thrashing during drag
|
||||
const rect = e.currentTarget.getBoundingClientRect();
|
||||
cachedRectRef.current = { left: rect.left, width: rect.width };
|
||||
|
||||
// Instantly update to pointer position
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
||||
const percent = (x / rect.width) * 100;
|
||||
updatePosition(percent);
|
||||
if (containerRef.current) {
|
||||
const rect = containerRef.current.getBoundingClientRect();
|
||||
cachedRectRef.current = { left: rect.left, width: rect.width };
|
||||
const x = Math.max(0, Math.min(e.clientX - rect.left, rect.width));
|
||||
const percent = (x / rect.width) * 100;
|
||||
updatePosition(percent);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePointerMove = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!isPointerDownRef.current) return;
|
||||
e.stopPropagation();
|
||||
|
||||
const clientX = e.clientX;
|
||||
if (rafIdRef.current) {
|
||||
@@ -131,6 +131,7 @@ export function Cinematic3DComparison({
|
||||
|
||||
const handlePointerUp = (e: React.PointerEvent<HTMLDivElement>) => {
|
||||
if (!isPointerDownRef.current) return;
|
||||
e.stopPropagation();
|
||||
isPointerDownRef.current = false;
|
||||
cachedRectRef.current = null;
|
||||
setIsDragging(false);
|
||||
@@ -163,24 +164,13 @@ export function Cinematic3DComparison({
|
||||
|
||||
return (
|
||||
<div className={`w-full perspective-1400 select-none ${className}`}>
|
||||
{/* 3D Kinetic Tilt Stage with Locked Touch-Action for Flawless Mobile Swiping */}
|
||||
{/* 3D Kinetic Tilt Stage - Allows smooth page scrolling when touching anywhere except the arrows handle */}
|
||||
<div
|
||||
ref={containerRef}
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={handlePointerUp}
|
||||
onPointerCancel={handlePointerUp}
|
||||
onKeyDown={handleKeyDown}
|
||||
role="slider"
|
||||
aria-label="Before and after comparison"
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
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 touch-none`}
|
||||
className={`relative w-full ${aspectRatio} rounded-2xl sm:rounded-3xl overflow-hidden 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={{
|
||||
'--split': '50%',
|
||||
touchAction: 'none', // Strictly prevents iOS/Android touch scrolling conflict on the slider
|
||||
touchAction: 'pan-y', // Allows mobile vertical scrolling across the image and line
|
||||
} as React.CSSProperties}
|
||||
>
|
||||
{/* Layer 1: After Image (Full Reconstructed Neural Result) */}
|
||||
@@ -208,7 +198,7 @@ export function Cinematic3DComparison({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Layer 3: Illuminated Holographic Laser Split Line */}
|
||||
{/* Layer 3: Illuminated Holographic Laser Split Line (pointer-events-none so it doesn't block scrolling) */}
|
||||
<div
|
||||
className="absolute top-0 bottom-0 w-[2px] bg-gradient-to-b from-blue-400 via-white to-amber-300 z-20 pointer-events-none -translate-x-1/2"
|
||||
style={{ left: 'var(--split)' }}
|
||||
@@ -216,10 +206,24 @@ export function Cinematic3DComparison({
|
||||
{/* Vertical Caustic Glow Beam */}
|
||||
<div className="absolute -top-4 -bottom-4 -left-1.5 w-3.5 bg-gradient-to-r from-blue-500/20 via-white/40 to-amber-400/20 blur-[3px]" />
|
||||
|
||||
{/* 3D Tactile Center Control Handle with generous touch-target area */}
|
||||
{/* 3D Tactile Center Control Handle with Arrows - Dedicated Drag Trigger with Pointer Capture */}
|
||||
<div
|
||||
className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-10 h-10 sm:w-11 sm:h-11 rounded-full bg-white/95 backdrop-blur-md border border-slate-900/10 shadow-2xl flex items-center justify-center cursor-ew-resize hover:scale-110 active:scale-95 transition-transform duration-150 preserve-3d before:absolute before:-inset-3 before:content-['']"
|
||||
style={{ transform: 'translateZ(28px)' }}
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerUp={handlePointerUp}
|
||||
onPointerCancel={handlePointerUp}
|
||||
onKeyDown={handleKeyDown}
|
||||
role="slider"
|
||||
aria-label="Before and after comparison slider"
|
||||
aria-valuemin={0}
|
||||
aria-valuemax={100}
|
||||
aria-valuenow={50}
|
||||
tabIndex={0}
|
||||
className="absolute top-1/2 -translate-y-1/2 -translate-x-1/2 w-10 h-10 sm:w-11 sm:h-11 rounded-full bg-white/95 backdrop-blur-md border border-slate-900/10 shadow-2xl flex items-center justify-center cursor-ew-resize hover:scale-110 active:scale-95 transition-transform duration-150 preserve-3d before:absolute before:-inset-3 before:content-[''] pointer-events-auto touch-none"
|
||||
style={{
|
||||
transform: 'translateZ(28px)',
|
||||
touchAction: 'none', // Strictly locks drag on the arrow handle only
|
||||
}}
|
||||
>
|
||||
{/* Outer Metallic Ring */}
|
||||
<div className="absolute inset-0 rounded-full border border-blue-600/30 shadow-[0_0_12px_rgba(37,99,235,0.3)]" />
|
||||
|
||||
+19
-5
@@ -4,9 +4,10 @@ import { renderToString } from 'react-dom/server';
|
||||
import { Cinematic3DComparison } from '@/components/ui/Cinematic3DComparison';
|
||||
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
||||
import { ShiftableToolsGridSection } from '@/components/sections/ShiftableToolsGridSection';
|
||||
import { TrendyBentoSection } from '@/components/sections/TrendyBentoSection';
|
||||
|
||||
describe('Before/After Comparison Sliders (Mobile & Touch Responsiveness)', () => {
|
||||
it('Cinematic3DComparison renders with touch-none, role="slider", and touchAction: none', () => {
|
||||
it('Cinematic3DComparison arrow handle has touch-none, role="slider", and touchAction: none', () => {
|
||||
const html = renderToString(
|
||||
<Cinematic3DComparison
|
||||
beforeUrl="/before.jpg"
|
||||
@@ -17,12 +18,13 @@ describe('Before/After Comparison Sliders (Mobile & Touch Responsiveness)', () =
|
||||
);
|
||||
|
||||
expect(html).toContain('role="slider"');
|
||||
expect(html).toContain('aria-label="Before and after comparison"');
|
||||
expect(html).toContain('aria-label="Before and after comparison slider"');
|
||||
expect(html).toContain('touch-none');
|
||||
expect(html).toContain('touch-action:none');
|
||||
expect(html).toContain('touch-action:pan-y');
|
||||
});
|
||||
|
||||
it('CardBeforeAfterSlider renders with touch-none, role="slider", and touchAction: none', () => {
|
||||
it('CardBeforeAfterSlider arrow handle has touch-none, role="slider", and touchAction: none', () => {
|
||||
const html = renderToString(
|
||||
<CardBeforeAfterSlider
|
||||
beforeUrl="/before.jpg"
|
||||
@@ -34,10 +36,11 @@ describe('Before/After Comparison Sliders (Mobile & Touch Responsiveness)', () =
|
||||
expect(html).toContain('aria-label="Before and after transformation slider"');
|
||||
expect(html).toContain('touch-none');
|
||||
expect(html).toContain('touch-action:none');
|
||||
expect(html).toContain('touch-action:pan-y');
|
||||
expect(html).toContain('--split:50%');
|
||||
});
|
||||
|
||||
it('ShiftableToolsGridSection renders comparison sliders as standalone interactive cards with touch-action: none', () => {
|
||||
it('ShiftableToolsGridSection renders comparison cards as clickable links with handle-only slider dragging', () => {
|
||||
const html = renderToString(
|
||||
<ShiftableToolsGridSection />
|
||||
);
|
||||
@@ -46,6 +49,17 @@ describe('Before/After Comparison Sliders (Mobile & Touch Responsiveness)', () =
|
||||
expect(html).toContain('aria-label="Before and after comparison slider"');
|
||||
expect(html).toContain('touch-none');
|
||||
expect(html).toContain('touch-action:none');
|
||||
expect(html).toContain('TRY TOOL');
|
||||
expect(html).toContain('touch-action:pan-y');
|
||||
expect(html).toContain('href="/tools/blemish-remover"');
|
||||
});
|
||||
|
||||
it('TrendyBentoSection renders each tile as a fully clickable card link', () => {
|
||||
const html = renderToString(
|
||||
<TrendyBentoSection />
|
||||
);
|
||||
|
||||
expect(html).toContain('href="/tools/background-remover"');
|
||||
expect(html).toContain('href="/tools/old-photo-restorer"');
|
||||
expect(html).toContain('href="/tools/cartoon-avatar"');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user