Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve mousemove/mouseup when dragging outside the game canvas #118

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions scripts/device/iOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ function positionHandler(e)
case 'MSPointerUp':
case 'pointercancel':
case 'MSPointerCancel':
case 'pointerout':
case 'MSPointerOut':
mouseDevice = getExistingMouseDevice(e["pointerId"]);
// RK :: Wallpaper Engine on Windows is not generating the "pointerdown" event it jumps straight to "pointerover",
// to work around this we pretend this is the "pointerdown" then everything starts to work.
Expand Down Expand Up @@ -416,8 +414,13 @@ function positionHandler(e)
}
} // end if

// Don't allow the user to move the page around
e.preventDefault();
// Don't prevent default on pointerdown events,
// otherwise pointerup events wont be triggered if the
// user releases the mouse outside the game canvas.
if (e.type != "pointerdown") {
// Don't allow the user to move the page around
e.preventDefault();
}
}

// #############################################################################################
Expand All @@ -433,17 +436,15 @@ function bindTouchEvents()
if ((window.PointerEvent) || (window.navigator.pointerEnabled)||(window.navigator.msPointerEnabled)) {

canvas.addEventListener( "pointerdown", positionHandler, false );
canvas.addEventListener( "pointermove", positionHandler, false );
window.addEventListener( "pointermove", positionHandler, false );
canvas.addEventListener( "pointerup", positionHandler, false );
canvas.addEventListener( "pointercancel", positionHandler, false );
canvas.addEventListener( "pointerover", positionHandler, false );
canvas.addEventListener( "pointerout", positionHandler, false );
canvas.addEventListener( "MSPointerDown", positionHandler, false );
canvas.addEventListener( "MSPointerMove", positionHandler, false );
canvas.addEventListener( "MSPointerUp", positionHandler, false );
window.addEventListener( "MSPointerUp", positionHandler, false );
canvas.addEventListener( "MSPointerCancel", positionHandler, false );
canvas.addEventListener( "MSPointerOver", positionHandler, false );
canvas.addEventListener( "MSPointerOut", positionHandler, false );

} // end if
else {
Expand Down