Merge pull request #3549 from fredj/keyboard_pan_duration
Move ol.*_DURATION const to a constructor option
This commit is contained in:
@@ -14,7 +14,6 @@ goog.require('goog.fx.Dragger.EventType');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.math.Rect');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Size');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.animation');
|
||||
@@ -73,6 +72,12 @@ ol.control.ZoomSlider = function(opt_options) {
|
||||
*/
|
||||
this.sliderInitialized_ = false;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 200;
|
||||
|
||||
var className = goog.isDef(options.className) ?
|
||||
options.className : 'ol-zoomslider';
|
||||
var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||
@@ -203,7 +208,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
|
||||
'currentResolution should be defined');
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: currentResolution,
|
||||
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
duration: this.duration_,
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
var relativePosition = this.getRelativePosition_(
|
||||
@@ -250,7 +255,7 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
|
||||
'this.currentResolution_ should be defined');
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: this.currentResolution_,
|
||||
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
duration: this.duration_,
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
var resolution = view.constrainResolution(this.currentResolution_);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.interaction.DragRotateAndZoom');
|
||||
|
||||
goog.require('goog.math.Vec2');
|
||||
goog.require('ol');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.events.ConditionType');
|
||||
goog.require('ol.events.condition');
|
||||
@@ -60,6 +59,12 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
|
||||
*/
|
||||
this.lastScaleDelta_ = 0;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 400;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Pointer);
|
||||
|
||||
@@ -120,8 +125,7 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
var direction = this.lastScaleDelta_ - 1;
|
||||
ol.interaction.Interaction.rotate(map, view, viewState.rotation);
|
||||
ol.interaction.Interaction.zoom(map, view, viewState.resolution,
|
||||
undefined, ol.DRAGROTATEANDZOOM_ANIMATION_DURATION,
|
||||
direction);
|
||||
undefined, this.duration_, direction);
|
||||
this.lastScaleDelta_ = 0;
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.interaction.DragRotate');
|
||||
|
||||
goog.require('ol');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.events.ConditionType');
|
||||
goog.require('ol.events.condition');
|
||||
@@ -45,6 +44,11 @@ ol.interaction.DragRotate = function(opt_options) {
|
||||
*/
|
||||
this.lastAngle_ = undefined;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
|
||||
};
|
||||
goog.inherits(ol.interaction.DragRotate, ol.interaction.Pointer);
|
||||
|
||||
@@ -92,7 +96,7 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
var rotation = view.getRotation();
|
||||
ol.interaction.Interaction.rotate(map, view, rotation,
|
||||
undefined, ol.DRAGROTATE_ANIMATION_DURATION);
|
||||
undefined, this.duration_);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
goog.provide('ol.interaction.DragZoom');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction.DragBox');
|
||||
@@ -28,6 +27,12 @@ ol.interaction.DragZoom = function(opt_options) {
|
||||
var condition = goog.isDef(options.condition) ?
|
||||
options.condition : ol.events.condition.shiftKeyOnly;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 200;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.style.Style}
|
||||
@@ -61,5 +66,5 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
||||
goog.asserts.assert(goog.isDef(size), 'size should be defined');
|
||||
ol.interaction.Interaction.zoom(map, view,
|
||||
view.getResolutionForExtent(extent, size),
|
||||
center, ol.DRAGZOOM_ANIMATION_DURATION);
|
||||
center, this.duration_);
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.events.KeyCodes');
|
||||
goog.require('goog.events.KeyHandler.EventType');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.events.ConditionType');
|
||||
goog.require('ol.events.condition');
|
||||
@@ -45,6 +44,12 @@ ol.interaction.KeyboardPan = function(opt_options) {
|
||||
goog.functions.and(ol.events.condition.noModifierKeys,
|
||||
ol.events.condition.targetNotEditable);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 100;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -89,8 +94,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
|
||||
}
|
||||
var delta = [deltaX, deltaY];
|
||||
ol.coordinate.rotate(delta, viewState.rotation);
|
||||
ol.interaction.Interaction.pan(
|
||||
map, view, delta, ol.KEYBOARD_PAN_DURATION);
|
||||
ol.interaction.Interaction.pan(map, view, delta, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
stopEvent = true;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.interaction.PinchRotate');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
@@ -61,6 +60,12 @@ ol.interaction.PinchRotate = function(opt_options) {
|
||||
*/
|
||||
this.threshold_ = goog.isDef(options.threshold) ? options.threshold : 0.3;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
|
||||
|
||||
@@ -131,7 +136,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (this.rotating_) {
|
||||
var rotation = view.getRotation();
|
||||
ol.interaction.Interaction.rotate(
|
||||
map, view, rotation, this.anchor_, ol.ROTATE_ANIMATION_DURATION);
|
||||
map, view, rotation, this.anchor_, this.duration_);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
||||
36
src/ol/ol.js
36
src/ol/ol.js
@@ -48,24 +48,6 @@ ol.DEFAULT_TILE_SIZE = 256;
|
||||
ol.DEFAULT_WMS_VERSION = '1.3.0';
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Drag-rotate-zoom animation duration.
|
||||
*/
|
||||
ol.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Drag-rotate animation duration.
|
||||
*/
|
||||
ol.DRAGROTATE_ANIMATION_DURATION = 250;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Drag-zoom animation duration.
|
||||
*/
|
||||
ol.DRAGZOOM_ANIMATION_DURATION = 200;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Hysteresis pixels.
|
||||
*/
|
||||
@@ -162,12 +144,6 @@ ol.IS_LEGACY_IE = goog.userAgent.IE &&
|
||||
!goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== '';
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Keyboard pan duration.
|
||||
*/
|
||||
ol.KEYBOARD_PAN_DURATION = 100;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} The maximum size in pixels of atlas images. Default is
|
||||
* `-1`, meaning it is not used (and `ol.WEBGL_MAX_TEXTURE_SIZE` is
|
||||
@@ -202,12 +178,6 @@ ol.OVERVIEWMAP_MAX_RATIO = 0.75;
|
||||
ol.OVERVIEWMAP_MIN_RATIO = 0.1;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Rotate animation duration.
|
||||
*/
|
||||
ol.ROTATE_ANIMATION_DURATION = 250;
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Tolerance for geometry simplification in device pixels.
|
||||
*/
|
||||
@@ -237,12 +207,6 @@ ol.WEBGL_MAX_TEXTURE_SIZE; // value is set in `ol.has`
|
||||
ol.WEBGL_EXTENSIONS; // value is set in `ol.has`
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Zoom slider animation duration.
|
||||
*/
|
||||
ol.ZOOMSLIDER_ANIMATION_DURATION = 200;
|
||||
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user