perf(thermal): eradicate thermal heating, CPU throttling, and excessive power draw across mobile and low-end devices

This commit is contained in:
2026-11-05 15:44:10 +05:30
parent 8715e23be0
commit fcd716463b
13 changed files with 396 additions and 321 deletions
+100 -14
View File
@@ -53,9 +53,7 @@
color: #0F172A; color: #0F172A;
background-color: #FAF8F5; background-color: #FAF8F5;
background-image: background-image:
radial-gradient(circle at 50% -10%, rgba(37, 99, 235, 0.05) 0%, transparent 60%), radial-gradient(circle at 50% -10%, rgba(37, 99, 235, 0.04) 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%);
background-attachment: scroll; background-attachment: scroll;
font-family: var(--font-sans), system-ui, -apple-system, sans-serif; font-family: var(--font-sans), system-ui, -apple-system, sans-serif;
overflow-x: clip; overflow-x: clip;
@@ -197,7 +195,7 @@
-webkit-text-fill-color: transparent; -webkit-text-fill-color: transparent;
} }
/* Shimmer Animation Effect for Badges & Buttons */ /* Shimmer Animation Effect for Badges & Buttons — disabled on touch devices */
.shimmer-badge { .shimmer-badge {
background: linear-gradient( background: linear-gradient(
90deg, 90deg,
@@ -206,7 +204,10 @@
rgba(255, 255, 255, 0) 100% rgba(255, 255, 255, 0) 100%
); );
background-size: 200% 100%; background-size: 200% 100%;
animation: shimmer 3s infinite; animation: shimmer 4s infinite;
}
@media (pointer: coarse) {
.shimmer-badge { animation: none; }
} }
@keyframes gradient-flow { @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 { .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 */ /* Light Luxury Cinematic 3D Card Shadows */
@@ -439,7 +441,7 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled {
} }
.animate-neural-sweep { .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) { @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; } .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 { @keyframes cre-orbit-cw {
from { transform: rotate(0deg); } from { transform: rotate(0deg); }
to { transform: rotate(360deg); } to { transform: rotate(360deg); }
@@ -558,8 +560,8 @@ h1, h2, h3, h4, h5, h6, .text-3d-chiseled {
to { transform: rotate(0deg); } to { transform: rotate(0deg); }
} }
@keyframes cre-pulse-star { @keyframes cre-pulse-star {
0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(56,189,248,0.9)); } 0%, 100% { transform: scale(1); }
50% { transform: scale(1.08); filter: drop-shadow(0 0 14px rgba(236,72,153,1)); } 50% { transform: scale(1.05); }
} }
@keyframes cre-shimmer-slide { @keyframes cre-shimmer-slide {
0%, 20% { transform: translate(-80px, -80px) rotate(45deg); opacity: 0; } 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; } 60%, 100% { transform: translate(80px, 80px) rotate(45deg); opacity: 0; }
} }
/* Slower orbit = less frame renders = cooler device */
.cre-anim-orbit { .cre-anim-orbit {
transform-origin: 50px 50px; transform-origin: 50px 50px;
animation: cre-orbit-cw 14s linear infinite; animation: cre-orbit-cw 28s linear infinite;
} }
.cre-anim-orbit-reverse { .cre-anim-orbit-reverse {
transform-origin: 50px 50px; 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 { .cre-anim-core {
transform-origin: 50px 50px; 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 { .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 { @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; 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;
}
+22 -10
View File
@@ -17,13 +17,15 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) {
const containerRef = useRef<HTMLDivElement>(null); const containerRef = useRef<HTMLDivElement>(null);
useEffect(() => { 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') { if (typeof window !== 'undefined') {
const isPhoneOrTablet = const isTouchOrTablet =
window.innerWidth < 1024 || window.innerWidth < 1024 ||
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || navigator.maxTouchPoints > 0 ||
(window.matchMedia && window.matchMedia('(pointer: coarse)').matches && !window.matchMedia('(pointer: fine)').matches); 'ontouchstart' in window ||
if (isPhoneOrTablet) return; /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; const container = containerRef.current;
@@ -38,9 +40,9 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) {
let renderer: THREE.WebGLRenderer | null = null; let renderer: THREE.WebGLRenderer | null = null;
try { 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.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); container.appendChild(renderer.domElement);
} catch { } catch {
return; return;
@@ -98,8 +100,8 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) {
ring2.rotation.z = Math.PI / 6; ring2.rotation.z = Math.PI / 6;
masterGroup.add(ring2); masterGroup.add(ring2);
// 3. Ambient Starlight Particles // 3. Ambient Starlight Particles — reduced count for thermal efficiency
const particleCount = 40; const particleCount = 20;
const particleGeo = new THREE.BufferGeometry(); const particleGeo = new THREE.BufferGeometry();
const posArray = new Float32Array(particleCount * 3); const posArray = new Float32Array(particleCount * 3);
for (let i = 0; i < particleCount * 3; i++) { for (let i = 0; i < particleCount * 3; i++) {
@@ -131,14 +133,24 @@ export function HeroCrystalCanvas({ className }: HeroCrystalCanvasProps) {
let isRunning = false; let isRunning = false;
const clock = new THREE.Clock(); const clock = new THREE.Clock();
let isVisible = true; 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) { if (!isVisible || document.hidden) {
isRunning = false; isRunning = false;
animId = 0; animId = 0;
return; return;
} }
// Skip frame if less than targetInterval ms has passed
if (timestamp - lastFrameTime < targetInterval) {
animId = requestAnimationFrame(animate);
return;
}
lastFrameTime = timestamp;
const elapsed = clock.getElapsedTime(); const elapsed = clock.getElapsedTime();
// Fluid crystal rotation // Fluid crystal rotation
+1 -1
View File
@@ -24,7 +24,7 @@ export function Marquee({
pauseOnHover = true, pauseOnHover = true,
children, children,
vertical = false, vertical = false,
repeat = 4, repeat = 2,
...props ...props
}: MarqueeProps) { }: MarqueeProps) {
return ( return (
+76 -67
View File
@@ -14,79 +14,94 @@ interface ParticlesProps {
export function Particles({ export function Particles({
className = '', className = '',
quantity = 35, quantity = 15,
staticity = 50,
ease = 50,
size = 0.6, size = 0.6,
color = '#3b82f6', color = '#3b82f6',
}: ParticlesProps) { }: ParticlesProps) {
const [mounted, setMounted] = React.useState(false); const [mounted, setMounted] = React.useState(false);
const [isMobile, setIsMobile] = React.useState(true); const [isTouchOrMobile, setIsTouchOrMobile] = React.useState(true);
const canvasRef = useRef<HTMLCanvasElement>(null); const canvasRef = useRef<HTMLCanvasElement>(null);
const canvasContainerRef = useRef<HTMLDivElement>(null); const canvasContainerRef = useRef<HTMLDivElement>(null);
const context = useRef<CanvasRenderingContext2D | null>(null); const context = useRef<CanvasRenderingContext2D | null>(null);
const circles = useRef<any[]>([]); const circles = useRef<any[]>([]);
const canvasSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 }); const canvasSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 });
const isVisibleRef = useRef<boolean>(true); const isVisibleRef = useRef<boolean>(true);
const dpr = typeof window !== 'undefined' ? Math.min(window.devicePixelRatio || 1, 2) : 1;
useEffect(() => { useEffect(() => {
if (typeof window === 'undefined') return; 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); setMounted(true);
}, []); }, []);
useEffect(() => { useEffect(() => {
if (!mounted || isMobile) return; // Zero CPU / GPU allocation on touch/mobile devices
if (!mounted || isTouchOrMobile) return;
const container = canvasContainerRef.current; const container = canvasContainerRef.current;
if (!container || !canvasRef.current) return; if (!container || !canvasRef.current) return;
context.current = canvasRef.current.getContext('2d'); context.current = canvasRef.current.getContext('2d');
if (!context.current) return;
initCanvas(); initCanvas();
// IntersectionObserver to pause loop completely when scrolled out of view!
let animId = 0; let animId = 0;
let isRunning = false; 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 = () => { const startAnimation = () => {
if (isRunning || !isVisibleRef.current || document.hidden) return; if (isRunning || !isVisibleRef.current || document.hidden) return;
isRunning = true; 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); animId = window.requestAnimationFrame(animate);
}; };
@@ -128,7 +143,6 @@ export function Particles({
resizeCanvas(); resizeCanvas();
drawParticles(); drawParticles();
}; };
window.addEventListener('resize', handleResize, { passive: true }); window.addEventListener('resize', handleResize, { passive: true });
return () => { return () => {
@@ -137,10 +151,10 @@ export function Particles({
document.removeEventListener('visibilitychange', handleVisibility); document.removeEventListener('visibilitychange', handleVisibility);
window.removeEventListener('resize', handleResize); window.removeEventListener('resize', handleResize);
}; };
}, [mounted, isMobile, color]); }, [mounted, isTouchOrMobile, color, quantity]);
// Completely omitted on phones and mobile touchscreens // Completely omitted on phones and mobile touchscreens
if (!mounted || isMobile) { if (!mounted || isTouchOrMobile) {
return null; return null;
} }
@@ -152,13 +166,15 @@ export function Particles({
const resizeCanvas = () => { const resizeCanvas = () => {
if (canvasContainerRef.current && canvasRef.current && context.current) { if (canvasContainerRef.current && canvasRef.current && context.current) {
circles.current.length = 0; circles.current.length = 0;
canvasSize.current.w = canvasContainerRef.current.offsetWidth; const w = canvasContainerRef.current.offsetWidth;
canvasSize.current.h = canvasContainerRef.current.offsetHeight; const h = canvasContainerRef.current.offsetHeight;
canvasRef.current.width = canvasSize.current.w * dpr; canvasSize.current.w = w;
canvasRef.current.height = canvasSize.current.h * dpr; canvasSize.current.h = h;
canvasRef.current.style.width = `${canvasSize.current.w}px`; // Fixed 1.0 DPR: eliminates 4x retina CPU rasterization overhead
canvasRef.current.style.height = `${canvasSize.current.h}px`; canvasRef.current.width = w;
context.current.scale(dpr, dpr); 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 x = Math.floor(Math.random() * canvasSize.current.w);
const y = Math.floor(Math.random() * canvasSize.current.h); const y = Math.floor(Math.random() * canvasSize.current.h);
const pSize = Math.floor(Math.random() * 2) + size; const pSize = Math.floor(Math.random() * 2) + size;
const targetAlpha = parseFloat((Math.random() * 0.4 + 0.1).toFixed(2)); const targetAlpha = parseFloat((Math.random() * 0.35 + 0.1).toFixed(2));
const dx = (Math.random() - 0.5) * 0.18; const dx = (Math.random() - 0.5) * 0.15;
const dy = (Math.random() - 0.5) * 0.18; const dy = (Math.random() - 0.5) * 0.15;
return { return { x, y, size: pSize, alpha: 0, targetAlpha, dx, dy };
x,
y,
size: pSize,
alpha: 0,
targetAlpha,
dx,
dy,
};
}; };
const drawCircle = (circle: any, update = false) => { const drawCircle = (circle: any, update = false) => {
@@ -197,13 +205,14 @@ export function Particles({
const drawParticles = () => { const drawParticles = () => {
clearContext(); clearContext();
for (let i = 0; i < quantity; i++) { const count = Math.min(quantity, 18);
for (let i = 0; i < count; i++) {
drawCircle(circleParams()); drawCircle(circleParams());
} }
}; };
const clearContext = () => { const clearContext = () => {
if (context.current) { if (context.current && canvasSize.current.w > 0) {
context.current.clearRect(0, 0, canvasSize.current.w, canvasSize.current.h); context.current.clearRect(0, 0, canvasSize.current.w, canvasSize.current.h);
} }
}; };
+5 -4
View File
@@ -19,13 +19,14 @@ export function SmoothCursor() {
useEffect(() => { useEffect(() => {
if (typeof window === 'undefined') return; if (typeof window === 'undefined') return;
// Detect phones, tablets, or touchscreen devices // Detect phones, tablets, or touchscreen devices (zero touch overhead)
const isMobileOrTablet = 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) || /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('(pointer: coarse)').matches) ||
(window.matchMedia && !window.matchMedia('(hover: hover)').matches) || (window.matchMedia && !window.matchMedia('(hover: hover)').matches);
('ontouchstart' in window && window.innerWidth < 1024) ||
(navigator.maxTouchPoints > 0 && window.innerWidth < 1024);
const hasFinePointer = const hasFinePointer =
window.matchMedia && window.matchMedia('(hover: hover) and (pointer: fine)').matches; window.matchMedia && window.matchMedia('(hover: hover) and (pointer: fine)').matches;
+2 -2
View File
@@ -267,10 +267,10 @@ export function HeroSection({
// ------------------------------------------------------------- // -------------------------------------------------------------
return ( return (
<section className="relative isolate min-h-[96vh] flex flex-col justify-center items-center text-center overflow-hidden bg-[#FAF8F5] pt-28 pb-20 px-4 sm:px-6 md:px-8 lg:px-12"> <section className="relative isolate min-h-[96vh] flex flex-col justify-center items-center text-center overflow-hidden bg-[#FAF8F5] pt-28 pb-20 px-4 sm:px-6 md:px-8 lg:px-12">
{/* 1. MagicUI Ambient Floating Particles */} {/* 1. MagicUI Ambient Floating Particles (Desktop only, 0% CPU on mobile/tablets) */}
<Particles <Particles
className="absolute inset-0 -z-20 opacity-40 pointer-events-none" className="absolute inset-0 -z-20 opacity-40 pointer-events-none"
quantity={60} quantity={15}
color="#3b82f6" color="#3b82f6"
size={0.7} size={0.7}
/> />
+14 -18
View File
@@ -38,7 +38,7 @@ export function HowItWorks3DSection({
useEffect(() => { useEffect(() => {
if (isPaused) return; if (isPaused) return;
const section = sectionRef.current; const section = sectionRef.current;
let isVisible = true; let isVisible = false; // Must be false until IntersectionObserver confirms visibility
let timer: any = null; let timer: any = null;
const runTimer = () => { const runTimer = () => {
@@ -47,7 +47,7 @@ export function HowItWorks3DSection({
if (isVisible && !document.hidden && !isPaused) { if (isVisible && !document.hidden && !isPaused) {
setActiveStep((prev) => (prev === 3 ? 1 : ((prev + 1) as 1 | 2 | 3))); setActiveStep((prev) => (prev === 3 ? 1 : ((prev + 1) as 1 | 2 | 3)));
} }
}, 3400); }, 4500);
}; };
const observer = new IntersectionObserver( const observer = new IntersectionObserver(
@@ -60,11 +60,10 @@ export function HowItWorks3DSection({
timer = null; timer = null;
} }
}, },
{ threshold: 0.1 } { threshold: 0.15 }
); );
if (section) observer.observe(section); if (section) observer.observe(section);
runTimer();
const handleVisibility = () => { const handleVisibility = () => {
if (document.hidden && timer) { if (document.hidden && timer) {
@@ -101,7 +100,7 @@ export function HowItWorks3DSection({
{/* Playful & Warm Section Header */} {/* Playful & Warm Section Header */}
<div className="text-center max-w-3xl mx-auto space-y-4"> <div className="text-center max-w-3xl mx-auto space-y-4">
<div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-display font-bold tracking-wider uppercase text-amber-900 bg-amber-100/80 border border-amber-300 shadow-sm"> <div className="inline-flex items-center gap-2 px-4 py-1.5 rounded-full text-xs font-display font-bold tracking-wider uppercase text-amber-900 bg-amber-100/80 border border-amber-300 shadow-sm">
<Sparkles className="w-4 h-4 text-amber-600 animate-spin" style={{ animationDuration: '6s' }} /> <Sparkles className="w-4 h-4 text-amber-600" />
<span>{badge}</span> <span>{badge}</span>
</div> </div>
@@ -199,7 +198,7 @@ function TravellingTransformationPipeline({
<div className="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 border-b border-slate-100"> <div className="flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 border-b border-slate-100">
<div> <div>
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-slate-100 text-slate-800 text-[11px] font-mono font-bold tracking-wider uppercase mb-1"> <div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-slate-100 text-slate-800 text-[11px] font-mono font-bold tracking-wider uppercase mb-1">
<span className={`w-2 h-2 rounded-full animate-ping ${ <span className={`w-2 h-2 rounded-full ${
activeStep === 1 ? 'bg-blue-600' : activeStep === 2 ? 'bg-amber-500' : 'bg-emerald-500' activeStep === 1 ? 'bg-blue-600' : activeStep === 2 ? 'bg-amber-500' : 'bg-emerald-500'
}`} /> }`} />
<span>Live Photo Journey Pipeline</span> <span>Live Photo Journey Pipeline</span>
@@ -434,7 +433,7 @@ function StepUploadCard({ isActive = false }: { isActive?: boolean }) {
{/* Step Badge */} {/* Step Badge */}
<div className="flex items-center justify-between mb-5"> <div className="flex items-center justify-between mb-5">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-700 text-xs font-display font-bold uppercase tracking-wider"> <div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-blue-50 border border-blue-200 text-blue-700 text-xs font-display font-bold uppercase tracking-wider">
{isActive && <span className="w-2 h-2 rounded-full bg-blue-600 animate-ping" />} {isActive && <span className="w-2 h-2 rounded-full bg-blue-600 inline-block" />}
<span>STEP 01</span> <span>STEP 01</span>
</div> </div>
<span className="text-xl">📸</span> <span className="text-xl">📸</span>
@@ -445,7 +444,7 @@ function StepUploadCard({ isActive = false }: { isActive?: boolean }) {
{/* Animated floating dashed dropzone */} {/* Animated floating dashed dropzone */}
<div className="w-full h-full border-2 border-dashed border-blue-300/80 rounded-2xl flex flex-col items-center justify-center p-4 relative"> <div className="w-full h-full border-2 border-dashed border-blue-300/80 rounded-2xl flex flex-col items-center justify-center p-4 relative">
{/* Playful Floating Photo Frame (GPU-composited CSS float, 0% JS overhead) */} {/* Playful Floating Photo Frame (GPU-composited CSS float, 0% JS overhead) */}
<div className="w-36 h-28 rounded-2xl bg-white shadow-xl border-2 border-white overflow-hidden p-1.5 animate-float-slow transform-gpu"> <div className="w-36 h-28 rounded-2xl bg-white shadow-xl border-2 border-white overflow-hidden p-1.5 transform-gpu">
<img <img
src="/management/pages/home/sections/how-it-works/media/before.jpg" src="/management/pages/home/sections/how-it-works/media/before.jpg"
alt="Your Photo" alt="Your Photo"
@@ -508,7 +507,7 @@ function StepMagicCard({ isActive = false }: { isActive?: boolean }) {
{/* Step Badge */} {/* Step Badge */}
<div className="flex items-center justify-between mb-5"> <div className="flex items-center justify-between mb-5">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-amber-50 border border-amber-200 text-amber-800 text-xs font-display font-bold uppercase tracking-wider"> <div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-amber-50 border border-amber-200 text-amber-800 text-xs font-display font-bold uppercase tracking-wider">
{isActive && <span className="w-2 h-2 rounded-full bg-amber-500 animate-ping" />} {isActive && <span className="w-2 h-2 rounded-full bg-amber-500 inline-block" />}
<span>STEP 02</span> <span>STEP 02</span>
</div> </div>
<span className="text-xl">🪄</span> <span className="text-xl">🪄</span>
@@ -516,20 +515,17 @@ function StepMagicCard({ isActive = false }: { isActive?: boolean }) {
{/* Visual Animation: Swirling Magical Portal */} {/* Visual Animation: Swirling Magical Portal */}
<div className="relative w-full h-[230px] rounded-3xl bg-gradient-to-b from-amber-50/80 via-purple-50/50 to-pink-50/60 border border-amber-200/80 overflow-hidden flex flex-col items-center justify-center p-4 select-none"> <div className="relative w-full h-[230px] rounded-3xl bg-gradient-to-b from-amber-50/80 via-purple-50/50 to-pink-50/60 border border-amber-200/80 overflow-hidden flex flex-col items-center justify-center p-4 select-none">
{/* Glowing Aura Ring */} {/* Glowing Aura Ring — static, no animation to prevent thermal issues */}
<div className="absolute w-36 h-36 rounded-full bg-gradient-to-tr from-amber-300/40 via-purple-300/40 to-pink-300/40 blur-xl animate-pulse" /> <div className="absolute w-36 h-36 rounded-full bg-gradient-to-tr from-amber-300/30 via-purple-300/30 to-pink-300/30 blur-xl" />
{/* Central Wand and Sparkling Swirl */} {/* Central Wand and Sparkling Swirl */}
<div className="relative z-10 flex flex-col items-center justify-center"> <div className="relative z-10 flex flex-col items-center justify-center">
<div className="w-20 h-20 rounded-3xl bg-white shadow-xl border border-amber-200 flex items-center justify-center transform group-hover:scale-110 transition-transform duration-300"> <div className="w-20 h-20 rounded-3xl bg-white shadow-xl border border-amber-200 flex items-center justify-center transform group-hover:scale-110 transition-transform duration-300">
<Wand2 className="w-10 h-10 text-amber-500 animate-bounce" /> <Wand2 className="w-10 h-10 text-amber-500" />
</div> </div>
{/* Orbiting Stars & Sparkles (Pure CSS 60/120fps hardware rotation - 0% JS intervals!) */} {/* Stars — static, no spin to avoid continuous GPU paint */}
<div <div className="absolute inset-[-20px] pointer-events-none">
className="absolute inset-[-20px] pointer-events-none animate-spin"
style={{ animationDuration: '8s' }}
>
<span className="absolute top-0 left-1/2 -translate-x-1/2 text-amber-400 text-base">✨</span> <span className="absolute top-0 left-1/2 -translate-x-1/2 text-amber-400 text-base">✨</span>
<span className="absolute bottom-0 left-1/2 -translate-x-1/2 text-purple-400 text-sm">⭐</span> <span className="absolute bottom-0 left-1/2 -translate-x-1/2 text-purple-400 text-sm">⭐</span>
<span className="absolute left-0 top-1/2 -translate-y-1/2 text-pink-400 text-sm">💫</span> <span className="absolute left-0 top-1/2 -translate-y-1/2 text-pink-400 text-sm">💫</span>
@@ -586,7 +582,7 @@ function StepTadaCard({ isActive = false }: { isActive?: boolean }) {
{/* Step Badge */} {/* Step Badge */}
<div className="flex items-center justify-between mb-5"> <div className="flex items-center justify-between mb-5">
<div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-emerald-50 border border-emerald-200 text-emerald-800 text-xs font-display font-bold uppercase tracking-wider"> <div className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full bg-emerald-50 border border-emerald-200 text-emerald-800 text-xs font-display font-bold uppercase tracking-wider">
{isActive && <span className="w-2 h-2 rounded-full bg-emerald-500 animate-ping" />} {isActive && <span className="w-2 h-2 rounded-full bg-emerald-500 inline-block" />}
<span>STEP 03</span> <span>STEP 03</span>
</div> </div>
<span className="text-xl">🎉</span> <span className="text-xl">🎉</span>
@@ -1,6 +1,6 @@
'use client'; 'use client';
import React from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { Star, MessageSquareQuote, CheckCircle2 } from 'lucide-react'; import { Star, MessageSquareQuote, CheckCircle2 } from 'lucide-react';
import { Marquee } from '@/components/magicui/marquee'; import { Marquee } from '@/components/magicui/marquee';
import { TextAnimate } from '@/components/magicui/text-animate'; import { TextAnimate } from '@/components/magicui/text-animate';
@@ -94,8 +94,48 @@ export function ReviewsMarqueeSection({
badge = 'VERIFIED COMMUNITY FEEDBACK', badge = 'VERIFIED COMMUNITY FEEDBACK',
subtitle = 'Over 1.4 million photos processed with five-star ratings across web and mobile apps.', subtitle = 'Over 1.4 million photos processed with five-star ratings across web and mobile apps.',
}: ReviewsMarqueeSectionProps) { }: ReviewsMarqueeSectionProps) {
const sectionRef = useRef<HTMLDivElement>(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 ( return (
<section id="user-reviews" className="py-14 sm:py-20 bg-[#FAF8F5] relative overflow-hidden border-t border-slate-900/[0.06]"> <section
id="user-reviews"
ref={sectionRef}
className="py-14 sm:py-20 bg-[#FAF8F5] relative overflow-hidden border-t border-slate-900/[0.06]"
>
{/* Symbolic Elemental Ambient Highlights */} {/* Symbolic Elemental Ambient Highlights */}
<div <div
className="absolute inset-0 pointer-events-none -z-10" className="absolute inset-0 pointer-events-none -z-10"
@@ -124,17 +164,29 @@ export function ReviewsMarqueeSection({
</p> </p>
</div> </div>
{/* Marquee Container with Left & Right Gradient Feather Masks */} {/* Marquee Container with Left & Right Gradient Feather Masks - Paused when offscreen */}
<div className="relative flex w-full flex-col items-center justify-center overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_10%,black_90%,transparent)]"> <div
className="relative flex w-full flex-col items-center justify-center overflow-hidden [mask-image:linear-gradient(to_right,transparent,black_10%,black_90%,transparent)]"
style={{
animationPlayState: isInView ? 'running' : 'paused',
}}
>
{/* Row 1: Leftward Marquee */} {/* Row 1: Leftward Marquee */}
<Marquee pauseOnHover className="[--duration:35s]"> <Marquee
pauseOnHover
className={`[--duration:35s] ${!isInView ? '[&>*]:[animation-play-state:paused]' : ''}`}
>
{REVIEWS_ROW_1.map((review, idx) => ( {REVIEWS_ROW_1.map((review, idx) => (
<ReviewCard key={idx} {...review} /> <ReviewCard key={idx} {...review} />
))} ))}
</Marquee> </Marquee>
{/* Row 2: Rightward Reverse Marquee */} {/* Row 2: Rightward Reverse Marquee */}
<Marquee reverse pauseOnHover className="[--duration:40s] mt-4"> <Marquee
reverse
pauseOnHover
className={`[--duration:40s] mt-4 ${!isInView ? '[&>*]:[animation-play-state:paused]' : ''}`}
>
{REVIEWS_ROW_2.map((review, idx) => ( {REVIEWS_ROW_2.map((review, idx) => (
<ReviewCard key={idx} {...review} /> <ReviewCard key={idx} {...review} />
))} ))}
+6 -6
View File
@@ -27,8 +27,8 @@ export function BrandLogo({
className="relative flex items-center justify-center shrink-0 transition-transform duration-300 group-hover:scale-105" className="relative flex items-center justify-center shrink-0 transition-transform duration-300 group-hover:scale-105"
style={{ width: iconDimensions.w, height: iconDimensions.h }} 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) */}
<div className="absolute -inset-1 rounded-2xl bg-gradient-to-tr from-cyan-400 via-blue-500 to-fuchsia-500 opacity-45 blur-md group-hover:opacity-90 group-hover:blur-lg transition-all duration-500 animate-pulse pointer-events-none" /> <div className="absolute -inset-1 rounded-2xl bg-gradient-to-tr from-cyan-400 via-blue-500 to-fuchsia-500 opacity-25 group-hover:opacity-75 transition-opacity duration-300 pointer-events-none" />
{/* Glossy Bezel Container */} {/* Glossy Bezel Container */}
<div className="relative w-full h-full rounded-2xl overflow-hidden bg-slate-950 p-[1.5px] shadow-[0_4px_20px_-4px_rgba(56,189,248,0.5)] border border-white/30 group-hover:border-cyan-400/80 transition-all duration-300"> <div className="relative w-full h-full rounded-2xl overflow-hidden bg-slate-950 p-[1.5px] shadow-[0_4px_20px_-4px_rgba(56,189,248,0.5)] border border-white/30 group-hover:border-cyan-400/80 transition-all duration-300">
@@ -97,9 +97,9 @@ export function BrandLogo({
strokeDasharray="4 6" strokeDasharray="4 6"
/> />
{/* Orbiting Photon Nodes */} {/* Orbiting Photon Nodes */}
<circle cx="50" cy="9" r="3" fill="#00F5FF" filter="drop-shadow(0 0 4px #00F5FF)" /> <circle cx="50" cy="9" r="3" fill="#00F5FF" />
<circle cx="91" cy="50" r="2.5" fill="#EC4899" filter="drop-shadow(0 0 4px #EC4899)" /> <circle cx="91" cy="50" r="2.5" fill="#EC4899" />
<circle cx="15" cy="70" r="2.5" fill="#FACC15" filter="drop-shadow(0 0 4px #FACC15)" /> <circle cx="15" cy="70" r="2.5" fill="#FACC15" />
</g> </g>
{/* Inner Counter-Orbiting Quantum Track */} {/* Inner Counter-Orbiting Quantum Track */}
@@ -144,7 +144,7 @@ export function BrandLogo({
{/* Radiant Supernova Core Bloom */} {/* Radiant Supernova Core Bloom */}
<circle cx="50" cy="50" r="14" fill="url(#cre-star-bloom)" /> <circle cx="50" cy="50" r="14" fill="url(#cre-star-bloom)" />
<circle cx="50" cy="50" r="5" fill="#FFFFFF" filter="drop-shadow(0 0 5px #FFFFFF)" /> <circle cx="50" cy="50" r="5" fill="#FFFFFF" />
{/* Central 4-Point Micro Diamond Glint */} {/* Central 4-Point Micro Diamond Glint */}
<polygon points="50,42 52,50 50,58 48,50" fill="#FFFFFF" /> <polygon points="50,42 52,50 50,58 48,50" fill="#FFFFFF" />
+48 -162
View File
@@ -1,6 +1,6 @@
'use client'; 'use client';
import React from 'react'; import React, { useRef, useEffect } from 'react';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
interface GrainTransformShowcaseProps { interface GrainTransformShowcaseProps {
@@ -12,9 +12,20 @@ interface GrainTransformShowcaseProps {
className?: string; className?: string;
} }
// Ultra-fast SVG fractal noise data URI (GPU-cached, 0% CPU overhead) /**
const NOISE_SVG_DATA_URI = `data:image/svg+xml;utf8,<svg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'><filter id='noise'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23noise)' opacity='0.7'/></svg>`; * 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({ export function GrainTransformShowcase({
beforeUrl, beforeUrl,
afterUrl, afterUrl,
@@ -23,46 +34,45 @@ export function GrainTransformShowcase({
aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full', aspectRatio = 'aspect-[4/3] lg:aspect-auto lg:h-full',
className = '', className = '',
}: GrainTransformShowcaseProps) { }: GrainTransformShowcaseProps) {
// Constant Animation Cycle: 8-second seamless looping timeline const containerRef = useRef<HTMLDivElement>(null);
// 0.0s - 2.5s: Before image active const isVisibleRef = useRef(true);
// 2.5s - 4.0s: Before image dissolves into full neural grain field
// 4.0s - 6.5s: After image crystallizes and shines // Pause Framer Motion when offscreen (saves CPU/GPU budget on mobile)
// 6.5s - 8.0s: After image dissolves through grains back to Before useEffect(() => {
const cycleDuration = 7.5; 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 ( return (
<div className={`relative flex flex-col justify-between h-full bg-slate-950 rounded-3xl overflow-hidden select-none ${className}`}> <div
{/* Visual Display Stage */} ref={containerRef}
className={`relative flex flex-col justify-between h-full bg-slate-950 rounded-3xl overflow-hidden select-none ${className}`}
>
<div className={`relative flex-1 min-h-[380px] sm:min-h-[460px] overflow-hidden ${aspectRatio}`}> <div className={`relative flex-1 min-h-[380px] sm:min-h-[460px] overflow-hidden ${aspectRatio}`}>
<div className="relative w-full h-full overflow-hidden bg-slate-950"> <div className="relative w-full h-full overflow-hidden bg-slate-950">
{/* Layer 1: Ambient Background */} {/* Ambient Background — static, no animation */}
<div className="absolute inset-0 bg-gradient-to-br from-slate-950 via-indigo-950/30 to-slate-950 pointer-events-none" /> <div className="absolute inset-0 bg-gradient-to-br from-slate-950 via-indigo-950/30 to-slate-950 pointer-events-none" />
{/* Layer 2: Raw Input Image (Framer-Motion Hardware Accelerated) */} {/* Layer 1: Before image — opacity-only crossfade (no blur, no scale) */}
<motion.div <motion.div
className="absolute inset-0 w-full h-full" className="absolute inset-0 w-full h-full"
animate={{ animate={{ opacity: [1, 1, 0, 0, 0, 0, 1] }}
opacity: [1, 1, 0, 0, 0, 0, 1],
scale: [1, 1, 1.03, 1.03, 1, 1, 1],
filter: [
'blur(0px) brightness(1)',
'blur(0px) brightness(1)',
'blur(6px) brightness(1.2)',
'blur(12px) brightness(1.4)',
'blur(12px) brightness(1.4)',
'blur(0px) brightness(1)',
'blur(0px) brightness(1)',
],
}}
transition={{ transition={{
duration: cycleDuration, duration: cycleDuration,
repeat: Infinity, repeat: Infinity,
times: [0, 0.28, 0.44, 0.5, 0.56, 0.92, 1], times: [0, 0.3, 0.44, 0.5, 0.56, 0.9, 1],
ease: 'easeInOut', ease: 'easeInOut',
}} }}
> >
{/* eslint-disable-next-line @next/next/no-img-element */}
<img <img
src={beforeUrl} src={beforeUrl}
alt={beforeLabel} alt={beforeLabel}
@@ -71,30 +81,17 @@ export function GrainTransformShowcase({
/> />
</motion.div> </motion.div>
{/* Layer 3: AI Synthesized Result Image (Framer-Motion Hardware Accelerated) */} {/* Layer 2: After image — opacity-only crossfade (no blur, no scale) */}
<motion.div <motion.div
className="absolute inset-0 w-full h-full" className="absolute inset-0 w-full h-full"
animate={{ animate={{ opacity: [0, 0, 0, 1, 1, 1, 0] }}
opacity: [0, 0, 0, 0.2, 1, 1, 0],
scale: [1.03, 1.03, 1.03, 1.02, 1, 1, 1.03],
filter: [
'blur(12px) brightness(1.4)',
'blur(12px) brightness(1.4)',
'blur(8px) brightness(1.2)',
'blur(4px) brightness(1.1)',
'blur(0px) brightness(1)',
'blur(0px) brightness(1)',
'blur(10px) brightness(1.4)',
],
}}
transition={{ transition={{
duration: cycleDuration, duration: cycleDuration,
repeat: Infinity, repeat: Infinity,
times: [0, 0.28, 0.42, 0.52, 0.62, 0.88, 1], times: [0, 0.3, 0.5, 0.62, 0.7, 0.9, 1],
ease: 'easeInOut', ease: 'easeInOut',
}} }}
> >
{/* eslint-disable-next-line @next/next/no-img-element */}
<img <img
src={afterUrl} src={afterUrl}
alt={afterLabel} alt={afterLabel}
@@ -103,128 +100,17 @@ export function GrainTransformShowcase({
/> />
</motion.div> </motion.div>
{/* Layer 4: Whole-Image Generative Latent Grain Field (Constant High-Frequency Animation) */} {/* Static labels — CSS transition only, no Framer Motion */}
<motion.div
className="absolute inset-0 pointer-events-none mix-blend-screen"
style={{
backgroundImage: `url("${NOISE_SVG_DATA_URI}")`,
backgroundSize: '160px 160px',
}}
animate={{
opacity: [0.08, 0.12, 0.85, 0.95, 0.75, 0.1, 0.08],
backgroundPosition: [
'0px 0px',
'40px -30px',
'-50px 60px',
'70px -80px',
'-30px 40px',
'60px -50px',
'0px 0px',
],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.25, 0.45, 0.5, 0.55, 0.75, 1],
ease: 'linear',
}}
/>
{/* Layer 5: High-Density Micro-Grain Shimmer Layer */}
<motion.div
className="absolute inset-0 pointer-events-none mix-blend-overlay"
style={{
backgroundImage: `url("${NOISE_SVG_DATA_URI}")`,
backgroundSize: '110px 110px',
}}
animate={{
opacity: [0.15, 0.2, 0.9, 1, 0.8, 0.2, 0.15],
backgroundPosition: [
'0px 0px',
'-30px 40px',
'50px -50px',
'-70px 30px',
'40px -40px',
'-20px 20px',
'0px 0px',
],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.25, 0.45, 0.5, 0.55, 0.75, 1],
ease: 'linear',
}}
/>
{/* Layer 6: Prismatic Latent Neural Glow (Shimmers during grain transformation) */}
<motion.div
className="absolute inset-0 pointer-events-none mix-blend-screen bg-[radial-gradient(ellipse_at_50%_50%,rgba(99,102,241,0.35),rgba(56,189,248,0.2),transparent_70%)]"
animate={{
opacity: [0, 0, 0.75, 0.9, 0.6, 0, 0],
scale: [0.95, 0.95, 1.05, 1.1, 1.02, 0.95, 0.95],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.3, 0.45, 0.5, 0.58, 0.72, 1],
ease: 'easeInOut',
}}
/>
{/* Layer 7: Final Completion Sheen Flash */}
<motion.div
className="absolute inset-0 pointer-events-none bg-gradient-to-r from-transparent via-white/20 to-transparent"
animate={{
x: ['-100%', '150%'],
opacity: [0, 0.8, 0],
}}
transition={{
duration: 1.2,
repeat: Infinity,
repeatDelay: cycleDuration - 1.2,
ease: 'easeInOut',
delay: 4.2,
}}
/>
{/* Minimalist Floating Tags (ONLY BEFORE AND AFTER - NO CLUTTER TEXT) */}
<div className="absolute bottom-4 left-4 z-30 pointer-events-none"> <div className="absolute bottom-4 left-4 z-30 pointer-events-none">
<motion.span <span className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-white/20 shadow-md text-white bg-black/75">
className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-white/20 shadow-md text-white bg-black/75"
animate={{
opacity: [1, 1, 0.4, 0.3, 0.4, 1, 1],
scale: [1, 1, 0.95, 0.92, 0.95, 1, 1],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.3, 0.45, 0.5, 0.55, 0.85, 1],
ease: 'easeInOut',
}}
>
{beforeLabel} {beforeLabel}
</motion.span> </span>
</div> </div>
<div className="absolute bottom-4 right-4 z-30 pointer-events-none"> <div className="absolute bottom-4 right-4 z-30 pointer-events-none">
<motion.span <span className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-blue-400/30 shadow-lg text-white bg-blue-600/90">
className="px-2.5 py-1 rounded-md text-[10px] font-mono font-bold tracking-wider uppercase backdrop-blur-md border border-blue-400/30 shadow-lg text-white bg-blue-600/90"
animate={{
opacity: [0.35, 0.35, 0.5, 0.7, 1, 1, 0.35],
scale: [0.94, 0.94, 0.96, 0.98, 1.03, 1, 0.94],
}}
transition={{
duration: cycleDuration,
repeat: Infinity,
times: [0, 0.3, 0.45, 0.52, 0.62, 0.88, 1],
ease: 'easeInOut',
}}
>
{afterLabel} {afterLabel}
</motion.span> </span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
+9 -1
View File
@@ -29,8 +29,16 @@ export function Navbar({ config, currentLocale }: NavbarProps) {
const pathname = usePathname(); const pathname = usePathname();
useEffect(() => { useEffect(() => {
let lastScrolled = window.scrollY > 20;
if (lastScrolled !== isScrolled) {
setIsScrolled(lastScrolled);
}
const handleScroll = () => { const handleScroll = () => {
setIsScrolled(window.scrollY > 20); const nextScrolled = window.scrollY > 20;
if (nextScrolled !== lastScrolled) {
lastScrolled = nextScrolled;
setIsScrolled(nextScrolled);
}
}; };
window.addEventListener('scroll', handleScroll, { passive: true }); window.addEventListener('scroll', handleScroll, { passive: true });
return () => window.removeEventListener('scroll', handleScroll); return () => window.removeEventListener('scroll', handleScroll);
+18 -27
View File
@@ -8,6 +8,16 @@ interface NeuralGrainOverlayProps {
className?: string; 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({ export function NeuralGrainOverlay({
intensity = 0.22, intensity = 0.22,
active = true, active = true,
@@ -19,32 +29,13 @@ export function NeuralGrainOverlay({
<div <div
aria-hidden="true" aria-hidden="true"
className={`pointer-events-none absolute inset-0 z-10 overflow-hidden mix-blend-overlay ${className}`} className={`pointer-events-none absolute inset-0 z-10 overflow-hidden mix-blend-overlay ${className}`}
style={{ opacity: intensity }} style={{
> opacity: intensity,
{/* High-frequency animated SVG noise filter */} // Static SVG fractal noise — rendered once by browser, cached, zero CPU animation
<svg className="absolute inset-0 h-full w-full opacity-65"> backgroundImage: `url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>")`,
<filter id="neural-grain-noise"> backgroundSize: '200px 200px',
<feTurbulence backgroundRepeat: 'repeat',
type="fractalNoise" }}
baseFrequency="0.75" />
numOctaves="3"
stitchTiles="stitch"
>
<animate
attributeName="seed"
from="1"
to="60"
dur="1.8s"
repeatCount="indefinite"
/>
</feTurbulence>
<feColorMatrix type="saturate" values="0" />
</filter>
<rect width="100%" height="100%" filter="url(#neural-grain-noise)" />
</svg>
{/* Latent Neural Scan Sweep Beam */}
<div className="absolute inset-y-0 w-28 bg-gradient-to-r from-transparent via-blue-400/25 to-transparent animate-neural-sweep pointer-events-none" />
</div>
); );
} }
+37 -3
View File
@@ -8,9 +8,10 @@ interface SmoothScrollProviderProps {
/** /**
* Universal Smooth Scrolling Provider. * Universal Smooth Scrolling Provider.
* - On iOS / Android / Mobile touch devices: Keeps native hardware-accelerated 120Hz momentum * - On iOS / Android / Tablets / Touch devices: Keeps native hardware-accelerated 120Hz momentum
* scrolling intact, completely avoiding WebKit JS scroll conflicts and parser overhead. * scrolling intact, completely avoiding WebKit JS scroll conflicts and parser overhead.
* - On Desktop & Trackpads: Dynamically loads high-performance exponential easing Lenis engine. * - On Desktop & Trackpads: Dynamically loads high-performance exponential easing Lenis engine.
* - Idle sleep: Automatically stops the RAF loop when scrolling is settled (0% CPU at rest).
* - Handles anchor link smooth scrolling safely across all devices. * - Handles anchor link smooth scrolling safely across all devices.
*/ */
export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) { export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
@@ -22,12 +23,13 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
let animId = 0; let animId = 0;
let isDisposed = false; let isDisposed = false;
let visibilityHandler: (() => void) | null = null; let visibilityHandler: (() => void) | null = null;
let removeInputListeners: (() => void) | null = null;
// Detect mobile / touch devices: iOS (iPhone, iPad, iPod) and touch screens // Detect mobile / touch devices: iOS (iPhone, iPad, iPod), Android tablets, and touch screens
const isTouchDevice = const isTouchDevice =
'ontouchstart' in window || 'ontouchstart' in window ||
navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0 ||
(window.matchMedia && window.matchMedia('(pointer: coarse)').matches && !window.matchMedia('(pointer: fine)').matches); (window.matchMedia && window.matchMedia('(pointer: coarse)').matches);
const prefersReducedMotion = const prefersReducedMotion =
window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
@@ -53,9 +55,13 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
(window as any).__lenis = lenis; (window as any).__lenis = lenis;
let isRunning = false; let isRunning = false;
let idleFrames = 0;
const startRaf = () => { const startRaf = () => {
if (isRunning || isDisposed || document.hidden) return; if (isRunning || isDisposed || document.hidden) return;
isRunning = true; isRunning = true;
idleFrames = 0;
const raf = (time: number) => { const raf = (time: number) => {
if (isDisposed || document.hidden) { if (isDisposed || document.hidden) {
isRunning = false; isRunning = false;
@@ -63,11 +69,36 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
return; return;
} }
lenis?.raf(time); lenis?.raf(time);
// Idle Sleep: when scrolling velocity settles to 0, stop RAF loop to conserve battery
if (lenis && Math.abs(lenis.velocity || 0) < 0.01 && !lenis.isScrolling) {
idleFrames++;
if (idleFrames > 20) {
isRunning = false;
animId = 0;
return;
}
} else {
idleFrames = 0;
}
animId = requestAnimationFrame(raf); animId = requestAnimationFrame(raf);
}; };
animId = requestAnimationFrame(raf); animId = requestAnimationFrame(raf);
}; };
// Wake up loop on scroll interactions
const wakeUp = () => startRaf();
window.addEventListener('wheel', wakeUp, { passive: true });
window.addEventListener('keydown', wakeUp, { passive: true });
window.addEventListener('scroll', wakeUp, { passive: true });
removeInputListeners = () => {
window.removeEventListener('wheel', wakeUp);
window.removeEventListener('keydown', wakeUp);
window.removeEventListener('scroll', wakeUp);
};
startRaf(); startRaf();
visibilityHandler = () => { visibilityHandler = () => {
@@ -132,6 +163,9 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
if (visibilityHandler) { if (visibilityHandler) {
document.removeEventListener('visibilitychange', visibilityHandler); document.removeEventListener('visibilitychange', visibilityHandler);
} }
if (removeInputListeners) {
removeInputListeners();
}
document.removeEventListener('click', handleAnchorClick, { capture: true }); document.removeEventListener('click', handleAnchorClick, { capture: true });
if (lenis && typeof lenis.destroy === 'function') { if (lenis && typeof lenis.destroy === 'function') {
lenis.destroy(); lenis.destroy();