From ba1e5f26dc99d722044525a81d4e7358913c3400 Mon Sep 17 00:00:00 2001 From: vshnosngh Date: Thu, 5 Nov 2026 18:23:55 +0530 Subject: [PATCH] feat(our-tools): calm subtle expansion ratio and scroll-triggered middle-viewport activation --- .../sections/ShiftableToolsGridSection.tsx | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/src/components/sections/ShiftableToolsGridSection.tsx b/src/components/sections/ShiftableToolsGridSection.tsx index 1ef13aa..1b26026 100644 --- a/src/components/sections/ShiftableToolsGridSection.tsx +++ b/src/components/sections/ShiftableToolsGridSection.tsx @@ -104,6 +104,28 @@ export function ShiftableToolsGridSection({ const row1 = displayItems.slice(0, 4); const row2 = displayItems.slice(4, 8); + // Expansion only starts when that section reaches the middle (top of section <= 50% of viewport) + const [isMiddleReached, setIsMiddleReached] = useState(false); + + useEffect(() => { + const checkPosition = () => { + const section = document.getElementById('our-tools'); + if (!section) return; + const rect = section.getBoundingClientRect(); + // Only start expansion once the section reaches the middle of the viewport + const inMiddle = rect.top <= window.innerHeight * 0.5 && rect.bottom >= window.innerHeight * 0.15; + setIsMiddleReached(inMiddle); + }; + + checkPosition(); + window.addEventListener('scroll', checkPosition, { passive: true }); + window.addEventListener('resize', checkPosition, { passive: true }); + return () => { + window.removeEventListener('scroll', checkPosition); + window.removeEventListener('resize', checkPosition); + }; + }, []); + return (
{/* Symbolic Elemental Ambient Highlights */} @@ -136,8 +158,8 @@ export function ShiftableToolsGridSection({ {/* Desktop View (md and up): 2-Row Shiftable Expansion Grid */}
- - + +
{/* Mobile / Phone View ((null); + // Clear any active hover expansion if the section leaves the active middle viewport zone + useEffect(() => { + if (!isEnabled) { + setHoveredId(null); + } + }, [isEnabled]); + return (
{items.map((item) => { - const isHovered = hoveredId === item.id; - const hasOtherHovered = hoveredId !== null && !isHovered; + const isHovered = isEnabled && hoveredId === item.id; + const hasOtherHovered = isEnabled && hoveredId !== null && !isHovered; - // 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; + // Subtle, refined expansion (lesser shift, lesser expansion): + // Hovered card: 1.28 flex-grow (~32% width, gentle expansion) + // Other cards: 0.9066 flex-grow (~22.6% width, minimal displacement) + // At rest or before middle reached: 1.0 flex-grow (25% width each) + // Sum is mathematically conserved at exactly 4.0 (1.28 + 3 * 0.9066 = 4.00) + const flexGrowValue = isHovered ? 1.28 : hasOtherHovered ? 0.9066 : 1; return (
setHoveredId(item.id)} + onMouseEnter={() => { + if (isEnabled) setHoveredId(item.id); + }} onMouseLeave={() => setHoveredId(null)} - className="w-[82vw] max-w-[320px] md:max-w-none md:w-auto shrink-0 md:shrink md:flex-1 snap-start transition-[flex-grow] duration-700 ease-[cubic-bezier(0.16,1,0.3,1)] flex flex-col min-w-0" + className="w-[82vw] max-w-[320px] md:max-w-none md:w-auto shrink-0 md:shrink md:flex-1 snap-start transition-[flex-grow] duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] flex flex-col min-w-0" style={{ flexGrow: flexGrowValue, }}