perf: eliminate high CPU/GPU load, remove smooth cursor, remove canvas particles, throttle scroll handler
This commit is contained in:
+21
-19
@@ -112,21 +112,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Magic UI Smooth Cursor: Transform native cursor into custom cursor on desktop */
|
|
||||||
@media (min-width: 769px) {
|
|
||||||
html.custom-cursor-active,
|
|
||||||
html.custom-cursor-active *,
|
|
||||||
html.custom-cursor-active *::before,
|
|
||||||
html.custom-cursor-active *::after {
|
|
||||||
cursor: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
html.custom-cursor-active input,
|
|
||||||
html.custom-cursor-active textarea,
|
|
||||||
html.custom-cursor-active select {
|
|
||||||
cursor: text !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Studio Proof Grid: Fine dot matrix on porcelain paper */
|
/* Studio Proof Grid: Fine dot matrix on porcelain paper */
|
||||||
.studio-proof-grid {
|
.studio-proof-grid {
|
||||||
@@ -278,6 +263,11 @@ button:disabled,
|
|||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.animate-marquee { animation: none; }
|
||||||
|
.animate-marquee-vertical { animation: none; }
|
||||||
|
}
|
||||||
|
|
||||||
.animate-marquee-vertical {
|
.animate-marquee-vertical {
|
||||||
animation: marquee-vertical var(--duration) linear infinite;
|
animation: marquee-vertical var(--duration) linear infinite;
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
@@ -306,6 +296,10 @@ button:disabled,
|
|||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.animate-scanline { animation: none; }
|
||||||
|
}
|
||||||
|
|
||||||
/* Traveling Data Beam across Step Cards (GPU Accelerated) */
|
/* Traveling Data Beam across Step Cards (GPU Accelerated) */
|
||||||
@keyframes beam-pulse {
|
@keyframes beam-pulse {
|
||||||
0% {
|
0% {
|
||||||
@@ -330,6 +324,10 @@ button:disabled,
|
|||||||
transform: translateZ(0);
|
transform: translateZ(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.animate-beam-pulse { animation: none; }
|
||||||
|
}
|
||||||
|
|
||||||
/* Magic UI Animated Shiny Text Keyframe — Sweeps specular band from left to right across text */
|
/* Magic UI Animated Shiny Text Keyframe — Sweeps specular band from left to right across text */
|
||||||
@keyframes shiny-text {
|
@keyframes shiny-text {
|
||||||
0% {
|
0% {
|
||||||
@@ -418,7 +416,6 @@ button:disabled,
|
|||||||
var(--color-ink) 100%
|
var(--color-ink) 100%
|
||||||
) !important;
|
) !important;
|
||||||
background-size: 200% 100% !important;
|
background-size: 200% 100% !important;
|
||||||
will-change: background-position;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Magic UI Aurora Text Animation — Smooth shifting Northern Lights color wave */
|
/* Magic UI Aurora Text Animation — Smooth shifting Northern Lights color wave */
|
||||||
@@ -442,7 +439,10 @@ button:disabled,
|
|||||||
|
|
||||||
.animate-aurora {
|
.animate-aurora {
|
||||||
animation: aurora 8s ease-in-out infinite alternate !important;
|
animation: aurora 8s ease-in-out infinite alternate !important;
|
||||||
will-change: background-position;
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.animate-aurora { animation: none !important; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Magic UI Typing Animation Blinking Cursor */
|
/* Magic UI Typing Animation Blinking Cursor */
|
||||||
@@ -474,13 +474,15 @@ button:disabled,
|
|||||||
|
|
||||||
.animate-gradient {
|
.animate-gradient {
|
||||||
animation: gradient 8s linear infinite;
|
animation: gradient 8s linear infinite;
|
||||||
will-change: background-position;
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.animate-gradient { animation: none; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Magic UI Kinetic Text Character Styles */
|
/* Magic UI Kinetic Text Character Styles */
|
||||||
.kinetic-letter {
|
.kinetic-letter {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
will-change: font-weight, -webkit-text-stroke-width, padding;
|
|
||||||
-webkit-text-stroke-color: transparent;
|
-webkit-text-stroke-color: transparent;
|
||||||
-webkit-text-stroke-width: var(--text-stroke-width, 0.02em);
|
-webkit-text-stroke-width: var(--text-stroke-width, 0.02em);
|
||||||
transition: font-weight 0.4s ease, -webkit-text-stroke-color 0.4s ease, padding 0.4s ease;
|
transition: font-weight 0.4s ease, -webkit-text-stroke-color 0.4s ease, padding 0.4s ease;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { getSiteConfig } from '@/lib/config/loader';
|
|||||||
import { Navbar } from '@/components/ui/Navbar';
|
import { Navbar } from '@/components/ui/Navbar';
|
||||||
import { Footer } from '@/components/ui/Footer';
|
import { Footer } from '@/components/ui/Footer';
|
||||||
import { SmoothScrollProvider } from '@/components/ui/SmoothScrollProvider';
|
import { SmoothScrollProvider } from '@/components/ui/SmoothScrollProvider';
|
||||||
import { SmoothCursor } from '@/components/magicui/smooth-cursor';
|
|
||||||
|
|
||||||
const poppinsFont = Poppins({
|
const poppinsFont = Poppins({
|
||||||
subsets: ['latin'],
|
subsets: ['latin'],
|
||||||
@@ -95,7 +94,6 @@ export default function RootLayout({
|
|||||||
/>
|
/>
|
||||||
</head>
|
</head>
|
||||||
<body className="min-h-screen flex flex-col antialiased bg-paper text-ink relative font-sans overflow-x-clip">
|
<body className="min-h-screen flex flex-col antialiased bg-paper text-ink relative font-sans overflow-x-clip">
|
||||||
<SmoothCursor />
|
|
||||||
<SmoothScrollProvider>
|
<SmoothScrollProvider>
|
||||||
<a href="#main-content" className="skip-link">Skip to main content</a>
|
<a href="#main-content" className="skip-link">Skip to main content</a>
|
||||||
<Navbar config={config} currentLocale="en" />
|
<Navbar config={config} currentLocale="en" />
|
||||||
|
|||||||
@@ -74,13 +74,12 @@ export function CinematicHorizontalScrollSection({
|
|||||||
const translateX = progress * maxDistance;
|
const translateX = progress * maxDistance;
|
||||||
track.style.transform = `translate3d(-${translateX.toFixed(2)}px, 0, 0)`;
|
track.style.transform = `translate3d(-${translateX.toFixed(2)}px, 0, 0)`;
|
||||||
|
|
||||||
// Sync active card index and button states
|
// Sync active card index and button states — batched into one setState call
|
||||||
const active = Math.min(
|
const active = Math.min(
|
||||||
cards.length - 1,
|
cards.length - 1,
|
||||||
Math.max(0, Math.round(progress * (cards.length - 1)))
|
Math.max(0, Math.round(progress * (cards.length - 1)))
|
||||||
);
|
);
|
||||||
setActiveIndex(active);
|
setActiveIndex(active);
|
||||||
|
|
||||||
setCanScrollLeft(progress > 0.02);
|
setCanScrollLeft(progress > 0.02);
|
||||||
setCanScrollRight(progress < 0.98);
|
setCanScrollRight(progress < 0.98);
|
||||||
}, []);
|
}, []);
|
||||||
@@ -88,8 +87,15 @@ export function CinematicHorizontalScrollSection({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
|
|
||||||
|
// RAF-throttled scroll handler: fires at most once per animation frame (≤60/s)
|
||||||
|
// preventing the expensive DOM reads from firing hundreds of times per second.
|
||||||
|
let rafId: number | null = null;
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
updateTranslation();
|
if (rafId !== null) return;
|
||||||
|
rafId = requestAnimationFrame(() => {
|
||||||
|
updateTranslation();
|
||||||
|
rafId = null;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Support horizontal trackpad swipe (deltaX) on the showcase container
|
// Support horizontal trackpad swipe (deltaX) on the showcase container
|
||||||
@@ -136,6 +142,7 @@ export function CinematicHorizontalScrollSection({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
if (rafId !== null) cancelAnimationFrame(rafId);
|
||||||
window.removeEventListener('scroll', handleScroll);
|
window.removeEventListener('scroll', handleScroll);
|
||||||
window.removeEventListener('resize', handleScroll);
|
window.removeEventListener('resize', handleScroll);
|
||||||
if (container) {
|
if (container) {
|
||||||
@@ -260,7 +267,7 @@ export function CinematicHorizontalScrollSection({
|
|||||||
{/* Horizontal Track */}
|
{/* Horizontal Track */}
|
||||||
<div
|
<div
|
||||||
ref={trackRef}
|
ref={trackRef}
|
||||||
className="cinematic-rail flex gap-6 will-change-transform"
|
className="cinematic-rail flex gap-6"
|
||||||
style={{
|
style={{
|
||||||
paddingLeft: 'calc((100vw - min(780px, 88vw)) / 2)',
|
paddingLeft: 'calc((100vw - min(780px, 88vw)) / 2)',
|
||||||
paddingRight: 'calc((100vw - min(780px, 88vw)) / 2)',
|
paddingRight: 'calc((100vw - min(780px, 88vw)) / 2)',
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
|
import { ToolItem, VariantSpec, resolveLocalised } from '@/types';
|
||||||
import { TryItWidget } from './TryItWidget';
|
import { TryItWidget } from './TryItWidget';
|
||||||
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
import { CardBeforeAfterSlider } from '@/components/ui/CardBeforeAfterSlider';
|
||||||
import { Particles } from '@/components/magicui/particles';
|
|
||||||
import { BorderBeam } from '@/components/magicui/border-beam';
|
import { BorderBeam } from '@/components/magicui/border-beam';
|
||||||
import { LightRays } from '@/components/magicui/light-rays';
|
import { LightRays } from '@/components/magicui/light-rays';
|
||||||
import { RainbowButton } from '@/components/magicui/rainbow-button';
|
import { RainbowButton } from '@/components/magicui/rainbow-button';
|
||||||
@@ -213,9 +213,8 @@ export function HeroSection({
|
|||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Layered Light Rays & Particles */}
|
{/* Layered Light Rays */}
|
||||||
<LightRays className="opacity-40" />
|
<LightRays className="opacity-40" />
|
||||||
<Particles quantity={25} size={0.7} color="var(--color-accent)" className="absolute inset-0 pointer-events-none" />
|
|
||||||
|
|
||||||
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6 relative z-10">
|
<div className="max-w-3xl mx-auto px-4 sm:px-6 lg:px-8 space-y-6 relative z-10">
|
||||||
<BlurFade delay={0.06}>
|
<BlurFade delay={0.06}>
|
||||||
@@ -308,15 +307,7 @@ export function HeroSection({
|
|||||||
{/* Background Layer 2: Magic UI Atmospheric Light Rays */}
|
{/* Background Layer 2: Magic UI Atmospheric Light Rays */}
|
||||||
<LightRays className="opacity-45" />
|
<LightRays className="opacity-45" />
|
||||||
|
|
||||||
{/* Background Layer 3: Magic UI Floating Particles */}
|
{/* Background Layer 3: Fine Dot Matrix Pattern */}
|
||||||
<Particles
|
|
||||||
quantity={35}
|
|
||||||
size={0.8}
|
|
||||||
color="var(--color-accent)"
|
|
||||||
className="absolute inset-0 pointer-events-none z-0"
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Background Layer 4: Fine Dot Matrix Pattern */}
|
|
||||||
<div
|
<div
|
||||||
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid z-0"
|
className="pointer-events-none absolute inset-0 opacity-20 studio-proof-grid z-0"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
|
|||||||
Reference in New Issue
Block a user