From 8a9738d755d9e09eb467354df64275e5862c57c1 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Mon, 28 Jan 2013 17:33:15 +0100 Subject: [PATCH 1/9] Add support for kinetic effect while dragging. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only dragpan interaction is supported for now. The kinetic effect use the maths below (thx @twpayne): Rate of decay (number, must be negative) = α Minimum velocity (pixels/millisecond) = v_min Initial velocity (pixels/millisecond) = v₀ Velocity at time t (pixels/millisecond) = α⋅t v₀⋅ℯ Distance travelled at time t (pixels) = ⎛ α⋅t ⎞ v₀⋅⎝ℯ - 1⎠ ───────────── α Duration of animation (milliseconds) = ⎛v_min⎞ log⎜─────⎟ ⎝ v₀ ⎠ ────────── α Total distance travelled (pixels) = -v₀ + v_min ─────────── α Easing function = ⎛ α⋅duration⋅t ⎞ v₀⋅⎝ℯ - 1⎠ ────────────────────── -v₀ + v_min --- src/ol/interaction/dragpaninteraction.js | 42 ++++++- src/ol/kinetic.js | 143 +++++++++++++++++++++++ 2 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 src/ol/kinetic.js diff --git a/src/ol/interaction/dragpaninteraction.js b/src/ol/interaction/dragpaninteraction.js index 3fcc4d4157..4598cabec1 100644 --- a/src/ol/interaction/dragpaninteraction.js +++ b/src/ol/interaction/dragpaninteraction.js @@ -7,6 +7,7 @@ goog.require('ol.Coordinate'); goog.require('ol.MapBrowserEvent'); goog.require('ol.View2D'); goog.require('ol.ViewHint'); +goog.require('ol.animation'); goog.require('ol.interaction.ConditionType'); goog.require('ol.interaction.Drag'); @@ -16,8 +17,9 @@ goog.require('ol.interaction.Drag'); * @constructor * @extends {ol.interaction.Drag} * @param {ol.interaction.ConditionType} condition Condition. + * @param {ol.Kinetic=} opt_kinetic Kinetic object. */ -ol.interaction.DragPan = function(condition) { +ol.interaction.DragPan = function(condition, opt_kinetic) { goog.base(this); @@ -27,6 +29,12 @@ ol.interaction.DragPan = function(condition) { */ this.condition_ = condition; + /** + * @private + * @type {ol.Kinetic|undefined} + */ + this.kinetic_ = opt_kinetic; + }; goog.inherits(ol.interaction.DragPan, ol.interaction.Drag); @@ -35,6 +43,9 @@ goog.inherits(ol.interaction.DragPan, ol.interaction.Drag); * @inheritDoc */ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) { + if (this.kinetic_) { + this.kinetic_.update(mapBrowserEvent.browserEvent); + } var map = mapBrowserEvent.map; // FIXME works for View2D only var view = map.getView(); @@ -55,9 +66,31 @@ ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) { * @inheritDoc */ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) { + + // FIXME works for View2D only + var map = mapBrowserEvent.map; - map.requestRenderFrame(); - map.getView().setHint(ol.ViewHint.PANNING, -1); + var view = map.getView(); + view.setHint(ol.ViewHint.PANNING, -1); + + if (this.kinetic_ && this.kinetic_.end()) { + var distance = this.kinetic_.getDistance(); + var angle = this.kinetic_.getAngle(); + var center = view.getCenter(); + var kineticPanFrom = ol.animation.createPanFrom({ + source: center, + duration: this.kinetic_.getDuration(), + easing: this.kinetic_.getEasingFn() + }); + map.addPreRenderFunction(kineticPanFrom); + + var centerpx = map.getPixelFromCoordinate(center); + var destpx = new ol.Pixel( + centerpx.x - distance * Math.cos(angle), + centerpx.y - distance * Math.sin(angle)); + var dest = map.getCoordinateFromPixel(destpx); + view.setCenter(dest); + } }; @@ -67,6 +100,9 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) { ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) { var browserEvent = mapBrowserEvent.browserEvent; if (this.condition_(browserEvent)) { + if (this.kinetic_) { + this.kinetic_.begin(browserEvent); + } var map = mapBrowserEvent.map; map.requestRenderFrame(); map.getView().setHint(ol.ViewHint.PANNING, 1); diff --git a/src/ol/kinetic.js b/src/ol/kinetic.js new file mode 100644 index 0000000000..909fbb4936 --- /dev/null +++ b/src/ol/kinetic.js @@ -0,0 +1,143 @@ + +goog.provide('ol.Kinetic'); + +goog.require('goog.array'); +goog.require('ol.Pixel'); + + +/** + * @typedef {{x: number, + * y: number, + * t: number}} + */ +ol.KineticPoint; + + + +/** + * @constructor + * @param {number} decay Rate of decay (must be negative). + * @param {number} v_min Minimum velocity (pixels/millisecond). + * @param {number} delay Delay to consider to calculate the kinetic + * initial values (milliseconds). + */ +ol.Kinetic = function(decay, v_min, delay) { + + /** + * @private + * @type {number} + */ + this.decay_ = decay; + + /** + * @private + * @type {number} + */ + this.v_min_ = v_min; + + /** + * @private + * @type {number} + */ + this.delay_ = delay; + + /** + * @private + * @type {Array.} + */ + this.points_ = []; + + /** + * @private + * @type {number} + */ + this.angle_ = 0; + + /** + * @private + * @type {number} + */ + this.v_0_ = 0; +}; + + +/** + * @param {goog.events.BrowserEvent} browserEvent Browser event. + */ +ol.Kinetic.prototype.begin = function(browserEvent) { + this.points_.length = 0; + this.angle_ = 0; + this.v_0_ = 0; + this.update(browserEvent); +}; + + +/** + * @param {goog.events.BrowserEvent} browserEvent Browser event. + */ +ol.Kinetic.prototype.update = function(browserEvent) { + this.points_.push({ + x: browserEvent.clientX, + y: browserEvent.clientY, + t: goog.now() + }); +}; + + +/** + * @return {boolean} Whether we should do kinetic animation. + */ +ol.Kinetic.prototype.end = function() { + var now = goog.now(); + var index = Math.abs(goog.array.binarySelect(this.points_, function(elt) { + return elt.t < now - this.delay_; + }, this)); + if (index < this.points_.length - 1) { + var first = this.points_[index]; + var last = this.points_[this.points_.length - 1]; + var dx = last.x - first.x; + var dy = last.y - first.y; + this.angle_ = Math.atan2(dy, dx); + this.v_0_ = Math.sqrt(dx * dx + dy * dy) / (last.t - first.t); + return this.v_0_ > this.v_min_; + } + return false; +}; + + +/** + * @return {function(number): number} Easing function for kinetic animation. + */ +ol.Kinetic.prototype.getEasingFn = function() { + var decay = this.decay_; + var v_0 = this.v_0_; + var v_min = this.v_min_; + var duration = this.getDuration(); + return function(t) { + return v_0 * (Math.exp((decay * t) * duration) - 1) / (v_min - v_0); + }; +}; + + +/** + * @return {number} Duration of animation (milliseconds). + */ +ol.Kinetic.prototype.getDuration = function() { + return Math.log(this.v_min_ / this.v_0_) / this.decay_; +}; + + +/** + * @return {number} Total distance travelled (pixels). + */ +ol.Kinetic.prototype.getDistance = function() { + return (this.v_min_ - this.v_0_) / this.decay_; +}; + + +/** + * @return {number} Angle of the kinetic panning animation (radians). + */ +ol.Kinetic.prototype.getAngle = function() { + return this.angle_; +}; From 7d0b4c757ea80379e6b719a7da2f42e84641d75d Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Mon, 28 Jan 2013 17:40:00 +0100 Subject: [PATCH 2/9] Activate kinetic effect by default --- src/ol/map.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ol/map.js b/src/ol/map.js index 46e9743e9f..1432c45612 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -29,6 +29,7 @@ goog.require('ol.Color'); goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.FrameState'); +goog.require('ol.Kinetic'); goog.require('ol.MapBrowserEvent'); goog.require('ol.Object'); goog.require('ol.Pixel'); @@ -984,7 +985,8 @@ ol.Map.createInteractions_ = function(mapOptions) { mapOptions.dragPan : true; if (dragPan) { interactions.push( - new ol.interaction.DragPan(ol.interaction.condition.noModifierKeys)); + new ol.interaction.DragPan(ol.interaction.condition.noModifierKeys, + new ol.Kinetic(-0.005, 0.05, 100))); } var keyboard = goog.isDef(mapOptions.keyboard) ? From d54864695db8a922337f5d67e11b698bb06914b8 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 29 Jan 2013 12:56:15 +0100 Subject: [PATCH 3/9] Add a removePreRenderFunction method to ol.Map This will remove the pre-render function from preRenderFunctions_ array if found. --- src/ol/map.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ol/map.js b/src/ol/map.js index 1432c45612..23b42bc203 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -326,6 +326,15 @@ ol.Map.prototype.addPreRenderFunctions = function(preRenderFunctions) { }; +/** + * @param {ol.PreRenderFunction} preRenderFunction Pre-render function. + * @return {boolean} Whether the preRenderFunction has been found and removed. + */ +ol.Map.prototype.removePreRenderFunction = function(preRenderFunction) { + return goog.array.remove(this.preRenderFunctions_, preRenderFunction); +}; + + /** * * @inheritDoc From 39cbba3eb7eb569c713932992b870f9093d1b6fe Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 29 Jan 2013 13:00:02 +0100 Subject: [PATCH 4/9] Add a frameState property to ol.MapBrowserEvent so that we will be able to retrieve the current center of the view2d from the framestate in the dragpan interaction. --- src/ol/map.js | 1 + src/ol/mapbrowserevent.js | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index 23b42bc203..22609eb4a6 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -542,6 +542,7 @@ ol.Map.prototype.handleControlsRemove_ = function(collectionEvent) { * @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle. */ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + mapBrowserEvent.frameState = this.frameState_; var interactions = this.getInteractions(); var interactionsArray = /** @type {Array.} */ (interactions.getArray()); diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index cdb40d3e66..a6b0f20be7 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -21,10 +21,11 @@ goog.require('ol.Pixel'); * @param {string} type Event type. * @param {ol.Map} map Map. * @param {goog.events.BrowserEvent} browserEvent Browser event. + * @param {?ol.FrameState=} opt_frameState Frame state. */ -ol.MapBrowserEvent = function(type, map, browserEvent) { +ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) { - goog.base(this, type, map); + goog.base(this, type, map, opt_frameState); /** * @type {goog.events.BrowserEvent} @@ -230,6 +231,9 @@ ol.MapBrowserEventHandler.prototype.handleUp_ = function(browserEvent) { * @private */ ol.MapBrowserEventHandler.prototype.handleDown_ = function(browserEvent) { + var newEvent = new ol.MapBrowserEvent( + ol.MapBrowserEvent.EventType.DOWN, this.map_, browserEvent); + this.dispatchEvent(newEvent); if (!this.previous_) { this.touchEnableBrowserEvent_(browserEvent); this.down_ = browserEvent; @@ -306,5 +310,6 @@ ol.MapBrowserEvent.EventType = { DBLCLICK: goog.events.EventType.DBLCLICK, DRAGSTART: 'dragstart', DRAG: 'drag', - DRAGEND: 'dragend' + DRAGEND: 'dragend', + DOWN: 'down' }; From 2bb8a5cfd9abc75915f08fdbee082b81cbd0ab7d Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 29 Jan 2013 14:12:01 +0100 Subject: [PATCH 5/9] Stop current kinetic animation on DOWN events --- src/ol/interaction/draginteraction.js | 11 ++++++++++ src/ol/interaction/dragpaninteraction.js | 28 ++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/ol/interaction/draginteraction.js b/src/ol/interaction/draginteraction.js index b41e548a6b..1d525bae7d 100644 --- a/src/ol/interaction/draginteraction.js +++ b/src/ol/interaction/draginteraction.js @@ -80,6 +80,13 @@ ol.interaction.Drag.prototype.handleDragEnd = goog.nullFunction; ol.interaction.Drag.prototype.handleDragStart = goog.functions.FALSE; +/** + * @param {ol.MapBrowserEvent} mapBrowserEvent Event. + * @protected + */ +ol.interaction.Drag.prototype.handleDown = goog.nullFunction; + + /** * @inheritDoc */ @@ -91,6 +98,10 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent = } var view = map.getView(); var browserEvent = mapBrowserEvent.browserEvent; + if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DOWN) { + goog.asserts.assert(browserEvent instanceof goog.events.BrowserEvent); + this.handleDown(mapBrowserEvent); + } if (this.dragging_) { if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DRAG) { goog.asserts.assert(browserEvent instanceof goog.events.BrowserEvent); diff --git a/src/ol/interaction/dragpaninteraction.js b/src/ol/interaction/dragpaninteraction.js index 4598cabec1..dcd9e752da 100644 --- a/src/ol/interaction/dragpaninteraction.js +++ b/src/ol/interaction/dragpaninteraction.js @@ -35,6 +35,12 @@ ol.interaction.DragPan = function(condition, opt_kinetic) { */ this.kinetic_ = opt_kinetic; + /** + * @private + * @type {?ol.PreRenderFunction} + */ + this.kineticPreRenderFn_ = null; + }; goog.inherits(ol.interaction.DragPan, ol.interaction.Drag); @@ -77,12 +83,12 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) { var distance = this.kinetic_.getDistance(); var angle = this.kinetic_.getAngle(); var center = view.getCenter(); - var kineticPanFrom = ol.animation.createPanFrom({ + this.kineticPreRenderFn_ = ol.animation.createPanFrom({ source: center, duration: this.kinetic_.getDuration(), easing: this.kinetic_.getEasingFn() }); - map.addPreRenderFunction(kineticPanFrom); + map.addPreRenderFunction(this.kineticPreRenderFn_); var centerpx = map.getPixelFromCoordinate(center); var destpx = new ol.Pixel( @@ -111,3 +117,21 @@ ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) { return false; } }; + + +/** + * @inheritDoc + */ +ol.interaction.DragPan.prototype.handleDown = function(mapBrowserEvent) { + var map = mapBrowserEvent.map; + // FIXME works for View2D only + var view = map.getView(); + goog.asserts.assert(view instanceof ol.View2D); + goog.asserts.assert(!goog.isNull(mapBrowserEvent.frameState)); + if (!goog.isNull(this.kineticPreRenderFn_) && + map.removePreRenderFunction(this.kineticPreRenderFn_)) { + map.requestRenderFrame(); + view.setCenter(mapBrowserEvent.frameState.view2DState.center); + this.kineticPreRenderFn_ = null; + } +}; From 79849888db6e7492f0399102492c6318e01d38a3 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Tue, 29 Jan 2013 14:50:12 +0100 Subject: [PATCH 6/9] Kinetic now returns directly the pre-render function instead of returning the kinetic easing function only. (thanks @fredj) --- src/ol/interaction/dragpaninteraction.js | 7 +------ src/ol/kinetic.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ol/interaction/dragpaninteraction.js b/src/ol/interaction/dragpaninteraction.js index dcd9e752da..5c516d62ff 100644 --- a/src/ol/interaction/dragpaninteraction.js +++ b/src/ol/interaction/dragpaninteraction.js @@ -7,7 +7,6 @@ goog.require('ol.Coordinate'); goog.require('ol.MapBrowserEvent'); goog.require('ol.View2D'); goog.require('ol.ViewHint'); -goog.require('ol.animation'); goog.require('ol.interaction.ConditionType'); goog.require('ol.interaction.Drag'); @@ -83,11 +82,7 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) { var distance = this.kinetic_.getDistance(); var angle = this.kinetic_.getAngle(); var center = view.getCenter(); - this.kineticPreRenderFn_ = ol.animation.createPanFrom({ - source: center, - duration: this.kinetic_.getDuration(), - easing: this.kinetic_.getEasingFn() - }); + this.kineticPreRenderFn_ = this.kinetic_.createPanFrom(center); map.addPreRenderFunction(this.kineticPreRenderFn_); var centerpx = map.getPixelFromCoordinate(center); diff --git a/src/ol/kinetic.js b/src/ol/kinetic.js index 909fbb4936..4f952477de 100644 --- a/src/ol/kinetic.js +++ b/src/ol/kinetic.js @@ -3,6 +3,7 @@ goog.provide('ol.Kinetic'); goog.require('goog.array'); goog.require('ol.Pixel'); +goog.require('ol.animation'); /** @@ -106,16 +107,22 @@ ol.Kinetic.prototype.end = function() { /** - * @return {function(number): number} Easing function for kinetic animation. + * @param {ol.Coordinate} source Source coordinate for the animation. + * @return {ol.PreRenderFunction} Pre-render function for kinetic animation. */ -ol.Kinetic.prototype.getEasingFn = function() { +ol.Kinetic.prototype.createPanFrom = function(source) { var decay = this.decay_; var v_0 = this.v_0_; var v_min = this.v_min_; var duration = this.getDuration(); - return function(t) { + var easingFunction = function(t) { return v_0 * (Math.exp((decay * t) * duration) - 1) / (v_min - v_0); }; + return ol.animation.createPanFrom({ + source: source, + duration: duration, + easing: easingFunction + }); }; From d91e1d30d472bf4788b6099d7b2e3bdc9d586f83 Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 30 Jan 2013 11:42:53 +0100 Subject: [PATCH 7/9] Get rid of binarySelect to find the first point. --- src/ol/kinetic.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ol/kinetic.js b/src/ol/kinetic.js index 4f952477de..875eea7a16 100644 --- a/src/ol/kinetic.js +++ b/src/ol/kinetic.js @@ -90,12 +90,14 @@ ol.Kinetic.prototype.update = function(browserEvent) { */ ol.Kinetic.prototype.end = function() { var now = goog.now(); - var index = Math.abs(goog.array.binarySelect(this.points_, function(elt) { - return elt.t < now - this.delay_; - }, this)); - if (index < this.points_.length - 1) { - var first = this.points_[index]; - var last = this.points_[this.points_.length - 1]; + var lastIndex = this.points_.length - 1; + var firstIndex = lastIndex - 1; + while (firstIndex >= 0 && this.points_[firstIndex].t > now - this.delay_) { + firstIndex--; + } + if (firstIndex >= 0) { + var first = this.points_[firstIndex]; + var last = this.points_[lastIndex]; var dx = last.x - first.x; var dy = last.y - first.y; this.angle_ = Math.atan2(dy, dx); From dff8c2b2b2b1de1e070af465c406a8e1d75e281c Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 30 Jan 2013 11:53:57 +0100 Subject: [PATCH 8/9] Renaming to be more consistent with ol3 style s/v_0/initialVelocity/ s/v_min/minVelocity/ --- src/ol/kinetic.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/ol/kinetic.js b/src/ol/kinetic.js index 875eea7a16..6f98e60d51 100644 --- a/src/ol/kinetic.js +++ b/src/ol/kinetic.js @@ -18,11 +18,11 @@ ol.KineticPoint; /** * @constructor * @param {number} decay Rate of decay (must be negative). - * @param {number} v_min Minimum velocity (pixels/millisecond). + * @param {number} minVelocity Minimum velocity (pixels/millisecond). * @param {number} delay Delay to consider to calculate the kinetic * initial values (milliseconds). */ -ol.Kinetic = function(decay, v_min, delay) { +ol.Kinetic = function(decay, minVelocity, delay) { /** * @private @@ -34,7 +34,7 @@ ol.Kinetic = function(decay, v_min, delay) { * @private * @type {number} */ - this.v_min_ = v_min; + this.minVelocity_ = minVelocity; /** * @private @@ -58,7 +58,7 @@ ol.Kinetic = function(decay, v_min, delay) { * @private * @type {number} */ - this.v_0_ = 0; + this.initialVelocity_ = 0; }; @@ -68,7 +68,7 @@ ol.Kinetic = function(decay, v_min, delay) { ol.Kinetic.prototype.begin = function(browserEvent) { this.points_.length = 0; this.angle_ = 0; - this.v_0_ = 0; + this.initialVelocity_ = 0; this.update(browserEvent); }; @@ -101,8 +101,8 @@ ol.Kinetic.prototype.end = function() { var dx = last.x - first.x; var dy = last.y - first.y; this.angle_ = Math.atan2(dy, dx); - this.v_0_ = Math.sqrt(dx * dx + dy * dy) / (last.t - first.t); - return this.v_0_ > this.v_min_; + this.initialVelocity_ = Math.sqrt(dx * dx + dy * dy) / (last.t - first.t); + return this.initialVelocity_ > this.minVelocity_; } return false; }; @@ -114,11 +114,12 @@ ol.Kinetic.prototype.end = function() { */ ol.Kinetic.prototype.createPanFrom = function(source) { var decay = this.decay_; - var v_0 = this.v_0_; - var v_min = this.v_min_; + var initialVelocity = this.initialVelocity_; + var minVelocity = this.minVelocity_; var duration = this.getDuration(); var easingFunction = function(t) { - return v_0 * (Math.exp((decay * t) * duration) - 1) / (v_min - v_0); + return initialVelocity * (Math.exp((decay * t) * duration) - 1) / + (minVelocity - initialVelocity); }; return ol.animation.createPanFrom({ source: source, @@ -132,7 +133,7 @@ ol.Kinetic.prototype.createPanFrom = function(source) { * @return {number} Duration of animation (milliseconds). */ ol.Kinetic.prototype.getDuration = function() { - return Math.log(this.v_min_ / this.v_0_) / this.decay_; + return Math.log(this.minVelocity_ / this.initialVelocity_) / this.decay_; }; @@ -140,7 +141,7 @@ ol.Kinetic.prototype.getDuration = function() { * @return {number} Total distance travelled (pixels). */ ol.Kinetic.prototype.getDistance = function() { - return (this.v_min_ - this.v_0_) / this.decay_; + return (this.minVelocity_ - this.initialVelocity_) / this.decay_; }; From d2f30986db0d460bc41c7d6bcccbd71b02c0c1ea Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Wed, 30 Jan 2013 13:39:16 +0100 Subject: [PATCH 9/9] Set kinetic getDuration instance method to @private --- src/ol/kinetic.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ol/kinetic.js b/src/ol/kinetic.js index 6f98e60d51..44aabe850b 100644 --- a/src/ol/kinetic.js +++ b/src/ol/kinetic.js @@ -116,7 +116,7 @@ ol.Kinetic.prototype.createPanFrom = function(source) { var decay = this.decay_; var initialVelocity = this.initialVelocity_; var minVelocity = this.minVelocity_; - var duration = this.getDuration(); + var duration = this.getDuration_(); var easingFunction = function(t) { return initialVelocity * (Math.exp((decay * t) * duration) - 1) / (minVelocity - initialVelocity); @@ -130,9 +130,10 @@ ol.Kinetic.prototype.createPanFrom = function(source) { /** + * @private * @return {number} Duration of animation (milliseconds). */ -ol.Kinetic.prototype.getDuration = function() { +ol.Kinetic.prototype.getDuration_ = function() { return Math.log(this.minVelocity_ / this.initialVelocity_) / this.decay_; };