2026-11-03 16:44:13 +05:30
|
|
|
'use client';
|
|
|
|
|
|
2026-11-04 11:25:57 +05:30
|
|
|
import React, { useRef, useState, useEffect, useCallback } from 'react';
|
2026-11-03 16:44:13 +05:30
|
|
|
import Link from 'next/link';
|
2026-11-04 11:25:57 +05:30
|
|
|
import { ArrowRight, Check, Smartphone, ChevronLeft, ChevronRight } from 'lucide-react';
|
|
|
|
|
import { DeferredComparison } from '@/components/ui/DeferredComparison';
|
2026-11-03 16:44:13 +05:30
|
|
|
|
2026-11-03 18:06:20 +05:30
|
|
|
export interface ShowcaseItem {
|
2026-11-03 16:44:13 +05:30
|
|
|
id: string;
|
|
|
|
|
index: string;
|
2026-11-03 18:06:20 +05:30
|
|
|
tabLabel?: string;
|
2026-11-03 16:44:13 +05:30
|
|
|
category: string;
|
|
|
|
|
model: string;
|
|
|
|
|
latency: string;
|
|
|
|
|
title: string;
|
|
|
|
|
tagline: string;
|
|
|
|
|
description: string;
|
2026-11-03 18:06:20 +05:30
|
|
|
variant?: 'comparison' | 'banner';
|
|
|
|
|
beforeUrl?: string;
|
|
|
|
|
afterUrl?: string;
|
|
|
|
|
bannerImage?: string;
|
|
|
|
|
bannerBadge?: string;
|
2026-11-03 16:44:13 +05:30
|
|
|
toolSlug: string;
|
|
|
|
|
appSlug: string;
|
|
|
|
|
appName: string;
|
|
|
|
|
specs: string[];
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-03 18:06:20 +05:30
|
|
|
interface CinematicHorizontalProps {
|
|
|
|
|
title?: string;
|
|
|
|
|
badge?: string;
|
|
|
|
|
subtitle?: string;
|
|
|
|
|
items?: ShowcaseItem[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function CinematicHorizontalScrollSection({
|
|
|
|
|
title = 'Interactive Model Showcase',
|
|
|
|
|
badge = 'FLAGSHIP TRANSFORMATION MODELS',
|
2026-11-04 11:25:57 +05:30
|
|
|
subtitle = 'Browse the flagship tools with native cinematic pan controls.',
|
|
|
|
|
items = [],
|
2026-11-03 18:06:20 +05:30
|
|
|
}: CinematicHorizontalProps) {
|
2026-11-04 11:25:57 +05:30
|
|
|
const sectionRef = useRef<HTMLElement>(null);
|
|
|
|
|
const railRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
const activeIndexRef = useRef(0);
|
|
|
|
|
const lastWheelTimeRef = useRef(0);
|
|
|
|
|
|
|
|
|
|
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
|
|
|
|
const [canScrollRight, setCanScrollRight] = useState(true);
|
|
|
|
|
|
|
|
|
|
// Helper to compute snap-center targets for all cards
|
|
|
|
|
const getCardPositions = useCallback(() => {
|
|
|
|
|
const rail = railRef.current;
|
|
|
|
|
if (!rail) return [];
|
|
|
|
|
const cards = Array.from(rail.querySelectorAll('article'));
|
|
|
|
|
if (!cards.length) return [];
|
|
|
|
|
|
|
|
|
|
const halfView = rail.clientWidth / 2;
|
|
|
|
|
const maxScroll = Math.max(0, rail.scrollWidth - rail.clientWidth);
|
|
|
|
|
|
|
|
|
|
return cards.map((c) => {
|
|
|
|
|
const center = c.offsetLeft + c.offsetWidth / 2;
|
|
|
|
|
return Math.max(0, Math.min(maxScroll, Math.round(center - halfView)));
|
|
|
|
|
});
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// Update bounds and sync active card index on scroll
|
|
|
|
|
const checkScrollBounds = useCallback(() => {
|
|
|
|
|
const rail = railRef.current;
|
|
|
|
|
if (!rail) return;
|
|
|
|
|
const maxScroll = rail.scrollWidth - rail.clientWidth;
|
|
|
|
|
const current = rail.scrollLeft;
|
|
|
|
|
|
|
|
|
|
setCanScrollLeft(current > 8);
|
|
|
|
|
setCanScrollRight(current < maxScroll - 8);
|
|
|
|
|
|
|
|
|
|
// Sync active index with nearest card
|
|
|
|
|
const positions = getCardPositions();
|
|
|
|
|
if (positions.length > 0) {
|
|
|
|
|
let closest = 0;
|
|
|
|
|
let minDiff = Infinity;
|
|
|
|
|
positions.forEach((pos, idx) => {
|
|
|
|
|
const diff = Math.abs(pos - current);
|
|
|
|
|
if (diff < minDiff) {
|
|
|
|
|
minDiff = diff;
|
|
|
|
|
closest = idx;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
activeIndexRef.current = closest;
|
|
|
|
|
}
|
|
|
|
|
}, [getCardPositions]);
|
|
|
|
|
|
|
|
|
|
// Update on mount, resize, and scroll
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const rail = railRef.current;
|
|
|
|
|
if (!rail) return;
|
|
|
|
|
|
|
|
|
|
checkScrollBounds();
|
|
|
|
|
|
|
|
|
|
const handleScroll = () => {
|
|
|
|
|
checkScrollBounds();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
rail.addEventListener('scroll', handleScroll, { passive: true });
|
|
|
|
|
window.addEventListener('resize', checkScrollBounds);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
rail.removeEventListener('scroll', handleScroll);
|
|
|
|
|
window.removeEventListener('resize', checkScrollBounds);
|
|
|
|
|
};
|
|
|
|
|
}, [checkScrollBounds, items.length]);
|
|
|
|
|
|
|
|
|
|
// Mandatory Horizontal Scroll Lock:
|
|
|
|
|
// Visitor cannot scroll down past this section until the horizontal scroll is completely finished.
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const rail = railRef.current;
|
|
|
|
|
const section = sectionRef.current;
|
|
|
|
|
if (!rail || !section) return;
|
|
|
|
|
|
|
|
|
|
const WHEEL_COOLDOWN = 450; // Smooth glide cooldown between cards
|
|
|
|
|
|
|
|
|
|
const handleWheel = (e: WheelEvent) => {
|
|
|
|
|
// Allow native 2-finger horizontal trackpad gestures
|
|
|
|
|
if (Math.abs(e.deltaX) >= Math.abs(e.deltaY)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Ignore micro-jitters
|
|
|
|
|
if (Math.abs(e.deltaY) < 8) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const sectionRect = section.getBoundingClientRect();
|
|
|
|
|
const railRect = rail.getBoundingClientRect();
|
|
|
|
|
const vh = window.innerHeight;
|
|
|
|
|
|
|
|
|
|
// If the showcase section is completely outside the viewport, do nothing
|
|
|
|
|
if (sectionRect.bottom < 0 || sectionRect.top > vh) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const railCenter = railRect.top + railRect.height / 2;
|
|
|
|
|
const isDown = e.deltaY > 0;
|
|
|
|
|
const isUp = e.deltaY < 0;
|
|
|
|
|
const currentIndex = activeIndexRef.current;
|
|
|
|
|
const positions = getCardPositions();
|
|
|
|
|
if (positions.length <= 1) return;
|
|
|
|
|
|
|
|
|
|
const lastIndex = positions.length - 1;
|
|
|
|
|
|
|
|
|
|
// 1. Approaching from above: allow normal page scroll until cards align in the middle of the screen
|
|
|
|
|
if (currentIndex === 0 && isDown && railCenter > vh * 0.65) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. Approaching from below: allow normal page scroll up until cards align in the middle of the screen
|
|
|
|
|
if (currentIndex === lastIndex && isUp && railCenter < vh * 0.35) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const now = Date.now();
|
|
|
|
|
|
|
|
|
|
// 3. Mandatory completion release & momentum absorption:
|
|
|
|
|
// At last card scrolling down:
|
|
|
|
|
if (isDown && currentIndex >= lastIndex) {
|
|
|
|
|
// If we just glided to the last card, absorb residual wheel burst so visitor doesn't skip seeing it
|
|
|
|
|
if (now - lastWheelTimeRef.current < WHEEL_COOLDOWN + 150) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Horizontal scroll is complete! Release lock and allow visitor to scroll down the page
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// At first card scrolling up:
|
|
|
|
|
if (isUp && currentIndex <= 0) {
|
|
|
|
|
// If we just glided to the first card, absorb residual wheel burst
|
|
|
|
|
if (now - lastWheelTimeRef.current < WHEEL_COOLDOWN + 150) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// At first card scrolling up -> release lock and allow visitor to scroll up the page
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. In all other cases while showcase is aligned in middle and horizontal cards are incomplete:
|
|
|
|
|
// LOCK VERTICAL PAGE SCROLL (Visitor CANNOT scroll down past the section until horizontal scroll is finished)
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
|
|
// Absorb rapid wheel bursts during active glide transition
|
|
|
|
|
if (now - lastWheelTimeRef.current < WHEEL_COOLDOWN) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
lastWheelTimeRef.current = now;
|
|
|
|
|
|
|
|
|
|
// Glide smoothly to next or previous card
|
|
|
|
|
if (isDown && currentIndex < lastIndex) {
|
|
|
|
|
const nextIndex = currentIndex + 1;
|
|
|
|
|
activeIndexRef.current = nextIndex;
|
|
|
|
|
rail.scrollTo({
|
|
|
|
|
left: positions[nextIndex],
|
|
|
|
|
behavior: 'smooth',
|
|
|
|
|
});
|
|
|
|
|
} else if (isUp && currentIndex > 0) {
|
|
|
|
|
const prevIndex = currentIndex - 1;
|
|
|
|
|
activeIndexRef.current = prevIndex;
|
|
|
|
|
rail.scrollTo({
|
|
|
|
|
left: positions[prevIndex],
|
|
|
|
|
behavior: 'smooth',
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
window.addEventListener('wheel', handleWheel, { passive: false });
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener('wheel', handleWheel);
|
|
|
|
|
};
|
|
|
|
|
}, [getCardPositions]);
|
|
|
|
|
|
|
|
|
|
// Slide precisely between cards using side arrows
|
|
|
|
|
const scrollDirection = (direction: 'left' | 'right') => {
|
|
|
|
|
const rail = railRef.current;
|
|
|
|
|
if (!rail) return;
|
|
|
|
|
|
|
|
|
|
const positions = getCardPositions();
|
|
|
|
|
if (positions.length <= 1) return;
|
|
|
|
|
|
|
|
|
|
const current = rail.scrollLeft;
|
|
|
|
|
let targetIndex = activeIndexRef.current;
|
|
|
|
|
|
|
|
|
|
if (direction === 'right') {
|
|
|
|
|
const nextIdx = positions.findIndex((pos) => pos > current + 15);
|
|
|
|
|
targetIndex = nextIdx !== -1 ? nextIdx : positions.length - 1;
|
|
|
|
|
} else {
|
|
|
|
|
let prevIdx = -1;
|
|
|
|
|
for (let i = positions.length - 1; i >= 0; i--) {
|
|
|
|
|
if (positions[i] < current - 15) {
|
|
|
|
|
prevIdx = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
targetIndex = prevIdx !== -1 ? prevIdx : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activeIndexRef.current = targetIndex;
|
|
|
|
|
rail.scrollTo({
|
|
|
|
|
left: positions[targetIndex],
|
|
|
|
|
behavior: 'smooth',
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!items.length) return null;
|
2026-11-03 17:31:00 +05:30
|
|
|
|
2026-11-03 16:44:13 +05:30
|
|
|
return (
|
2026-11-04 11:25:57 +05:30
|
|
|
<section
|
|
|
|
|
id="flagship-models"
|
|
|
|
|
ref={sectionRef}
|
|
|
|
|
className="overflow-hidden border-y border-slate-900/[0.08] bg-[#FAF8F5] py-16 sm:py-20 lg:py-24"
|
2026-11-03 16:44:13 +05:30
|
|
|
>
|
2026-11-04 11:25:57 +05:30
|
|
|
<div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
|
|
|
|
<div className="mb-8 flex flex-col gap-4 sm:mb-10 sm:flex-row sm:items-end sm:justify-between">
|
|
|
|
|
<div className="max-w-2xl">
|
|
|
|
|
<p className="eyebrow">{badge}</p>
|
|
|
|
|
<h2 className="mt-3 text-3xl font-display font-bold tracking-tight text-slate-900 sm:text-4xl lg:text-5xl">{title}</h2>
|
|
|
|
|
<p className="mt-3 text-sm leading-relaxed text-slate-600 sm:text-base">{subtitle}</p>
|
2026-11-03 16:44:13 +05:30
|
|
|
</div>
|
2026-11-04 11:25:57 +05:30
|
|
|
<p className="hidden text-xs font-medium text-slate-500 sm:block">Scroll cards vertically, swipe, or use side arrows</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-11-03 16:44:13 +05:30
|
|
|
|
2026-11-04 11:25:57 +05:30
|
|
|
<div className="relative group/showcase">
|
|
|
|
|
{/* Soft edge fades for polished visual boundary */}
|
|
|
|
|
<div
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
className={`pointer-events-none absolute left-0 top-0 bottom-0 w-12 sm:w-20 bg-gradient-to-r from-[#FAF8F5] to-transparent z-10 transition-opacity duration-300 ${
|
|
|
|
|
canScrollLeft ? 'opacity-100' : 'opacity-0'
|
|
|
|
|
}`}
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
className={`pointer-events-none absolute right-0 top-0 bottom-0 w-12 sm:w-20 bg-gradient-to-l from-[#FAF8F5] to-transparent z-10 transition-opacity duration-300 ${
|
|
|
|
|
canScrollRight ? 'opacity-100' : 'opacity-0'
|
|
|
|
|
}`}
|
|
|
|
|
/>
|
2026-11-03 17:17:02 +05:30
|
|
|
|
2026-11-04 11:25:57 +05:30
|
|
|
{/* Left Side Arrow Button (Always visible on the left side) */}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => scrollDirection('left')}
|
|
|
|
|
disabled={!canScrollLeft}
|
|
|
|
|
aria-label="Previous flagship model"
|
|
|
|
|
className={`absolute left-3 sm:left-6 lg:left-8 top-1/2 -translate-y-1/2 z-30 grid h-12 w-12 sm:h-14 sm:w-14 place-items-center rounded-full border border-slate-900/15 bg-white/95 text-slate-800 shadow-cream-md backdrop-blur-md transition-all duration-300 hover:scale-105 hover:bg-white hover:text-blue-600 hover:border-blue-400 hover:shadow-cream-lg active:scale-95 disabled:opacity-35 disabled:cursor-not-allowed disabled:hover:scale-100 disabled:hover:bg-white/95 disabled:hover:text-slate-400 disabled:hover:border-slate-900/15 disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-600`}
|
|
|
|
|
>
|
|
|
|
|
<ChevronLeft className="h-6 w-6 stroke-[2.5]" />
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
{/* Horizontal Rail */}
|
|
|
|
|
<div
|
|
|
|
|
ref={railRef}
|
|
|
|
|
className="cinematic-rail flex snap-x snap-proximity gap-5 overflow-x-auto px-4 pb-5 sm:px-6 lg:px-[max(2rem,calc((100vw-80rem)/2))]"
|
|
|
|
|
>
|
|
|
|
|
{items.map((item) => (
|
|
|
|
|
<ShowcaseCard key={item.id} item={item} />
|
|
|
|
|
))}
|
2026-11-03 16:44:13 +05:30
|
|
|
</div>
|
|
|
|
|
|
2026-11-04 11:25:57 +05:30
|
|
|
{/* Right Side Arrow Button (Always visible on the right side) */}
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => scrollDirection('right')}
|
|
|
|
|
disabled={!canScrollRight}
|
|
|
|
|
aria-label="Next flagship model"
|
|
|
|
|
className={`absolute right-3 sm:right-6 lg:right-8 top-1/2 -translate-y-1/2 z-30 grid h-12 w-12 sm:h-14 sm:w-14 place-items-center rounded-full border border-slate-900/15 bg-white/95 text-slate-800 shadow-cream-md backdrop-blur-md transition-all duration-300 hover:scale-105 hover:bg-white hover:text-blue-600 hover:border-blue-400 hover:shadow-cream-lg active:scale-95 disabled:opacity-35 disabled:cursor-not-allowed disabled:hover:scale-100 disabled:hover:bg-white/95 disabled:hover:text-slate-400 disabled:hover:border-slate-900/15 disabled:shadow-none focus:outline-none focus:ring-2 focus:ring-blue-600`}
|
|
|
|
|
>
|
|
|
|
|
<ChevronRight className="h-6 w-6 stroke-[2.5]" />
|
|
|
|
|
</button>
|
2026-11-03 16:44:13 +05:30
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-11-04 11:25:57 +05:30
|
|
|
|
|
|
|
|
function ShowcaseCard({ item }: { item: ShowcaseItem }) {
|
|
|
|
|
const comparison = item.variant !== 'banner' && item.beforeUrl && item.afterUrl;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<article className="w-[88vw] shrink-0 snap-center overflow-hidden rounded-3xl border border-slate-900/[0.09] bg-white shadow-cream-md sm:w-[680px] lg:w-[780px]">
|
|
|
|
|
<div className="grid lg:grid-cols-[1.1fr_.9fr]">
|
|
|
|
|
<div className="min-h-[280px] bg-slate-100">
|
|
|
|
|
{comparison ? (
|
|
|
|
|
<DeferredComparison
|
|
|
|
|
beforeUrl={item.beforeUrl!}
|
|
|
|
|
afterUrl={item.afterUrl!}
|
|
|
|
|
beforeLabel="Original"
|
|
|
|
|
afterLabel="CRE result"
|
|
|
|
|
aspectRatio="aspect-[4/3] lg:aspect-auto lg:h-full"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="relative h-full min-h-[280px] overflow-hidden bg-slate-950">
|
|
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img
|
|
|
|
|
src={item.bannerImage || item.beforeUrl || ''}
|
|
|
|
|
alt={item.title}
|
|
|
|
|
loading="lazy"
|
|
|
|
|
decoding="async"
|
|
|
|
|
className="h-full w-full object-cover"
|
|
|
|
|
/>
|
|
|
|
|
<div className="absolute inset-0 bg-gradient-to-t from-slate-950/70 via-transparent to-transparent" />
|
|
|
|
|
<span className="absolute left-4 top-4 rounded-full bg-white/92 px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-slate-800 shadow-sm">
|
|
|
|
|
{item.bannerBadge || item.model}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex flex-col p-6 sm:p-7">
|
|
|
|
|
<div className="flex items-center justify-between gap-3">
|
|
|
|
|
<span className="text-xs font-bold tracking-[0.16em] text-blue-700">{item.index}</span>
|
|
|
|
|
<span className="rounded-full border border-emerald-200 bg-emerald-50 px-2.5 py-1 text-[10px] font-semibold text-emerald-800">
|
|
|
|
|
{item.latency}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="mt-5 text-xs font-semibold uppercase tracking-[0.12em] text-slate-500">{item.category}</p>
|
|
|
|
|
<h3 className="mt-2 text-2xl font-display font-bold leading-tight tracking-tight text-slate-900">{item.title}</h3>
|
|
|
|
|
<p className="mt-3 text-sm leading-relaxed text-slate-600">{item.description}</p>
|
|
|
|
|
<ul className="mt-5 space-y-2.5 text-sm text-slate-700">
|
|
|
|
|
{item.specs.slice(0, 3).map((spec) => (
|
|
|
|
|
<li key={spec} className="flex gap-2">
|
|
|
|
|
<Check className="mt-0.5 h-4 w-4 shrink-0 text-blue-700" />
|
|
|
|
|
{spec}
|
|
|
|
|
</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
<div className="mt-7 flex flex-wrap gap-3">
|
|
|
|
|
<Link href={`/tools/${item.toolSlug}`} className="button-primary">
|
|
|
|
|
Try online <ArrowRight className="h-4 w-4" />
|
|
|
|
|
</Link>
|
|
|
|
|
<Link href={`/apps/${item.appSlug}`} className="button-secondary">
|
|
|
|
|
<Smartphone className="h-4 w-4" /> App
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</article>
|
|
|
|
|
);
|
|
|
|
|
}
|