fix: handle left-button touch cancel and contextmenu cleanup

This commit is contained in:
wenjie
2026-05-20 14:49:33 +08:00
parent 961d7f2e89
commit fe34008ce3
2 changed files with 2 additions and 2 deletions

View File

@@ -234,7 +234,7 @@ export const Absolute = () => {
longPressTimerRef.current = null;
}
if (pressedButtonRef.current) {
if (pressedButtonRef.current !== null) {
handleMouseEvent({ type: 'mouseup', button: pressedButtonRef.current! });
}

View File

@@ -33,7 +33,7 @@ export const Relative = () => {
screen.addEventListener('mouseup', handleMouseUp);
screen.addEventListener('mousemove', handleMouseMove);
screen.addEventListener('wheel', handleMouseWheel, { passive: false });
screen.addEventListener('contextmenu', (e) => e.preventDefault());
screen.addEventListener('contextmenu', disableEvent);
document.addEventListener('pointerlockchange', handlePointerLockChange);
// Mouse click event