Add a small tolerance when testing pointer event positions
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
goog.provide('ol.MapBrowserEventHandler');
|
goog.provide('ol.MapBrowserEventHandler');
|
||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
|
goog.require('ol.has');
|
||||||
goog.require('ol.MapBrowserEventType');
|
goog.require('ol.MapBrowserEventType');
|
||||||
goog.require('ol.MapBrowserPointerEvent');
|
goog.require('ol.MapBrowserPointerEvent');
|
||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
@@ -43,6 +44,12 @@ ol.MapBrowserEventHandler = function(map) {
|
|||||||
*/
|
*/
|
||||||
this.dragListenerKeys_ = [];
|
this.dragListenerKeys_ = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {number}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.moveTolerance_ = ol.has.DEVICE_PIXEL_RATIO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The most recent "down" type event (or null if none have occurred).
|
* The most recent "down" type event (or null if none have occurred).
|
||||||
* Set on pointerdown.
|
* Set on pointerdown.
|
||||||
@@ -241,11 +248,9 @@ ol.MapBrowserEventHandler.prototype.handlePointerDown_ = function(pointerEvent)
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
|
ol.MapBrowserEventHandler.prototype.handlePointerMove_ = function(pointerEvent) {
|
||||||
// Fix IE10 on windows Surface : When you tap the tablet, it triggers
|
// Between pointerdown and pointerup, pointermove events are triggered.
|
||||||
// multiple pointermove events between pointerdown and pointerup with
|
// To avoid a 'false' touchmove event to be dispatched, we test if the pointer
|
||||||
// the exact same coordinates of the pointerdown event. To avoid a
|
// moved a significant distance.
|
||||||
// 'false' touchmove event to be dispatched , we test if the pointer
|
|
||||||
// effectively moved.
|
|
||||||
if (this.isMoving_(pointerEvent)) {
|
if (this.isMoving_(pointerEvent)) {
|
||||||
this.dragging_ = true;
|
this.dragging_ = true;
|
||||||
var newEvent = new ol.MapBrowserPointerEvent(
|
var newEvent = new ol.MapBrowserPointerEvent(
|
||||||
@@ -281,8 +286,8 @@ ol.MapBrowserEventHandler.prototype.relayEvent_ = function(pointerEvent) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
|
ol.MapBrowserEventHandler.prototype.isMoving_ = function(pointerEvent) {
|
||||||
return pointerEvent.clientX != this.down_.clientX ||
|
return Math.abs(pointerEvent.clientX - this.down_.clientX) > this.moveTolerance_ ||
|
||||||
pointerEvent.clientY != this.down_.clientY;
|
Math.abs(pointerEvent.clientY - this.down_.clientY) > this.moveTolerance_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user