Remove ol.DRAG_BOX_HYSTERESIS_PIXELS define and add option

This commit is contained in:
Frederic Junod
2017-04-07 15:31:59 +02:00
parent d767f8545f
commit 5c6c555b62
3 changed files with 20 additions and 30 deletions

View File

@@ -47,12 +47,6 @@ ol.DEFAULT_TILE_SIZE = 256;
ol.DEFAULT_WMS_VERSION = '1.3.0';
/**
* @define {number} Hysteresis pixels.
*/
ol.DRAG_BOX_HYSTERESIS_PIXELS = 8;
/**
* @define {boolean} Enable the Canvas renderer. Default is `true`. Setting
* this to false at compile time in advanced mode removes all code

View File

@@ -8,15 +8,6 @@ goog.require('ol.interaction.Pointer');
goog.require('ol.render.Box');
/**
* @const
* @type {number}
*/
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED =
ol.DRAG_BOX_HYSTERESIS_PIXELS *
ol.DRAG_BOX_HYSTERESIS_PIXELS;
/**
* @classdesc
* Allows the user to draw a vector box by clicking and dragging on the map,
@@ -50,6 +41,12 @@ ol.interaction.DragBox = function(opt_options) {
*/
this.box_ = new ol.render.Box(options.className || 'ol-dragbox');
/**
* @type {number}
* @private
*/
this.minArea_ = options.minArea !== undefined ? options.minArea : 64;
/**
* @type {ol.Pixel}
* @private
@@ -82,12 +79,10 @@ ol.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
* @param {ol.Pixel} endPixel The end pixel of the box.
* @return {boolean} Whether or not the boxend condition should be fired.
*/
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent,
startPixel, endPixel) {
ol.interaction.DragBox.defaultBoxEndCondition = function(mapBrowserEvent, startPixel, endPixel) {
var width = endPixel[0] - startPixel[0];
var height = endPixel[1] - startPixel[1];
return width * width + height * height >=
ol.DRAG_BOX_HYSTERESIS_PIXELS_SQUARED;
return width * width + height * height >= this.minArea_;
};