fix(mobile): resolve mobile touch runtime errors, webgl transmission GPU stall and add root icon
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="none">
|
||||
<defs>
|
||||
<linearGradient id="cre-bright-cyan" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#00F5FF" />
|
||||
<stop offset="100%" stop-color="#2563EB" />
|
||||
</linearGradient>
|
||||
<linearGradient id="cre-bright-purple" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#A855F7" />
|
||||
<stop offset="100%" stop-color="#EC4899" />
|
||||
</linearGradient>
|
||||
<linearGradient id="cre-bright-gold" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#F59E0B" />
|
||||
<stop offset="100%" stop-color="#FACC15" />
|
||||
</linearGradient>
|
||||
<linearGradient id="cre-bright-teal" x1="0%" y1="0%" x2="100%" y2="100%">
|
||||
<stop offset="0%" stop-color="#10B981" />
|
||||
<stop offset="100%" stop-color="#06B6D4" />
|
||||
</linearGradient>
|
||||
<radialGradient id="cre-star-bloom" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0%" stop-color="#FFFFFF" />
|
||||
<stop offset="35%" stop-color="#38BDF8" stop-opacity="0.95" />
|
||||
<stop offset="70%" stop-color="#818CF8" stop-opacity="0.4" />
|
||||
<stop offset="100%" stop-color="#0284C7" stop-opacity="0" />
|
||||
</radialGradient>
|
||||
<radialGradient id="cre-bg-cosmic" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0%" stop-color="#1E293B" />
|
||||
<stop offset="60%" stop-color="#0F172A" />
|
||||
<stop offset="100%" stop-color="#020617" />
|
||||
</radialGradient>
|
||||
</defs>
|
||||
|
||||
<!-- Cosmic Background Disc -->
|
||||
<circle cx="50" cy="50" r="48" fill="url(#cre-bg-cosmic)" />
|
||||
|
||||
<!-- Outer Orbiting Energy Ring -->
|
||||
<circle cx="50" cy="50" r="41" stroke="rgba(56, 189, 248, 0.45)" stroke-width="1.5" stroke-dasharray="4 6" />
|
||||
<circle cx="50" cy="9" r="3" fill="#00F5FF" />
|
||||
<circle cx="91" cy="50" r="2.5" fill="#EC4899" />
|
||||
<circle cx="15" cy="70" r="2.5" fill="#FACC15" />
|
||||
|
||||
<!-- Inner Counter-Orbiting Track -->
|
||||
<circle cx="50" cy="50" r="33" stroke="rgba(168, 85, 247, 0.35)" stroke-width="1" stroke-dasharray="2 4" />
|
||||
|
||||
<!-- Faceted Quantum Crystal Prism -->
|
||||
<polygon points="50,16 62,38 50,50 38,38" fill="url(#cre-bright-cyan)" opacity="0.95" />
|
||||
<polygon points="84,50 62,62 50,50 62,38" fill="url(#cre-bright-purple)" opacity="0.95" />
|
||||
<polygon points="50,84 38,62 50,50 62,62" fill="url(#cre-bright-gold)" opacity="0.95" />
|
||||
<polygon points="16,50 38,38 50,50 38,62" fill="url(#cre-bright-teal)" opacity="0.95" />
|
||||
|
||||
<polygon points="50,50 62,38 72,28 62,28" fill="#38BDF8" opacity="0.8" />
|
||||
<polygon points="50,50 62,62 72,72 72,62" fill="#EC4899" opacity="0.8" />
|
||||
<polygon points="50,50 38,62 28,72 38,72" fill="#FACC15" opacity="0.8" />
|
||||
<polygon points="50,50 38,38 28,28 28,38" fill="#10B981" opacity="0.8" />
|
||||
|
||||
<line x1="50" y1="16" x2="50" y2="84" stroke="#FFFFFF" stroke-width="1.2" opacity="0.85" />
|
||||
<line x1="16" y1="50" x2="84" y2="50" stroke="#FFFFFF" stroke-width="1.2" opacity="0.85" />
|
||||
<line x1="26" y1="26" x2="74" y2="74" stroke="#FFFFFF" stroke-width="0.8" opacity="0.6" />
|
||||
<line x1="74" y1="26" x2="26" y2="74" stroke="#FFFFFF" stroke-width="0.8" opacity="0.6" />
|
||||
|
||||
<!-- Radiant Core Bloom -->
|
||||
<circle cx="50" cy="50" r="14" fill="url(#cre-star-bloom)" />
|
||||
<circle cx="50" cy="50" r="5" fill="#FFFFFF" />
|
||||
<polygon points="50,42 52,50 50,58 48,50" fill="#FFFFFF" />
|
||||
<polygon points="42,50 50,52 58,50 50,48" fill="#FFFFFF" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.3 KiB |
@@ -87,45 +87,59 @@ export function SmoothCursor() {
|
||||
|
||||
// 2. Touch Handlers (Full Mobile, Tablet, iPad & Touchscreen Compatibility)
|
||||
const onTouchStart = (e: TouchEvent) => {
|
||||
if (!e.touches || e.touches.length === 0) return;
|
||||
isTouchActive = true;
|
||||
if (fadeTimeout) clearTimeout(fadeTimeout);
|
||||
try {
|
||||
if (!e.touches || e.touches.length === 0) return;
|
||||
isTouchActive = true;
|
||||
if (fadeTimeout) clearTimeout(fadeTimeout);
|
||||
|
||||
const touch = e.touches[0];
|
||||
mouseX = touch.clientX;
|
||||
mouseY = touch.clientY;
|
||||
const touch = e.touches[0];
|
||||
if (!touch) return;
|
||||
mouseX = touch.clientX;
|
||||
mouseY = touch.clientY;
|
||||
|
||||
// If opening fresh, snap directly to finger touch point
|
||||
if (!isVisible) {
|
||||
lensX = mouseX;
|
||||
lensY = mouseY;
|
||||
prevMouseX = mouseX;
|
||||
prevMouseY = mouseY;
|
||||
isVisible = true;
|
||||
lens.style.opacity = '1';
|
||||
if (caustic) caustic.style.opacity = '1';
|
||||
// If opening fresh, snap directly to finger touch point
|
||||
if (!isVisible) {
|
||||
lensX = mouseX;
|
||||
lensY = mouseY;
|
||||
prevMouseX = mouseX;
|
||||
prevMouseY = mouseY;
|
||||
isVisible = true;
|
||||
lens.style.opacity = '1';
|
||||
if (caustic) caustic.style.opacity = '1';
|
||||
}
|
||||
// On touch, hide the tiny dot (the finger is right there)
|
||||
dot.style.opacity = '0';
|
||||
isPressed = true;
|
||||
} catch {
|
||||
// Safe failover
|
||||
}
|
||||
// On touch, hide the tiny dot (the finger is right there)
|
||||
dot.style.opacity = '0';
|
||||
isPressed = true;
|
||||
};
|
||||
|
||||
const onTouchMove = (e: TouchEvent) => {
|
||||
if (!e.touches || e.touches.length === 0) return;
|
||||
const touch = e.touches[0];
|
||||
mouseX = touch.clientX;
|
||||
mouseY = touch.clientY;
|
||||
try {
|
||||
if (!e.touches || e.touches.length === 0) return;
|
||||
const touch = e.touches[0];
|
||||
if (!touch) return;
|
||||
mouseX = touch.clientX;
|
||||
mouseY = touch.clientY;
|
||||
} catch {
|
||||
// Safe failover
|
||||
}
|
||||
};
|
||||
|
||||
const onTouchEnd = () => {
|
||||
isPressed = false;
|
||||
// Graceful liquid fade out after touch interaction completes
|
||||
if (fadeTimeout) clearTimeout(fadeTimeout);
|
||||
fadeTimeout = setTimeout(() => {
|
||||
isVisible = false;
|
||||
lens.style.opacity = '0';
|
||||
if (caustic) caustic.style.opacity = '0';
|
||||
}, 350);
|
||||
try {
|
||||
isPressed = false;
|
||||
// Graceful liquid fade out after touch interaction completes
|
||||
if (fadeTimeout) clearTimeout(fadeTimeout);
|
||||
fadeTimeout = setTimeout(() => {
|
||||
isVisible = false;
|
||||
if (lens) lens.style.opacity = '0';
|
||||
if (caustic) caustic.style.opacity = '0';
|
||||
}, 350);
|
||||
} catch {
|
||||
// Safe failover
|
||||
}
|
||||
};
|
||||
|
||||
// Throttled interactive element detection for magnetic lens scaling
|
||||
@@ -135,9 +149,12 @@ export function SmoothCursor() {
|
||||
if (now - lastCheck < 25) return;
|
||||
lastCheck = now;
|
||||
|
||||
const target = e.target as HTMLElement | null;
|
||||
const target = e.target as Node | null;
|
||||
if (!target) return;
|
||||
const interactive = target.closest('a, button, input, textarea, select, [role="button"], .cursor-pointer, [data-interactive]');
|
||||
const element = (target instanceof Element ? target : target.parentElement) as HTMLElement | null;
|
||||
if (!element || typeof element.closest !== 'function') return;
|
||||
|
||||
const interactive = element.closest('a, button, input, textarea, select, [role="button"], .cursor-pointer, [data-interactive]');
|
||||
isHovered = !!interactive;
|
||||
};
|
||||
|
||||
|
||||
@@ -453,18 +453,16 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
||||
const masterGroup = new THREE.Group();
|
||||
scene.add(masterGroup);
|
||||
|
||||
// 1. Central Optical Translucent Crystal (Icosahedron, non-obstructive)
|
||||
// 1. Central Optical Translucent Crystal (Icosahedron, mobile GPU safe)
|
||||
const crystalGeo = new THREE.IcosahedronGeometry(1.25, 0);
|
||||
const crystalMat = new THREE.MeshPhysicalMaterial({
|
||||
const crystalMat = new THREE.MeshStandardMaterial({
|
||||
color: 0x3b82f6,
|
||||
emissive: 0x1d4ed8,
|
||||
emissiveIntensity: 0.1,
|
||||
roughness: 0.15,
|
||||
emissiveIntensity: 0.12,
|
||||
roughness: 0.18,
|
||||
metalness: 0.1,
|
||||
transmission: 0.9,
|
||||
transparent: true,
|
||||
opacity: 0.11,
|
||||
ior: 1.4,
|
||||
opacity: 0.14,
|
||||
});
|
||||
const crystal = new THREE.Mesh(crystalGeo, crystalMat);
|
||||
masterGroup.add(crystal);
|
||||
@@ -568,11 +566,24 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
||||
particles.rotation.y = elapsed * 0.03;
|
||||
particles.rotation.x = elapsed * 0.02;
|
||||
|
||||
if (renderer) renderer.render(scene, camera);
|
||||
if (renderer) {
|
||||
try {
|
||||
renderer.render(scene, camera);
|
||||
} catch {
|
||||
cancelAnimationFrame(animId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
animate();
|
||||
|
||||
const canvas = renderer.domElement;
|
||||
const handleContextLost = (e: Event) => {
|
||||
e.preventDefault();
|
||||
cancelAnimationFrame(animId);
|
||||
};
|
||||
canvas.addEventListener('webglcontextlost', handleContextLost, false);
|
||||
|
||||
const handleResize = () => {
|
||||
if (!container || !renderer) return;
|
||||
const w = container.clientWidth;
|
||||
@@ -587,6 +598,7 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
||||
return () => {
|
||||
cancelAnimationFrame(animId);
|
||||
observer.disconnect();
|
||||
canvas.removeEventListener('webglcontextlost', handleContextLost);
|
||||
window.removeEventListener('resize', handleResize);
|
||||
if (renderer && renderer.domElement && container.contains(renderer.domElement)) {
|
||||
container.removeChild(renderer.domElement);
|
||||
|
||||
@@ -25,49 +25,63 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
|
||||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
if (prefersReducedMotion) return;
|
||||
|
||||
// Initialize ultra-lightweight Lenis instance
|
||||
const lenis = new Lenis({
|
||||
duration: 1.15,
|
||||
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // Silky exponential ease-out
|
||||
orientation: 'vertical',
|
||||
gestureOrientation: 'vertical',
|
||||
smoothWheel: true,
|
||||
wheelMultiplier: 0.95,
|
||||
touchMultiplier: 1.25,
|
||||
infinite: false,
|
||||
});
|
||||
|
||||
// Expose lenis instance globally for programmatic scrolling
|
||||
(window as any).__lenis = lenis;
|
||||
|
||||
// Locked high-frequency RAF loop
|
||||
let lenis: Lenis | null = null;
|
||||
let animId = 0;
|
||||
const raf = (time: number) => {
|
||||
lenis.raf(time);
|
||||
|
||||
try {
|
||||
// Initialize ultra-lightweight Lenis instance
|
||||
lenis = new Lenis({
|
||||
duration: 1.15,
|
||||
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // Silky exponential ease-out
|
||||
orientation: 'vertical',
|
||||
gestureOrientation: 'vertical',
|
||||
smoothWheel: true,
|
||||
syncTouch: false, // Preserves native 120Hz iOS/Android touch momentum without interference
|
||||
wheelMultiplier: 0.95,
|
||||
touchMultiplier: 1.0,
|
||||
infinite: false,
|
||||
});
|
||||
|
||||
// Expose lenis instance globally for programmatic scrolling
|
||||
(window as any).__lenis = lenis;
|
||||
|
||||
// Locked high-frequency RAF loop
|
||||
const raf = (time: number) => {
|
||||
lenis?.raf(time);
|
||||
animId = requestAnimationFrame(raf);
|
||||
};
|
||||
animId = requestAnimationFrame(raf);
|
||||
};
|
||||
animId = requestAnimationFrame(raf);
|
||||
} catch {
|
||||
// Fallback silently to native smooth scrolling
|
||||
}
|
||||
|
||||
// Intercept in-page anchor links for seamless animated scrolling
|
||||
// Intercept in-page anchor links for seamless animated scrolling (safe on text nodes on mobile)
|
||||
const handleAnchorClick = (e: MouseEvent) => {
|
||||
const target = e.target as HTMLElement | null;
|
||||
if (!target) return;
|
||||
|
||||
const anchor = target.closest('a[href^="#"]') as HTMLAnchorElement | null;
|
||||
if (!anchor) return;
|
||||
|
||||
const href = anchor.getAttribute('href');
|
||||
if (!href || href === '#' || href === '#!') return;
|
||||
|
||||
try {
|
||||
const target = e.target as Node | null;
|
||||
if (!target) return;
|
||||
|
||||
const element = (target instanceof Element ? target : target.parentElement) as HTMLElement | null;
|
||||
if (!element || typeof element.closest !== 'function') return;
|
||||
|
||||
const anchor = element.closest('a[href^="#"]') as HTMLAnchorElement | null;
|
||||
if (!anchor) return;
|
||||
|
||||
const href = anchor.getAttribute('href');
|
||||
if (!href || href === '#' || href === '#!') return;
|
||||
|
||||
const targetElement = document.querySelector(href);
|
||||
if (targetElement) {
|
||||
e.preventDefault();
|
||||
lenis.scrollTo(targetElement as HTMLElement, {
|
||||
offset: -80, // Offset for floating glass navbar
|
||||
duration: 1.25,
|
||||
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
||||
});
|
||||
if (lenis) {
|
||||
lenis.scrollTo(targetElement as HTMLElement, {
|
||||
offset: -80, // Offset for floating glass navbar
|
||||
duration: 1.25,
|
||||
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
||||
});
|
||||
} else {
|
||||
targetElement.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Fallback gracefully to default navigation if querySelector fails
|
||||
@@ -79,7 +93,7 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
|
||||
return () => {
|
||||
cancelAnimationFrame(animId);
|
||||
document.removeEventListener('click', handleAnchorClick, { capture: true });
|
||||
lenis.destroy();
|
||||
lenis?.destroy();
|
||||
delete (window as any).__lenis;
|
||||
};
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user