diff --git a/src/components/sections/ShiftableToolsGridSection.tsx b/src/components/sections/ShiftableToolsGridSection.tsx
index f7e4afa..7f6fc3f 100644
--- a/src/components/sections/ShiftableToolsGridSection.tsx
+++ b/src/components/sections/ShiftableToolsGridSection.tsx
@@ -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({
- {/* 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) */}
@@ -144,10 +144,10 @@ export function ShiftableToolsGridSection({
@@ -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 (
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 */}
+ {/* GPU-Composited Shadow Elevation Layer (Opacity-only transition, zero paint thrash) */}
+
+
{/* Media Renderer */}
- {/* Hover Media Type Pill */}
-
+ {/* Hover Media Type Pill (Smooth GPU Opacity Transition) */}
+
{item.mediaType === 'video' && }
{item.mediaType === 'comparison' && }
@@ -201,10 +214,10 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
{/* Little Title Below Window (Fixed height, no vertical jumping) */}
{item.title}
-
+
);
@@ -215,9 +228,26 @@ function ShiftableRow({ items }: { items: ToolMediaItem[] }) {
function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered: boolean }) {
const videoRef = useRef
(null);
- const [sliderPos, setSliderPos] = useState(50);
- const [isManualHover, setIsManualHover] = useState(false);
+ const containerRef = useRef(null);
+ const dividerRef = useRef(null);
+ const afterImgRef = useRef(null);
+
+ // High performance refs - completely eliminates per-frame React re-renders!
+ const isManualRef = useRef(false);
const animFrameRef = useRef(null);
+ const pointerRafRef = useRef(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) => {
+ // 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) => {
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) => {
+ 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]"
/>
-
+ {/* GPU-composited overlay (opacity only) */}
+
);
}
@@ -295,51 +362,57 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:
if (item.mediaType === 'comparison' && item.beforeUrl && item.afterUrl) {
return (
{/* BEFORE Image (Base layer, fixed scale & position, 0% zoom) */}

{/* AFTER Image (Top layer, exact same position & scale, clipped via clip-path) */}

- {/* Glowing Slider Divider Line */}
+ {/* Glowing Slider Divider Line (Direct GPU transform & position) */}
{/* Circular Grab Handle with Before/After Arrow Cue */}
-
- {/* Clean Badges Visible on Hover */}
- {isHovered && (
-
-
- AFTER
-
-
- BEFORE
-
-
- )}
+ {/* Badges with Smooth GPU Opacity Transition (No DOM mounting/unmounting) */}
+
+
+ AFTER
+
+
+ BEFORE
+
+
);
}
@@ -350,10 +423,11 @@ function ToolWindowMedia({ item, isHovered }: { item: ToolMediaItem; isHovered:

-
+ {/* GPU-composited overlay (opacity only) */}
+
);
}
diff --git a/src/components/sections/TrendyBentoSection.tsx b/src/components/sections/TrendyBentoSection.tsx
index 1535303..d0d0eef 100644
--- a/src/components/sections/TrendyBentoSection.tsx
+++ b/src/components/sections/TrendyBentoSection.tsx
@@ -230,7 +230,7 @@ export function TrendyBentoSection({