fix(ui): restore tool links and reduce animation overhead
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
scroll-behavior: auto;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -202,14 +202,18 @@ export function Hero3DCanvas({ className = '' }: Hero3DCanvasProps) {
|
|||||||
observer.observe(container);
|
observer.observe(container);
|
||||||
|
|
||||||
const clock = new THREE.Clock();
|
const clock = new THREE.Clock();
|
||||||
|
let lastFrameTime = 0;
|
||||||
|
const frameInterval = prefersReducedMotion ? 1000 : 1000 / 30;
|
||||||
|
|
||||||
const animate = () => {
|
const animate = (time = 0) => {
|
||||||
if (!isVisible || !renderer) {
|
if (!isVisible || !renderer) {
|
||||||
animFrameId = 0;
|
animFrameId = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
animFrameId = requestAnimationFrame(animate);
|
animFrameId = requestAnimationFrame(animate);
|
||||||
|
if (time - lastFrameTime < frameInterval) return;
|
||||||
|
lastFrameTime = time;
|
||||||
|
|
||||||
const elapsedTime = clock.getElapsedTime();
|
const elapsedTime = clock.getElapsedTime();
|
||||||
|
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ export function HeroSection({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Kinetic3DText
|
<Kinetic3DText
|
||||||
primaryText="Make every photo"
|
primaryText={resolvedTitle}
|
||||||
highlightText="feel finished."
|
|
||||||
subtitle={resolvedSubtitle}
|
subtitle={resolvedSubtitle}
|
||||||
className="mt-7 text-left [&_h1]:text-left [&_h1]:text-[2.7rem] sm:[&_h1]:text-6xl lg:[&_h1]:text-[4.25rem] [&_h1]:leading-[1.02] [&_p]:mx-0 [&_p]:mt-5 [&_p]:max-w-lg [&_p]:text-base [&_p]:sm:text-lg"
|
className="mt-7 text-left [&_h1]:text-left [&_h1]:text-[2.7rem] sm:[&_h1]:text-6xl lg:[&_h1]:text-[4.25rem] [&_h1]:leading-[1.02] [&_p]:mx-0 [&_p]:mt-5 [&_p]:max-w-lg [&_p]:text-base [&_p]:sm:text-lg"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ function SectionContent({ section, context }: SectionRendererProps) {
|
|||||||
context={{
|
context={{
|
||||||
tools: context.tools || [],
|
tools: context.tools || [],
|
||||||
categories: context.categories || [],
|
categories: context.categories || [],
|
||||||
|
apps: context.apps || [],
|
||||||
locale,
|
locale,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -235,7 +235,6 @@ export function TryItWidget({
|
|||||||
ref={fileInputRef}
|
ref={fileInputRef}
|
||||||
type="file"
|
type="file"
|
||||||
accept="image/jpeg,image/png,image/webp"
|
accept="image/jpeg,image/png,image/webp"
|
||||||
accept="image/jpeg,image/png,image/webp"
|
|
||||||
className="hidden"
|
className="hidden"
|
||||||
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
|
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
Cpu,
|
Cpu,
|
||||||
Smartphone,
|
Smartphone,
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import { resolveLocalised, ToolItem, CategoryItem } from '@/types';
|
import { resolveLocalised, ToolItem, CategoryItem, AppItem } from '@/types';
|
||||||
import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider';
|
import { BeforeAfterSlider } from '@/components/ui/BeforeAfterSlider';
|
||||||
import { SpotlightCard } from '@/components/animate-ui/SpotlightCard';
|
import { SpotlightCard } from '@/components/animate-ui/SpotlightCard';
|
||||||
import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge';
|
import { ShimmerBadge } from '@/components/animate-ui/ShimmerBadge';
|
||||||
@@ -26,6 +26,7 @@ export interface VerticalToolStackProps {
|
|||||||
context: {
|
context: {
|
||||||
tools: ToolItem[];
|
tools: ToolItem[];
|
||||||
categories: CategoryItem[];
|
categories: CategoryItem[];
|
||||||
|
apps: AppItem[];
|
||||||
locale: string;
|
locale: string;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -70,7 +71,7 @@ const ACCENT_STYLES: Record<string, { badge: string; text: string }> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
|
export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
|
||||||
const { tools, categories, locale } = context;
|
const { tools, categories, apps, locale } = context;
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
const [selectedCategory, setSelectedCategory] = useState<string>('all');
|
||||||
|
|
||||||
const filteredCategories = selectedCategory === 'all'
|
const filteredCategories = selectedCategory === 'all'
|
||||||
@@ -185,6 +186,7 @@ export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
|
|||||||
{/* Dynamic Multi-Format Tool Cards with Alternating Layouts */}
|
{/* Dynamic Multi-Format Tool Cards with Alternating Layouts */}
|
||||||
<div className="space-y-10 sm:space-y-12">
|
<div className="space-y-10 sm:space-y-12">
|
||||||
{catTools.map((tool, toolIdx) => {
|
{catTools.map((tool, toolIdx) => {
|
||||||
|
const homeApp = apps.find((app) => app.id === tool.homeApp);
|
||||||
const badgeInfo = MODEL_BADGES[tool.id] || {
|
const badgeInfo = MODEL_BADGES[tool.id] || {
|
||||||
model: 'Neural Vision v2.0',
|
model: 'Neural Vision v2.0',
|
||||||
latency: '< 450ms',
|
latency: '< 450ms',
|
||||||
@@ -339,7 +341,7 @@ export function VerticalToolStackSection({ context }: VerticalToolStackProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
href={`/apps/${tool.homeApp}`}
|
href={homeApp ? `/apps/${homeApp.slug}` : '/apps'}
|
||||||
className="inline-flex items-center gap-1.5 px-5 py-3 rounded-full text-xs font-bold text-slate-700 bg-slate-100 border border-slate-200 hover:bg-slate-200 transition-colors"
|
className="inline-flex items-center gap-1.5 px-5 py-3 rounded-full text-xs font-bold text-slate-700 bg-slate-100 border border-slate-200 hover:bg-slate-200 transition-colors"
|
||||||
>
|
>
|
||||||
<Smartphone className="w-3.5 h-3.5 text-blue-600" />
|
<Smartphone className="w-3.5 h-3.5 text-blue-600" />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useRef, useState, useCallback } from 'react';
|
import React, { useRef, useCallback } from 'react';
|
||||||
|
|
||||||
interface Kinetic3DTextProps {
|
interface Kinetic3DTextProps {
|
||||||
primaryText: string;
|
primaryText: string;
|
||||||
@@ -15,23 +15,22 @@ export function Kinetic3DText({
|
|||||||
subtitle,
|
subtitle,
|
||||||
className = '',
|
className = '',
|
||||||
}: Kinetic3DTextProps) {
|
}: Kinetic3DTextProps) {
|
||||||
const [tilt, setTilt] = useState({ rx: 0, ry: 0, active: false });
|
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const textRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
const handleMouseMove = useCallback((e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
if (!containerRef.current) return;
|
if (!containerRef.current) return;
|
||||||
const rect = containerRef.current.getBoundingClientRect();
|
const rect = containerRef.current.getBoundingClientRect();
|
||||||
const nx = (e.clientX - rect.left) / rect.width - 0.5;
|
const nx = (e.clientX - rect.left) / rect.width - 0.5;
|
||||||
const ny = (e.clientY - rect.top) / rect.height - 0.5;
|
const ny = (e.clientY - rect.top) / rect.height - 0.5;
|
||||||
setTilt({
|
if (!textRef.current || window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
||||||
rx: Math.max(Math.min(-ny * 10, 8), -8),
|
const rx = Math.max(Math.min(-ny * 3, 2.5), -2.5);
|
||||||
ry: Math.max(Math.min(nx * 12, 10), -10),
|
const ry = Math.max(Math.min(nx * 4, 3), -3);
|
||||||
active: true,
|
textRef.current.style.transform = `perspective(1000px) rotateX(${rx}deg) rotateY(${ry}deg)`;
|
||||||
});
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleMouseLeave = useCallback(() => {
|
const handleMouseLeave = useCallback(() => {
|
||||||
setTilt({ rx: 0, ry: 0, active: false });
|
if (textRef.current) textRef.current.style.transform = 'perspective(1000px) rotateX(0deg) rotateY(0deg)';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -40,16 +39,11 @@ export function Kinetic3DText({
|
|||||||
onMouseMove={handleMouseMove}
|
onMouseMove={handleMouseMove}
|
||||||
onMouseLeave={handleMouseLeave}
|
onMouseLeave={handleMouseLeave}
|
||||||
className={`relative select-none ${className}`}
|
className={`relative select-none ${className}`}
|
||||||
style={{ perspective: 1000 }}
|
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="transition-transform duration-200 ease-out"
|
ref={textRef}
|
||||||
style={{
|
className="transition-transform duration-300 ease-out will-change-transform"
|
||||||
transform: tilt.active
|
style={{ transform: 'perspective(1000px) rotateX(0deg) rotateY(0deg)', transformStyle: 'preserve-3d' }}
|
||||||
? `rotateX(${tilt.rx.toFixed(2)}deg) rotateY(${tilt.ry.toFixed(2)}deg)`
|
|
||||||
: 'rotateX(0deg) rotateY(0deg)',
|
|
||||||
transformStyle: 'preserve-3d',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{/* Main Floating Headline (100% Visible, Crisp, Zero Disappearance) */}
|
{/* Main Floating Headline (100% Visible, Crisp, Zero Disappearance) */}
|
||||||
<h1 className="text-4xl sm:text-5xl lg:text-6xl xl:text-7xl font-display font-black text-slate-900 tracking-tight leading-[1.08] relative z-10">
|
<h1 className="text-4xl sm:text-5xl lg:text-6xl xl:text-7xl font-display font-black text-slate-900 tracking-tight leading-[1.08] relative z-10">
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ export function SectionEntrance({ children, id }: { children: React.ReactNode; i
|
|||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
data-section-entrance={id}
|
data-section-entrance={id}
|
||||||
initial={reduceMotion ? false : { opacity: 0, y: 22, filter: 'blur(5px)' }}
|
initial={reduceMotion ? false : { opacity: 0, y: 14 }}
|
||||||
whileInView={{ opacity: 1, y: 0, filter: 'blur(0px)' }}
|
whileInView={{ opacity: 1, y: 0 }}
|
||||||
viewport={{ once: true, amount: 0.12, margin: '0px 0px -48px 0px' }}
|
viewport={{ once: true, amount: 0.08, margin: '0px 0px -24px 0px' }}
|
||||||
transition={{ duration: 0.65, ease: [0.22, 1, 0.36, 1] }}
|
transition={{ duration: 0.42, ease: [0.22, 1, 0.36, 1] }}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|||||||
@@ -1,58 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect } from 'react';
|
/** Keep native browser scrolling: it is interruptible, accessible, and avoids a permanent RAF loop. */
|
||||||
import Lenis from 'lenis';
|
|
||||||
|
|
||||||
export function SmoothScroll() {
|
export function SmoothScroll() {
|
||||||
useEffect(() => {
|
|
||||||
// Check prefers-reduced-motion
|
|
||||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return;
|
|
||||||
|
|
||||||
const lenis = new Lenis({
|
|
||||||
duration: 0.75, // Extra smooth, luxurious gliding friction
|
|
||||||
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
|
||||||
orientation: 'vertical',
|
|
||||||
gestureOrientation: 'vertical',
|
|
||||||
smoothWheel: true,
|
|
||||||
syncTouch: false,
|
|
||||||
wheelMultiplier: 1.05,
|
|
||||||
touchMultiplier: 1.0,
|
|
||||||
});
|
|
||||||
|
|
||||||
let rafId: number;
|
|
||||||
function raf(time: number) {
|
|
||||||
lenis.raf(time);
|
|
||||||
rafId = requestAnimationFrame(raf);
|
|
||||||
}
|
|
||||||
|
|
||||||
rafId = requestAnimationFrame(raf);
|
|
||||||
|
|
||||||
// Smooth scroll for anchor clicks (e.g. #studio-suite, #flagship-models)
|
|
||||||
const handleAnchorClick = (e: MouseEvent) => {
|
|
||||||
const target = e.target as HTMLElement;
|
|
||||||
const anchor = target.closest('a');
|
|
||||||
if (!anchor) return;
|
|
||||||
const href = anchor.getAttribute('href');
|
|
||||||
if (href && href.startsWith('#') && href.length > 1) {
|
|
||||||
const targetEl = document.querySelector(href);
|
|
||||||
if (targetEl) {
|
|
||||||
e.preventDefault();
|
|
||||||
lenis.scrollTo(targetEl as HTMLElement, { offset: -90, duration: 0.75 });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
document.addEventListener('click', handleAnchorClick);
|
|
||||||
|
|
||||||
// Expose lenis to window for external triggers
|
|
||||||
(window as any).lenis = lenis;
|
|
||||||
|
|
||||||
return () => {
|
|
||||||
cancelAnimationFrame(rafId);
|
|
||||||
document.removeEventListener('click', handleAnchorClick);
|
|
||||||
lenis.destroy();
|
|
||||||
delete (window as any).lenis;
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user