mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Interaction: MSPointer: Optimize by ignoring MSPointerMove events with the same x/y coords as the previous event.
This commit is contained in:
parent
f09288d18f
commit
3ffb6c6a2e
20
ui/jquery.ui.interaction.js
vendored
20
ui/jquery.ui.interaction.js
vendored
@ -188,7 +188,9 @@ var pointerHook = interaction.hooks.msPointer = {
|
|||||||
|
|
||||||
handle: function( widget ) {
|
handle: function( widget ) {
|
||||||
function move( _event ) {
|
function move( _event ) {
|
||||||
var event = _event.originalEvent;
|
var event = _event.originalEvent,
|
||||||
|
pageX = event.pageX,
|
||||||
|
pageY = event.pageY;
|
||||||
|
|
||||||
// always prevent manipulation to avoid panning/zooming
|
// always prevent manipulation to avoid panning/zooming
|
||||||
event.preventManipulation();
|
event.preventManipulation();
|
||||||
@ -197,9 +199,17 @@ var pointerHook = interaction.hooks.msPointer = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MS streams events constantly, even if there is no movement
|
||||||
|
// so we optimize by ignoring repeat events
|
||||||
|
if ( pointerHook.x === pageX && pointerHook.y === pageY ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointerHook.x = pageX;
|
||||||
|
pointerHook.y = pageY;
|
||||||
widget._interactionMove( event, {
|
widget._interactionMove( event, {
|
||||||
left: event.pageX,
|
left: pageX,
|
||||||
top: event.pageY
|
top: pageY
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +224,9 @@ var pointerHook = interaction.hooks.msPointer = {
|
|||||||
left: event.pageX,
|
left: event.pageX,
|
||||||
top: event.pageY
|
top: event.pageY
|
||||||
});
|
});
|
||||||
pointerHook.id = null;
|
pointerHook.id = undefined;
|
||||||
|
pointerHook.x = undefined;
|
||||||
|
pointerHook.y = undefined;
|
||||||
widget.document
|
widget.document
|
||||||
.unbind( "MSPointerMove", move )
|
.unbind( "MSPointerMove", move )
|
||||||
.unbind( "MSPointerUp", stop )
|
.unbind( "MSPointerUp", stop )
|
||||||
|
Loading…
Reference in New Issue
Block a user