diff --git a/externs/olx.js b/externs/olx.js index e1750071c9..71fdd80090 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -1435,6 +1435,7 @@ olx.control.ZoomOptions.prototype.target; /** * @typedef {{className: (string|undefined), + * duration: (number|undefined), * maxResolution: (number|undefined), * minResolution: (number|undefined), * render: (function(ol.MapEvent)|undefined)}} @@ -1451,6 +1452,14 @@ olx.control.ZoomSliderOptions; olx.control.ZoomSliderOptions.prototype.className; +/** + * Animation duration in milliseconds. Default is `200`. + * @type {number|undefined} + * @api + */ +olx.control.ZoomSliderOptions.prototype.duration; + + /** * Maximum resolution. * @type {number|undefined} @@ -2257,7 +2266,8 @@ olx.interaction.DragPanOptions.prototype.kinetic; /** - * @typedef {{condition: (ol.events.ConditionType|undefined)}} + * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined)}} * @api */ olx.interaction.DragRotateAndZoomOptions; @@ -2274,7 +2284,16 @@ olx.interaction.DragRotateAndZoomOptions.prototype.condition; /** - * @typedef {{condition: (ol.events.ConditionType|undefined)}} + * Animation duration in milliseconds. Default is `400`. + * @type {number|undefined} + * @api + */ +olx.interaction.DragRotateAndZoomOptions.prototype.duration; + + +/** + * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined)}} * @api */ olx.interaction.DragRotateOptions; @@ -2290,8 +2309,17 @@ olx.interaction.DragRotateOptions; olx.interaction.DragRotateOptions.prototype.condition; +/** + * Animation duration in milliseconds. Default is `250`. + * @type {number|undefined} + * @api + */ +olx.interaction.DragRotateOptions.prototype.duration; + + /** * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined), * style: ol.style.Style}} * @api */ @@ -2308,6 +2336,14 @@ olx.interaction.DragZoomOptions; olx.interaction.DragZoomOptions.prototype.condition; +/** + * Animation duration in milliseconds. Default is `200`. + * @type {number|undefined} + * @api + */ +olx.interaction.DragZoomOptions.prototype.duration; + + /** * Style for the box. * @type {ol.style.Style} @@ -2400,6 +2436,7 @@ olx.interaction.DrawOptions.prototype.condition; /** * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined), * pixelDelta: (number|undefined)}} * @api */ @@ -2417,6 +2454,14 @@ olx.interaction.KeyboardPanOptions; olx.interaction.KeyboardPanOptions.prototype.condition; +/** + * Animation duration in milliseconds. Default is `100`. + * @type {number|undefined} + * @api + */ +olx.interaction.KeyboardPanOptions.prototype.duration; + + /** * Pixel The amount to pan on each key press. Default is `128` pixels. * @type {number|undefined} @@ -2522,12 +2567,21 @@ olx.interaction.MouseWheelZoomOptions.prototype.duration; /** - * @typedef {{threshold: (number|undefined)}} + * @typedef {{threshold: (number|undefined), + * duration: (number|undefined)}} * @api */ olx.interaction.PinchRotateOptions; +/** + * The duration of the animation in milliseconds. Default is `250`. + * @type {number|undefined} + * @api + */ +olx.interaction.PinchRotateOptions.prototype.duration; + + /** * Minimal angle in radians to start a rotation. Default is `0.3`. * @type {number|undefined} diff --git a/src/ol/control/zoomslidercontrol.js b/src/ol/control/zoomslidercontrol.js index ded9c07b7d..71847f1f68 100644 --- a/src/ol/control/zoomslidercontrol.js +++ b/src/ol/control/zoomslidercontrol.js @@ -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_); diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index 4c31e8f3a6..83ecc0f5f2 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -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; }; diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index 877aa227dc..476cf1778f 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -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; }; diff --git a/src/ol/interaction/dragzoominteraction.js b/src/ol/interaction/dragzoominteraction.js index fb2c7ce8ad..30398002c6 100644 --- a/src/ol/interaction/dragzoominteraction.js +++ b/src/ol/interaction/dragzoominteraction.js @@ -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_); }; diff --git a/src/ol/interaction/keyboardpaninteraction.js b/src/ol/interaction/keyboardpaninteraction.js index d29e6e7425..029627f70c 100644 --- a/src/ol/interaction/keyboardpaninteraction.js +++ b/src/ol/interaction/keyboardpaninteraction.js @@ -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; } diff --git a/src/ol/interaction/pinchrotateinteraction.js b/src/ol/interaction/pinchrotateinteraction.js index ebb1a08247..7cae131e17 100644 --- a/src/ol/interaction/pinchrotateinteraction.js +++ b/src/ol/interaction/pinchrotateinteraction.js @@ -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 { diff --git a/src/ol/ol.js b/src/ol/ol.js index 8996511246..48c926e560 100644 --- a/src/ol/ol.js +++ b/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. *