From 3b4bc0be2584aa1174626aef113830636c4b73be Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 14:44:46 +0200 Subject: [PATCH 1/6] Move ol.KEYBOARD_PAN_DURATION const to a constructor option --- externs/olx.js | 9 +++++++++ src/ol/interaction/keyboardpaninteraction.js | 10 +++++++--- src/ol/ol.js | 6 ------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index ebf684f3b2..28fa457dce 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2385,6 +2385,7 @@ olx.interaction.DrawOptions.prototype.condition; /** * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined), * pixelDelta: (number|undefined)}} * @api */ @@ -2402,6 +2403,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} 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/ol.js b/src/ol/ol.js index 417a0cde6c..1ec7d5e5e3 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -170,12 +170,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 From 3eb22559d6f16813d61e7eb165da07ac106c6f0f Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 14:52:38 +0200 Subject: [PATCH 2/6] Move ol.ZOOMSLIDER_ANIMATION_DURATION const to a constructor option --- externs/olx.js | 9 +++++++++ src/ol/control/zoomslidercontrol.js | 11 ++++++++--- src/ol/ol.js | 6 ------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 28fa457dce..f5152ecb0b 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} 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/ol.js b/src/ol/ol.js index 1ec7d5e5e3..30f4bee455 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -239,12 +239,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. * From 2fcdc48d20f9bc556336e5b040116aaa87782543 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 14:59:39 +0200 Subject: [PATCH 3/6] Move ol.DRAGZOOM_ANIMATION_DURATION const to a constructor option --- externs/olx.js | 9 +++++++++ src/ol/interaction/dragzoominteraction.js | 9 +++++++-- src/ol/ol.js | 6 ------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index f5152ecb0b..5035b7d904 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2286,6 +2286,7 @@ olx.interaction.DragRotateOptions.prototype.condition; /** * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined), * style: ol.style.Style}} * @api */ @@ -2302,6 +2303,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} 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/ol.js b/src/ol/ol.js index 30f4bee455..0bcaa08976 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -60,12 +60,6 @@ ol.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400; ol.DRAGROTATE_ANIMATION_DURATION = 250; -/** - * @define {number} Drag-zoom animation duration. - */ -ol.DRAGZOOM_ANIMATION_DURATION = 200; - - /** * @define {number} Hysteresis pixels. */ From 1daf4628b7377f49cdeb916a795edfdaefefdb39 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 15:05:35 +0200 Subject: [PATCH 4/6] Move ol.ROTATE_ANIMATION_DURATION const to a constructor option --- externs/olx.js | 11 ++++++++++- src/ol/interaction/pinchrotateinteraction.js | 9 +++++++-- src/ol/ol.js | 6 ------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 5035b7d904..4b3c65a68d 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2534,12 +2534,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/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 0bcaa08976..b0af1db4cb 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -198,12 +198,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. */ From a94a87323d7e34e96b24ceadf0bdf8416329a84a Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 15:21:45 +0200 Subject: [PATCH 5/6] Move ol.DRAGROTATEANDZOOM_ANIMATION_DURATION const to a constructor option --- externs/olx.js | 11 ++++++++++- src/ol/interaction/dragrotateandzoominteraction.js | 10 +++++++--- src/ol/ol.js | 6 ------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 4b3c65a68d..3bbf468d92 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2251,7 +2251,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; @@ -2267,6 +2268,14 @@ olx.interaction.DragRotateAndZoomOptions; olx.interaction.DragRotateAndZoomOptions.prototype.condition; +/** + * Animation duration in milliseconds. Default is `400`. + * @type {number|undefined} + * @api + */ +olx.interaction.DragRotateAndZoomOptions.prototype.duration; + + /** * @typedef {{condition: (ol.events.ConditionType|undefined)}} * @api 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/ol.js b/src/ol/ol.js index b0af1db4cb..9351c16161 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -48,12 +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. */ From 6c33f84798c619f241526dbfc4e35b6682311275 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 13 Apr 2015 15:25:23 +0200 Subject: [PATCH 6/6] Move ol.DRAGROTATE_ANIMATION_DURATION const to a constructor option --- externs/olx.js | 11 ++++++++++- src/ol/interaction/dragrotateinteraction.js | 8 ++++++-- src/ol/ol.js | 6 ------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/externs/olx.js b/externs/olx.js index 3bbf468d92..69926dedb3 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -2277,7 +2277,8 @@ olx.interaction.DragRotateAndZoomOptions.prototype.duration; /** - * @typedef {{condition: (ol.events.ConditionType|undefined)}} + * @typedef {{condition: (ol.events.ConditionType|undefined), + * duration: (number|undefined)}} * @api */ olx.interaction.DragRotateOptions; @@ -2293,6 +2294,14 @@ 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), 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/ol.js b/src/ol/ol.js index 9351c16161..4b507a5ec9 100644 --- a/src/ol/ol.js +++ b/src/ol/ol.js @@ -48,12 +48,6 @@ ol.DEFAULT_TILE_SIZE = 256; ol.DEFAULT_WMS_VERSION = '1.3.0'; -/** - * @define {number} Drag-rotate animation duration. - */ -ol.DRAGROTATE_ANIMATION_DURATION = 250; - - /** * @define {number} Hysteresis pixels. */