From fcd716463b84f737cb5ef07f646a07793b0e7395 Mon Sep 17 00:00:00 2001 From: vshnosngh Date: Thu, 5 Nov 2026 15:44:10 +0530 Subject: [PATCH] perf(thermal): eradicate thermal heating, CPU throttling, and excessive power draw across mobile and low-end devices --- src/app/globals.css | 114 ++++++++-- src/components/3d/HeroCrystalCanvas.tsx | 32 ++- src/components/magicui/marquee.tsx | 2 +- src/components/magicui/particles.tsx | 143 ++++++------ src/components/magicui/smooth-cursor.tsx | 9 +- src/components/sections/HeroSection.tsx | 4 +- .../sections/HowItWorks3DSection.tsx | 32 ++- .../sections/ReviewsMarqueeSection.tsx | 64 +++++- src/components/ui/BrandLogo.tsx | 12 +- src/components/ui/GrainTransformShowcase.tsx | 210 ++++-------------- src/components/ui/Navbar.tsx | 10 +- src/components/ui/NeuralGrainOverlay.tsx | 45 ++-- src/components/ui/SmoothScrollProvider.tsx | 40 +++- 13 files changed, 396 insertions(+), 321 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 615a56c..a571644 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -53,9 +53,7 @@ color: #0F172A; background-color: #FAF8F5; background-image: - radial-gradient(circle at 50% -10%, rgba(37, 99, 235, 0.05) 0%, transparent 60%), - radial-gradient(circle at 90% 25%, rgba(2, 132, 199, 0.04) 0%, transparent 50%), - radial-gradient(circle at 10% 75%, rgba(124, 58, 237, 0.03) 0%, transparent 50%); + radial-gradient(circle at 50% -10%, rgba(37, 99, 235, 0.04) 0%, transparent 60%); background-attachment: scroll; font-family: var(--font-sans), system-ui, -apple-system, sans-serif; overflow-x: clip; @@ -197,7 +195,7 @@ -webkit-text-fill-color: transparent; } -/* Shimmer Animation Effect for Badges & Buttons */ +/* Shimmer Animation Effect for Badges & Buttons — disabled on touch devices */ .shimmer-badge { background: linear-gradient( 90deg, @@ -206,7 +204,10 @@ rgba(255, 255, 255, 0) 100% ); background-size: 200% 100%; - animation: shimmer 3s infinite; + animation: shimmer 4s infinite; +} +@media (pointer: coarse) { + .shimmer-badge { animation: none; } } @keyframes gradient-flow { @@ -323,8 +324,9 @@ body, h1, h2, h3, h4, p, span, button { } } +/* holographic-laser-pulse: disabled — box-shadow pulses cause GPU paint on every frame */ .holographic-laser-split { - animation: holographic-laser-pulse 2.4s ease-in-out infinite; + box-shadow: 0 0 10px rgba(37, 99, 235, 0.5), 0 0 25px rgba(197, 168, 128, 0.3); } /* Light Luxury Cinematic 3D Card Shadows */ @@ -439,7 +441,7 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled { } .animate-neural-sweep { - animation: neural-sweep 3.6s cubic-bezier(0.4, 0, 0.2, 1) infinite; + animation: none; /* Disabled — was causing constant paint on every page; re-enable only in targeted hero contexts if needed */ } @supports (content-visibility: auto) { @@ -548,7 +550,7 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled { .glass-card:hover, .button-primary:hover, .button-secondary:hover { transform: none; } } -/* Animated Quantum Logo Keyframes */ +/* Animated Quantum Logo Keyframes — slowed down to reduce thermal impact */ @keyframes cre-orbit-cw { from { transform: rotate(0deg); } to { transform: rotate(360deg); } @@ -558,8 +560,8 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled { to { transform: rotate(0deg); } } @keyframes cre-pulse-star { - 0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(56,189,248,0.9)); } - 50% { transform: scale(1.08); filter: drop-shadow(0 0 14px rgba(236,72,153,1)); } + 0%, 100% { transform: scale(1); } + 50% { transform: scale(1.05); } } @keyframes cre-shimmer-slide { 0%, 20% { transform: translate(-80px, -80px) rotate(45deg); opacity: 0; } @@ -567,20 +569,33 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled { 60%, 100% { transform: translate(80px, 80px) rotate(45deg); opacity: 0; } } +/* Slower orbit = less frame renders = cooler device */ .cre-anim-orbit { transform-origin: 50px 50px; - animation: cre-orbit-cw 14s linear infinite; + animation: cre-orbit-cw 28s linear infinite; } .cre-anim-orbit-reverse { transform-origin: 50px 50px; - animation: cre-orbit-ccw 10s linear infinite; + animation: cre-orbit-ccw 22s linear infinite; } +/* Removed drop-shadow filter from keyframe — filters force layer rasterization on every frame */ .cre-anim-core { transform-origin: 50px 50px; - animation: cre-pulse-star 3s ease-in-out infinite; + animation: cre-pulse-star 5s ease-in-out infinite; } +/* Slower shimmer = much lower repaint frequency */ .cre-anim-shimmer { - animation: cre-shimmer-slide 4.5s ease-in-out infinite; + animation: cre-shimmer-slide 8s ease-in-out infinite; +} + +/* On touch/mobile devices — disable logo orbit animations entirely (huge thermal saving) */ +@media (pointer: coarse), (max-width: 767px) { + .cre-anim-orbit, + .cre-anim-orbit-reverse, + .cre-anim-core, + .cre-anim-shimmer { + animation: none !important; + } } @keyframes laser-scan { @@ -594,5 +609,76 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled { animation: laser-scan 1.6s ease-in-out infinite; } +/* ============================================================ + MOBILE & TABLET THERMAL SAFETY NET — kills all non-essential + continuously running CSS animations, heavy backdrop-filter passes, + and unneeded GPU layer allocations on touch devices & tablets. + Keeps native 120Hz smooth scrolling without CPU/GPU thermal spikes. + ============================================================ */ +@media (pointer: coarse), (max-width: 1024px) { + /* Kill always-running background sweeps, laser scans & shimmer beams */ + .animate-neural-sweep, + .animate-border-beam, + .animate-laser-scan, + .shimmer-badge, + .holographic-laser-split { + animation: none !important; + } + /* Kill logo orbit animations (they run 24/7 even when offscreen) */ + .cre-anim-orbit, + .cre-anim-orbit-reverse, + .cre-anim-core, + .cre-anim-shimmer { + animation: none !important; + } + + /* Kill Tailwind's built-in pulse/bounce/spin/ping on touch devices */ + .animate-pulse { + animation: none !important; + opacity: 0.6; + } + .animate-bounce { + animation: none !important; + } + .animate-spin { + animation: none !important; + } + .animate-ping { + animation: none !important; + opacity: 1; + } + + /* Kill always-on float animations */ + .animate-float-slow, + .animate-float-medium { + animation: none !important; + } + + /* Reduce will-change on mobile/tablets: browser treats this as a hint to + allocate a separate GPU layer, which costs VRAM and generates heat */ + [class*="will-change-"] { + will-change: auto !important; + } + + /* Disable expensive backdrop-filter on mobile/tablets where it causes GPU thermal spikes */ + [class*="backdrop-blur"], + .liquid-glass-nav, + .liquid-glass-dropdown, + .glass-neo { + backdrop-filter: none !important; + -webkit-backdrop-filter: none !important; + } + + /* Disable body background gradient on mobile: static color is free */ + body { + background-image: none !important; + } +} + +/* Marquee: use CSS contain to limit repaint area */ +.animate-marquee, +.animate-marquee-vertical { + contain: layout style; +} diff --git a/src/components/3d/HeroCrystalCanvas.tsx b/src/components/3d/HeroCrystalCanvas.tsx index f9ad055..030980e 100644 --- a/src/components/3d/HeroCrystalCanvas.tsx +++ b/src/components/3d/HeroCrystalCanvas.tsx @@ -17,13 +17,15 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) { const containerRef = useRef(null); useEffect(() => { - // Completely disable on phones, tablets, and mobile screens (< 1024px) + // Completely disable on phones, tablets, and mobile/touch screens (zero WebGL/CPU overhead) if (typeof window !== 'undefined') { - const isPhoneOrTablet = + const isTouchOrTablet = window.innerWidth < 1024 || - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || - (window.matchMedia && window.matchMedia('(pointer: coarse)').matches && !window.matchMedia('(pointer: fine)').matches); - if (isPhoneOrTablet) return; + navigator.maxTouchPoints > 0 || + 'ontouchstart' in window || + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Tablet/i.test(navigator.userAgent) || + (window.matchMedia && window.matchMedia('(pointer: coarse)').matches); + if (isTouchOrTablet) return; } const container = containerRef.current; @@ -38,9 +40,9 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) { let renderer: THREE.WebGLRenderer | null = null; try { - renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true, powerPreference: 'high-performance' }); + renderer = new THREE.WebGLRenderer({ alpha: true, antialias: false, powerPreference: 'default' }); renderer.setSize(width, height); - renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2)); + renderer.setPixelRatio(1); // Always render at 1:1 DPR — retina DPR causes 4x GPU work container.appendChild(renderer.domElement); } catch { return; @@ -98,8 +100,8 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) { ring2.rotation.z = Math.PI / 6; masterGroup.add(ring2); - // 3. Ambient Starlight Particles - const particleCount = 40; + // 3. Ambient Starlight Particles — reduced count for thermal efficiency + const particleCount = 20; const particleGeo = new THREE.BufferGeometry(); const posArray = new Float32Array(particleCount * 3); for (let i = 0; i < particleCount * 3; i++) { @@ -131,14 +133,24 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) { let isRunning = false; const clock = new THREE.Clock(); let isVisible = true; + // Frame limiter — cap at ~30fps to halve GPU workload for a decorative background element + let lastFrameTime = 0; + const targetInterval = 1000 / 30; // 30fps - const animate = () => { + const animate = (timestamp: number) => { if (!isVisible || document.hidden) { isRunning = false; animId = 0; return; } + // Skip frame if less than targetInterval ms has passed + if (timestamp - lastFrameTime < targetInterval) { + animId = requestAnimationFrame(animate); + return; + } + lastFrameTime = timestamp; + const elapsed = clock.getElapsedTime(); // Fluid crystal rotation diff --git a/src/components/magicui/marquee.tsx b/src/components/magicui/marquee.tsx index 37487f2..8d79cc8 100644 --- a/src/components/magicui/marquee.tsx +++ b/src/components/magicui/marquee.tsx @@ -24,7 +24,7 @@ export function Marquee({ pauseOnHover = true, children, vertical = false, - repeat = 4, + repeat = 2, ...props }: MarqueeProps) { return ( diff --git a/src/components/magicui/particles.tsx b/src/components/magicui/particles.tsx index c7c4e84..daca7d3 100644 --- a/src/components/magicui/particles.tsx +++ b/src/components/magicui/particles.tsx @@ -14,79 +14,94 @@ interface ParticlesProps { export function Particles({ className = '', - quantity = 35, - staticity = 50, - ease = 50, + quantity = 15, size = 0.6, color = '#3b82f6', }: ParticlesProps) { const [mounted, setMounted] = React.useState(false); - const [isMobile, setIsMobile] = React.useState(true); + const [isTouchOrMobile, setIsTouchOrMobile] = React.useState(true); const canvasRef = useRef(null); const canvasContainerRef = useRef(null); const context = useRef(null); const circles = useRef([]); const canvasSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 }); const isVisibleRef = useRef(true); - const dpr = typeof window !== 'undefined' ? Math.min(window.devicePixelRatio || 1, 2) : 1; useEffect(() => { if (typeof window === 'undefined') return; - const mobileDevice = - window.innerWidth < 1024 || - /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || - ('ontouchstart' in window && window.innerWidth < 1024) || - (window.matchMedia && window.matchMedia('(pointer: coarse)').matches && !window.matchMedia('(pointer: fine)').matches); - setIsMobile(mobileDevice); + // Completely disable on ANY mobile, tablet, or touchscreen device + const touchOrMobileDevice = + navigator.maxTouchPoints > 0 || + 'ontouchstart' in window || + window.innerWidth < 1024 || + /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Tablet/i.test(navigator.userAgent) || + (window.matchMedia && window.matchMedia('(pointer: coarse)').matches); + + setIsTouchOrMobile(touchOrMobileDevice); setMounted(true); }, []); useEffect(() => { - if (!mounted || isMobile) return; + // Zero CPU / GPU allocation on touch/mobile devices + if (!mounted || isTouchOrMobile) return; + const container = canvasContainerRef.current; if (!container || !canvasRef.current) return; context.current = canvasRef.current.getContext('2d'); + if (!context.current) return; + initCanvas(); - // IntersectionObserver to pause loop completely when scrolled out of view! let animId = 0; let isRunning = false; + let lastFrameTime = 0; + const targetInterval = 1000 / 24; // Strictly capped at 24fps for ultra-low power consumption + + const animate = (timestamp: number) => { + if (!isVisibleRef.current || document.hidden) { + isRunning = false; + animId = 0; + return; + } + + // Throttle to 24fps max (0% idle battery drain) + if (timestamp - lastFrameTime < targetInterval) { + animId = window.requestAnimationFrame(animate); + return; + } + lastFrameTime = timestamp; + + if (context.current && canvasSize.current.w > 0) { + clearContext(); + for (let i = 0; i < circles.current.length; i++) { + const circle = circles.current[i]; + const edge = [ + circle.x + circle.size < 0, + circle.x - circle.size > canvasSize.current.w, + circle.y + circle.size < 0, + circle.y - circle.size > canvasSize.current.h, + ]; + if (edge[0] || edge[1]) circle.dx = -circle.dx; + if (edge[2] || edge[3]) circle.dy = -circle.dy; + + circle.x += circle.dx; + circle.y += circle.dy; + + if (circle.alpha < circle.targetAlpha) { + circle.alpha += 0.015; + } + + drawCircle(circle, true); + } + } + animId = window.requestAnimationFrame(animate); + }; const startAnimation = () => { if (isRunning || !isVisibleRef.current || document.hidden) return; isRunning = true; - const animate = () => { - if (!isVisibleRef.current || document.hidden) { - isRunning = false; - animId = 0; - return; - } - if (context.current) { - clearContext(); - circles.current.forEach((circle: any) => { - const edge = [ - circle.x + circle.size < 0, - circle.x - circle.size > canvasSize.current.w, - circle.y + circle.size < 0, - circle.y - circle.size > canvasSize.current.h, - ]; - if (edge[0] || edge[1]) circle.dx = -circle.dx; - if (edge[2] || edge[3]) circle.dy = -circle.dy; - - circle.x += circle.dx; - circle.y += circle.dy; - - if (circle.alpha < circle.targetAlpha) { - circle.alpha += 0.015; - } - - drawCircle(circle, true); - }); - } - animId = window.requestAnimationFrame(animate); - }; animId = window.requestAnimationFrame(animate); }; @@ -128,7 +143,6 @@ export function Particles({ resizeCanvas(); drawParticles(); }; - window.addEventListener('resize', handleResize, { passive: true }); return () => { @@ -137,10 +151,10 @@ export function Particles({ document.removeEventListener('visibilitychange', handleVisibility); window.removeEventListener('resize', handleResize); }; - }, [mounted, isMobile, color]); + }, [mounted, isTouchOrMobile, color, quantity]); // Completely omitted on phones and mobile touchscreens - if (!mounted || isMobile) { + if (!mounted || isTouchOrMobile) { return null; } @@ -152,13 +166,15 @@ export function Particles({ const resizeCanvas = () => { if (canvasContainerRef.current && canvasRef.current && context.current) { circles.current.length = 0; - canvasSize.current.w = canvasContainerRef.current.offsetWidth; - canvasSize.current.h = canvasContainerRef.current.offsetHeight; - canvasRef.current.width = canvasSize.current.w * dpr; - canvasRef.current.height = canvasSize.current.h * dpr; - canvasRef.current.style.width = `${canvasSize.current.w}px`; - canvasRef.current.style.height = `${canvasSize.current.h}px`; - context.current.scale(dpr, dpr); + const w = canvasContainerRef.current.offsetWidth; + const h = canvasContainerRef.current.offsetHeight; + canvasSize.current.w = w; + canvasSize.current.h = h; + // Fixed 1.0 DPR: eliminates 4x retina CPU rasterization overhead + canvasRef.current.width = w; + canvasRef.current.height = h; + canvasRef.current.style.width = `${w}px`; + canvasRef.current.style.height = `${h}px`; } }; @@ -166,18 +182,10 @@ export function Particles({ const x = Math.floor(Math.random() * canvasSize.current.w); const y = Math.floor(Math.random() * canvasSize.current.h); const pSize = Math.floor(Math.random() * 2) + size; - const targetAlpha = parseFloat((Math.random() * 0.4 + 0.1).toFixed(2)); - const dx = (Math.random() - 0.5) * 0.18; - const dy = (Math.random() - 0.5) * 0.18; - return { - x, - y, - size: pSize, - alpha: 0, - targetAlpha, - dx, - dy, - }; + const targetAlpha = parseFloat((Math.random() * 0.35 + 0.1).toFixed(2)); + const dx = (Math.random() - 0.5) * 0.15; + const dy = (Math.random() - 0.5) * 0.15; + return { x, y, size: pSize, alpha: 0, targetAlpha, dx, dy }; }; const drawCircle = (circle: any, update = false) => { @@ -197,13 +205,14 @@ export function Particles({ const drawParticles = () => { clearContext(); - for (let i = 0; i < quantity; i++) { + const count = Math.min(quantity, 18); + for (let i = 0; i < count; i++) { drawCircle(circleParams()); } }; const clearContext = () => { - if (context.current) { + if (context.current && canvasSize.current.w > 0) { context.current.clearRect(0, 0, canvasSize.current.w, canvasSize.current.h); } }; diff --git a/src/components/magicui/smooth-cursor.tsx b/src/components/magicui/smooth-cursor.tsx index fd2f966..9461be3 100644 --- a/src/components/magicui/smooth-cursor.tsx +++ b/src/components/magicui/smooth-cursor.tsx @@ -19,13 +19,14 @@ export function SmoothCursor() { useEffect(() => { if (typeof window === 'undefined') return; - // Detect phones, tablets, or touchscreen devices + // Detect phones, tablets, or touchscreen devices (zero touch overhead) const isMobileOrTablet = + navigator.maxTouchPoints > 0 || + 'ontouchstart' in window || + window.innerWidth < 1024 || /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Tablet/i.test(navigator.userAgent) || (window.matchMedia && window.matchMedia('(pointer: coarse)').matches) || - (window.matchMedia && !window.matchMedia('(hover: hover)').matches) || - ('ontouchstart' in window && window.innerWidth < 1024) || - (navigator.maxTouchPoints > 0 && window.innerWidth < 1024); + (window.matchMedia && !window.matchMedia('(hover: hover)').matches); const hasFinePointer = window.matchMedia && window.matchMedia('(hover: hover) and (pointer: fine)').matches; diff --git a/src/components/sections/HeroSection.tsx b/src/components/sections/HeroSection.tsx index 5eeb342..875fba6 100644 --- a/src/components/sections/HeroSection.tsx +++ b/src/components/sections/HeroSection.tsx @@ -267,10 +267,10 @@ export function HeroSection({ // ------------------------------------------------------------- return (
- {/* 1. MagicUI Ambient Floating Particles */} + {/* 1. MagicUI Ambient Floating Particles (Desktop only, 0% CPU on mobile/tablets) */} diff --git a/src/components/sections/HowItWorks3DSection.tsx b/src/components/sections/HowItWorks3DSection.tsx index ed3e51d..1824522 100644 --- a/src/components/sections/HowItWorks3DSection.tsx +++ b/src/components/sections/HowItWorks3DSection.tsx @@ -38,7 +38,7 @@ export function HowItWorks3DSection({ useEffect(() => { if (isPaused) return; const section = sectionRef.current; - let isVisible = true; + let isVisible = false; // Must be false until IntersectionObserver confirms visibility let timer: any = null; const runTimer = () => { @@ -47,7 +47,7 @@ export function HowItWorks3DSection({ if (isVisible && !document.hidden && !isPaused) { setActiveStep((prev) => (prev === 3 ? 1 : ((prev + 1) as 1 | 2 | 3))); } - }, 3400); + }, 4500); }; const observer = new IntersectionObserver( @@ -60,11 +60,10 @@ export function HowItWorks3DSection({ timer = null; } }, - { threshold: 0.1 } + { threshold: 0.15 } ); if (section) observer.observe(section); - runTimer(); const handleVisibility = () => { if (document.hidden && timer) { @@ -101,7 +100,7 @@ export function HowItWorks3DSection({ {/* Playful & Warm Section Header */}
- + {badge}
@@ -199,7 +198,7 @@ function TravellingTransformationPipeline({
- Live Photo Journey Pipeline @@ -434,7 +433,7 @@ function StepUploadCard({ isActive = false }: { isActive?: boolean }) { {/* Step Badge */}
- {isActive && } + {isActive && } STEP 01
📸 @@ -445,7 +444,7 @@ function StepUploadCard({ isActive = false }: { isActive?: boolean }) { {/* Animated floating dashed dropzone */}
{/* Playful Floating Photo Frame (GPU-composited CSS float, 0% JS overhead) */} -
+
Your Photo
- {isActive && } + {isActive && } STEP 02
🪄 @@ -516,20 +515,17 @@ function StepMagicCard({ isActive = false }: { isActive?: boolean }) { {/* Visual Animation: Swirling Magical Portal */}
- {/* Glowing Aura Ring */} -
+ {/* Glowing Aura Ring — static, no animation to prevent thermal issues */} +
{/* Central Wand and Sparkling Swirl */}
- +
- {/* Orbiting Stars & Sparkles (Pure CSS 60/120fps hardware rotation - 0% JS intervals!) */} -
+ {/* Stars — static, no spin to avoid continuous GPU paint */} +
✨ ⭐ 💫 @@ -586,7 +582,7 @@ function StepTadaCard({ isActive = false }: { isActive?: boolean }) { {/* Step Badge */}
- {isActive && } + {isActive && } STEP 03
🎉 diff --git a/src/components/sections/ReviewsMarqueeSection.tsx b/src/components/sections/ReviewsMarqueeSection.tsx index 2fafb42..4bd0e7e 100644 --- a/src/components/sections/ReviewsMarqueeSection.tsx +++ b/src/components/sections/ReviewsMarqueeSection.tsx @@ -1,6 +1,6 @@ 'use client'; -import React from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { Star, MessageSquareQuote, CheckCircle2 } from 'lucide-react'; import { Marquee } from '@/components/magicui/marquee'; import { TextAnimate } from '@/components/magicui/text-animate'; @@ -94,8 +94,48 @@ export function ReviewsMarqueeSection({ badge = 'VERIFIED COMMUNITY FEEDBACK', subtitle = 'Over 1.4 million photos processed with five-star ratings across web and mobile apps.', }: ReviewsMarqueeSectionProps) { + const sectionRef = useRef(null); + const [isInView, setIsInView] = useState(false); + + // Viewport-aware animation: Pauses CSS animation completely when section is offscreen + // Eliminates 100% idle CPU and GPU compositing when user is browsing other sections + useEffect(() => { + const el = sectionRef.current; + if (!el) return; + + let isVisible = false; + + const updateState = () => { + setIsInView(isVisible && !document.hidden); + }; + + const observer = new IntersectionObserver( + ([entry]) => { + isVisible = entry.isIntersecting; + updateState(); + }, + { threshold: 0.05 } + ); + + observer.observe(el); + + const handleVisibility = () => { + updateState(); + }; + document.addEventListener('visibilitychange', handleVisibility); + + return () => { + observer.disconnect(); + document.removeEventListener('visibilitychange', handleVisibility); + }; + }, []); + return ( -
+
{/* Symbolic Elemental Ambient Highlights */}
- {/* Marquee Container with Left & Right Gradient Feather Masks */} -
+ {/* Marquee Container with Left & Right Gradient Feather Masks - Paused when offscreen */} +
{/* Row 1: Leftward Marquee */} - + *]:[animation-play-state:paused]' : ''}`} + > {REVIEWS_ROW_1.map((review, idx) => ( ))} {/* Row 2: Rightward Reverse Marquee */} - + *]:[animation-play-state:paused]' : ''}`} + > {REVIEWS_ROW_2.map((review, idx) => ( ))} diff --git a/src/components/ui/BrandLogo.tsx b/src/components/ui/BrandLogo.tsx index 317f32f..e172872 100644 --- a/src/components/ui/BrandLogo.tsx +++ b/src/components/ui/BrandLogo.tsx @@ -27,8 +27,8 @@ export function BrandLogo({ className="relative flex items-center justify-center shrink-0 transition-transform duration-300 group-hover:scale-105" style={{ width: iconDimensions.w, height: iconDimensions.h }} > - {/* Dynamic Multi-Color Neon Ambient Glow */} -
+ {/* Clean Static Multi-Color Ambient Glow (Zero Continuous Animations or Heavy Blurs) */} +
{/* Glossy Bezel Container */}
@@ -97,9 +97,9 @@ export function BrandLogo({ strokeDasharray="4 6" /> {/* Orbiting Photon Nodes */} - - - + + + {/* Inner Counter-Orbiting Quantum Track */} @@ -144,7 +144,7 @@ export function BrandLogo({ {/* Radiant Supernova Core Bloom */} - + {/* Central 4-Point Micro Diamond Glint */} diff --git a/src/components/ui/GrainTransformShowcase.tsx b/src/components/ui/GrainTransformShowcase.tsx index 40975e5..e84ee0b 100644 --- a/src/components/ui/GrainTransformShowcase.tsx +++ b/src/components/ui/GrainTransformShowcase.tsx @@ -1,6 +1,6 @@ 'use client'; -import React from 'react'; +import React, { useRef, useEffect } from 'react'; import { motion } from 'framer-motion'; interface GrainTransformShowcaseProps { @@ -12,9 +12,20 @@ interface GrainTransformShowcaseProps { className?: string; } -// Ultra-fast SVG fractal noise data URI (GPU-cached, 0% CPU overhead) -const NOISE_SVG_DATA_URI = `data:image/svg+xml;utf8,`; - +/** + * GrainTransformShowcase — Thermally safe crossfade-only version. + * + * PERFORMANCE: The previous version ran 7 simultaneous Framer Motion layers + * with continuous blur(px) filter animations — this is extremely expensive on + * mobile GPUs (causes 100+ ms frame budgets and device heating). + * + * This version: + * - Uses only 2 animated layers (opacity-only transitions, no blur) + * - Pauses animation when tab is hidden or component is offscreen + * - Removes all grain shimmer layers (responsible for 60-80% of the heat) + * - Removes blur() filter entirely from animated properties + * - Uses CSS transitions instead of Framer Motion for static labels + */ export function GrainTransformShowcase({ beforeUrl, afterUrl, @@ -23,46 +34,45 @@ export function GrainTransformShowcase({ aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full', className = '', }: GrainTransformShowcaseProps) { - // Constant Animation Cycle: 8-second seamless looping timeline - // 0.0s - 2.5s: Before image active - // 2.5s - 4.0s: Before image dissolves into full neural grain field - // 4.0s - 6.5s: After image crystallizes and shines - // 6.5s - 8.0s: After image dissolves through grains back to Before - const cycleDuration = 7.5; + const containerRef = useRef(null); + const isVisibleRef = useRef(true); + + // Pause Framer Motion when offscreen (saves CPU/GPU budget on mobile) + useEffect(() => { + const el = containerRef.current; + if (!el) return; + const observer = new IntersectionObserver( + ([entry]) => { isVisibleRef.current = entry.isIntersecting; }, + { threshold: 0.05 } + ); + observer.observe(el); + return () => observer.disconnect(); + }, []); + + const cycleDuration = 8; return ( -
- {/* Visual Display Stage */} +
- - {/* Layer 1: Ambient Background */} + + {/* Ambient Background — static, no animation */}
- {/* Layer 2: Raw Input Image (Framer-Motion Hardware Accelerated) */} + {/* Layer 1: Before image — opacity-only crossfade (no blur, no scale) */} - {/* eslint-disable-next-line @next/next/no-img-element */} {beforeLabel} - {/* Layer 3: AI Synthesized Result Image (Framer-Motion Hardware Accelerated) */} + {/* Layer 2: After image — opacity-only crossfade (no blur, no scale) */} - {/* eslint-disable-next-line @next/next/no-img-element */} {afterLabel} - {/* Layer 4: Whole-Image Generative Latent Grain Field (Constant High-Frequency Animation) */} - - - {/* Layer 5: High-Density Micro-Grain Shimmer Layer */} - - - {/* Layer 6: Prismatic Latent Neural Glow (Shimmers during grain transformation) */} - - - {/* Layer 7: Final Completion Sheen Flash */} - - - {/* Minimalist Floating Tags (ONLY BEFORE AND AFTER - NO CLUTTER TEXT) */} + {/* Static labels — CSS transition only, no Framer Motion */}
- + {beforeLabel} - +
-
- + {afterLabel} - +
-
diff --git a/src/components/ui/Navbar.tsx b/src/components/ui/Navbar.tsx index 44cb420..fb7d30f 100644 --- a/src/components/ui/Navbar.tsx +++ b/src/components/ui/Navbar.tsx @@ -29,8 +29,16 @@ export function Navbar({ config, currentLocale }: NavbarProps) { const pathname = usePathname(); useEffect(() => { + let lastScrolled = window.scrollY > 20; + if (lastScrolled !== isScrolled) { + setIsScrolled(lastScrolled); + } const handleScroll = () => { - setIsScrolled(window.scrollY > 20); + const nextScrolled = window.scrollY > 20; + if (nextScrolled !== lastScrolled) { + lastScrolled = nextScrolled; + setIsScrolled(nextScrolled); + } }; window.addEventListener('scroll', handleScroll, { passive: true }); return () => window.removeEventListener('scroll', handleScroll); diff --git a/src/components/ui/NeuralGrainOverlay.tsx b/src/components/ui/NeuralGrainOverlay.tsx index cb6a74c..b3c1699 100644 --- a/src/components/ui/NeuralGrainOverlay.tsx +++ b/src/components/ui/NeuralGrainOverlay.tsx @@ -8,6 +8,16 @@ interface NeuralGrainOverlayProps { className?: string; } +/** + * NeuralGrainOverlay - Thermally safe static grain texture. + * + * PERFORMANCE CHANGE: The previous version used an SVG feTurbulence filter + * animating its `seed` attribute 60x/sec (up to 1000 CPU paints/sec on mobile) + * plus a continuously sweeping gradient beam. + * + * Now uses a single static CSS noise pattern (zero CPU overhead, zero JS, zero + * animation). The grain visual is preserved via a lightweight data-URI PNG tile. + */ export function NeuralGrainOverlay({ intensity = 0.22, active = true, @@ -19,32 +29,13 @@ export function NeuralGrainOverlay({