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)
|
// 2. Touch Handlers (Full Mobile, Tablet, iPad & Touchscreen Compatibility)
|
||||||
const onTouchStart = (e: TouchEvent) => {
|
const onTouchStart = (e: TouchEvent) => {
|
||||||
if (!e.touches || e.touches.length === 0) return;
|
try {
|
||||||
isTouchActive = true;
|
if (!e.touches || e.touches.length === 0) return;
|
||||||
if (fadeTimeout) clearTimeout(fadeTimeout);
|
isTouchActive = true;
|
||||||
|
if (fadeTimeout) clearTimeout(fadeTimeout);
|
||||||
|
|
||||||
const touch = e.touches[0];
|
const touch = e.touches[0];
|
||||||
mouseX = touch.clientX;
|
if (!touch) return;
|
||||||
mouseY = touch.clientY;
|
mouseX = touch.clientX;
|
||||||
|
mouseY = touch.clientY;
|
||||||
|
|
||||||
// If opening fresh, snap directly to finger touch point
|
// If opening fresh, snap directly to finger touch point
|
||||||
if (!isVisible) {
|
if (!isVisible) {
|
||||||
lensX = mouseX;
|
lensX = mouseX;
|
||||||
lensY = mouseY;
|
lensY = mouseY;
|
||||||
prevMouseX = mouseX;
|
prevMouseX = mouseX;
|
||||||
prevMouseY = mouseY;
|
prevMouseY = mouseY;
|
||||||
isVisible = true;
|
isVisible = true;
|
||||||
lens.style.opacity = '1';
|
lens.style.opacity = '1';
|
||||||
if (caustic) caustic.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) => {
|
const onTouchMove = (e: TouchEvent) => {
|
||||||
if (!e.touches || e.touches.length === 0) return;
|
try {
|
||||||
const touch = e.touches[0];
|
if (!e.touches || e.touches.length === 0) return;
|
||||||
mouseX = touch.clientX;
|
const touch = e.touches[0];
|
||||||
mouseY = touch.clientY;
|
if (!touch) return;
|
||||||
|
mouseX = touch.clientX;
|
||||||
|
mouseY = touch.clientY;
|
||||||
|
} catch {
|
||||||
|
// Safe failover
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onTouchEnd = () => {
|
const onTouchEnd = () => {
|
||||||
isPressed = false;
|
try {
|
||||||
// Graceful liquid fade out after touch interaction completes
|
isPressed = false;
|
||||||
if (fadeTimeout) clearTimeout(fadeTimeout);
|
// Graceful liquid fade out after touch interaction completes
|
||||||
fadeTimeout = setTimeout(() => {
|
if (fadeTimeout) clearTimeout(fadeTimeout);
|
||||||
isVisible = false;
|
fadeTimeout = setTimeout(() => {
|
||||||
lens.style.opacity = '0';
|
isVisible = false;
|
||||||
if (caustic) caustic.style.opacity = '0';
|
if (lens) lens.style.opacity = '0';
|
||||||
}, 350);
|
if (caustic) caustic.style.opacity = '0';
|
||||||
|
}, 350);
|
||||||
|
} catch {
|
||||||
|
// Safe failover
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Throttled interactive element detection for magnetic lens scaling
|
// Throttled interactive element detection for magnetic lens scaling
|
||||||
@@ -135,9 +149,12 @@ export function SmoothCursor() {
|
|||||||
if (now - lastCheck < 25) return;
|
if (now - lastCheck < 25) return;
|
||||||
lastCheck = now;
|
lastCheck = now;
|
||||||
|
|
||||||
const target = e.target as HTMLElement | null;
|
const target = e.target as Node | null;
|
||||||
if (!target) return;
|
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;
|
isHovered = !!interactive;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -453,18 +453,16 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
|||||||
const masterGroup = new THREE.Group();
|
const masterGroup = new THREE.Group();
|
||||||
scene.add(masterGroup);
|
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 crystalGeo = new THREE.IcosahedronGeometry(1.25, 0);
|
||||||
const crystalMat = new THREE.MeshPhysicalMaterial({
|
const crystalMat = new THREE.MeshStandardMaterial({
|
||||||
color: 0x3b82f6,
|
color: 0x3b82f6,
|
||||||
emissive: 0x1d4ed8,
|
emissive: 0x1d4ed8,
|
||||||
emissiveIntensity: 0.1,
|
emissiveIntensity: 0.12,
|
||||||
roughness: 0.15,
|
roughness: 0.18,
|
||||||
metalness: 0.1,
|
metalness: 0.1,
|
||||||
transmission: 0.9,
|
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.11,
|
opacity: 0.14,
|
||||||
ior: 1.4,
|
|
||||||
});
|
});
|
||||||
const crystal = new THREE.Mesh(crystalGeo, crystalMat);
|
const crystal = new THREE.Mesh(crystalGeo, crystalMat);
|
||||||
masterGroup.add(crystal);
|
masterGroup.add(crystal);
|
||||||
@@ -568,11 +566,24 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
|||||||
particles.rotation.y = elapsed * 0.03;
|
particles.rotation.y = elapsed * 0.03;
|
||||||
particles.rotation.x = elapsed * 0.02;
|
particles.rotation.x = elapsed * 0.02;
|
||||||
|
|
||||||
if (renderer) renderer.render(scene, camera);
|
if (renderer) {
|
||||||
|
try {
|
||||||
|
renderer.render(scene, camera);
|
||||||
|
} catch {
|
||||||
|
cancelAnimationFrame(animId);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
animate();
|
animate();
|
||||||
|
|
||||||
|
const canvas = renderer.domElement;
|
||||||
|
const handleContextLost = (e: Event) => {
|
||||||
|
e.preventDefault();
|
||||||
|
cancelAnimationFrame(animId);
|
||||||
|
};
|
||||||
|
canvas.addEventListener('webglcontextlost', handleContextLost, false);
|
||||||
|
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
if (!container || !renderer) return;
|
if (!container || !renderer) return;
|
||||||
const w = container.clientWidth;
|
const w = container.clientWidth;
|
||||||
@@ -587,6 +598,7 @@ function Hero3DCanvas({ className }: { className?: string }) {
|
|||||||
return () => {
|
return () => {
|
||||||
cancelAnimationFrame(animId);
|
cancelAnimationFrame(animId);
|
||||||
observer.disconnect();
|
observer.disconnect();
|
||||||
|
canvas.removeEventListener('webglcontextlost', handleContextLost);
|
||||||
window.removeEventListener('resize', handleResize);
|
window.removeEventListener('resize', handleResize);
|
||||||
if (renderer && renderer.domElement && container.contains(renderer.domElement)) {
|
if (renderer && renderer.domElement && container.contains(renderer.domElement)) {
|
||||||
container.removeChild(renderer.domElement);
|
container.removeChild(renderer.domElement);
|
||||||
|
|||||||
@@ -25,49 +25,63 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
|
|||||||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
if (prefersReducedMotion) return;
|
if (prefersReducedMotion) return;
|
||||||
|
|
||||||
// Initialize ultra-lightweight Lenis instance
|
let lenis: Lenis | null = null;
|
||||||
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 animId = 0;
|
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 {
|
||||||
animId = requestAnimationFrame(raf);
|
// 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 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 {
|
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);
|
const targetElement = document.querySelector(href);
|
||||||
if (targetElement) {
|
if (targetElement) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
lenis.scrollTo(targetElement as HTMLElement, {
|
if (lenis) {
|
||||||
offset: -80, // Offset for floating glass navbar
|
lenis.scrollTo(targetElement as HTMLElement, {
|
||||||
duration: 1.25,
|
offset: -80, // Offset for floating glass navbar
|
||||||
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
duration: 1.25,
|
||||||
});
|
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
targetElement.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Fallback gracefully to default navigation if querySelector fails
|
// Fallback gracefully to default navigation if querySelector fails
|
||||||
@@ -79,7 +93,7 @@ export function SmoothScrollProvider({ children }: SmoothScrollProviderProps) {
|
|||||||
return () => {
|
return () => {
|
||||||
cancelAnimationFrame(animId);
|
cancelAnimationFrame(animId);
|
||||||
document.removeEventListener('click', handleAnchorClick, { capture: true });
|
document.removeEventListener('click', handleAnchorClick, { capture: true });
|
||||||
lenis.destroy();
|
lenis?.destroy();
|
||||||
delete (window as any).__lenis;
|
delete (window as any).__lenis;
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
Reference in New Issue
Block a user