Skip to content

Commit

Permalink
Add a small tolerance when testing pointer event positions
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed May 9, 2017
1 parent 735ab45 commit 7b719cd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/ol/mapbrowsereventhandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,9 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent)
* @private
*/
ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
// Fix IE10 on windows Surface : When you tap the tablet, it triggers
// multiple pointermove events between pointerdown and pointerup with
// the exact same coordinates of the pointerdown event. To avoid a
// 'false' touchmove event to be dispatched , we test if the pointer
// effectively moved.
// Between pointerdown and pointerup, pointermove events are triggered.
// To avoid a 'false' touchmove event to be dispatched, we test if the pointer
// moved a significant distance.
if (this.isMoving_(pointerEvent)) {
this.dragging_ = true;
var newEvent = new ol.MapBrowserPointerEvent(
Expand Down Expand Up @@ -281,8 +279,8 @@ ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
* @private
*/
ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
return pointerEvent.clientX != this.down_.clientX ||
pointerEvent.clientY != this.down_.clientY;
return Math.abs(pointerEvent.clientX - this.down_.clientX) > 0.75 ||
Math.abs(pointerEvent.clientY - this.down_.clientY) > 0.75;
};


Expand Down

0 comments on commit 7b719cd

Please sign in to comment.