fix(mobile): resolve mobile touch runtime errors, webgl transmission GPU stall and add root icon

This commit is contained in:
2026-11-05 11:42:47 +05:30
parent d20f98cb36
commit 35a615f4ea
4 changed files with 184 additions and 76 deletions
+49 -32
View File
@@ -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;
};