Merge pull request #6834 from notnotse/move-tolerance-option

Move tolerance option
This commit is contained in:
Andreas Hocevar
2017-05-30 09:10:09 +02:00
committed by GitHub
4 changed files with 73 additions and 3 deletions

View File

@@ -278,7 +278,7 @@ ol.Map = function(options) {
* @private
* @type {ol.MapBrowserEventHandler}
*/
this.mapBrowserEventHandler_ = new ol.MapBrowserEventHandler(this);
this.mapBrowserEventHandler_ = new ol.MapBrowserEventHandler(this, options.moveTolerance);
for (var key in ol.MapBrowserEventType) {
ol.events.listen(this.mapBrowserEventHandler_, ol.MapBrowserEventType[key],
this.handleMapBrowserEvent, this);

View File

@@ -12,10 +12,11 @@ goog.require('ol.pointer.PointerEventHandler');
/**
* @param {ol.Map} map The map with the viewport to listen to events on.
* @param {number|undefined} moveTolerance The minimal distance the pointer must travel to trigger a move.
* @constructor
* @extends {ol.events.EventTarget}
*/
ol.MapBrowserEventHandler = function(map) {
ol.MapBrowserEventHandler = function(map, moveTolerance) {
ol.events.EventTarget.call(this);
@@ -48,7 +49,8 @@ ol.MapBrowserEventHandler = function(map) {
* @type {number}
* @private
*/
this.moveTolerance_ = ol.has.DEVICE_PIXEL_RATIO;
this.moveTolerance_ = moveTolerance ?
moveTolerance * ol.has.DEVICE_PIXEL_RATIO : ol.has.DEVICE_PIXEL_RATIO;
/**
* The most recent "down" type event (or null if none have occurred).