This commit is contained in:
cybrneko 2025-05-10 22:29:01 -05:00
parent e971a3d7ab
commit 427a84d823

View File

@ -105,18 +105,18 @@
document.body.appendChild(nekoEl); document.body.appendChild(nekoEl);
// Attach event listeners for both desktop and mobile // Desktop: Track mouse movement
document.addEventListener('mousemove', function (event) { document.addEventListener('mousemove', function (event) {
mousePosX = event.clientX; mousePosX = event.clientX;
mousePosY = event.clientY; mousePosY = event.clientY;
}); });
// Mobile: Track touch movement (including during scrolling)
document.addEventListener('touchmove', function (event) { document.addEventListener('touchmove', function (event) {
// Use the first touch point (primary touch) const touch = event.touches[0]; // Use the first touch point
const touch = event.touches[0];
mousePosX = touch.clientX; mousePosX = touch.clientX;
mousePosY = touch.clientY; mousePosY = touch.clientY;
}, { passive: false }); // Allow preventing default if needed }, { passive: true });
window.requestAnimationFrame(onAnimationFrame); window.requestAnimationFrame(onAnimationFrame);
} }