Kinetic now returns directly the pre-render function
instead of returning the kinetic easing function only. (thanks @fredj)
This commit is contained in:
@@ -7,7 +7,6 @@ goog.require('ol.Coordinate');
|
|||||||
goog.require('ol.MapBrowserEvent');
|
goog.require('ol.MapBrowserEvent');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.ViewHint');
|
goog.require('ol.ViewHint');
|
||||||
goog.require('ol.animation');
|
|
||||||
goog.require('ol.interaction.ConditionType');
|
goog.require('ol.interaction.ConditionType');
|
||||||
goog.require('ol.interaction.Drag');
|
goog.require('ol.interaction.Drag');
|
||||||
|
|
||||||
@@ -83,11 +82,7 @@ ol.interaction.DragPan.prototype.handleDragEnd = function(mapBrowserEvent) {
|
|||||||
var distance = this.kinetic_.getDistance();
|
var distance = this.kinetic_.getDistance();
|
||||||
var angle = this.kinetic_.getAngle();
|
var angle = this.kinetic_.getAngle();
|
||||||
var center = view.getCenter();
|
var center = view.getCenter();
|
||||||
this.kineticPreRenderFn_ = ol.animation.createPanFrom({
|
this.kineticPreRenderFn_ = this.kinetic_.createPanFrom(center);
|
||||||
source: center,
|
|
||||||
duration: this.kinetic_.getDuration(),
|
|
||||||
easing: this.kinetic_.getEasingFn()
|
|
||||||
});
|
|
||||||
map.addPreRenderFunction(this.kineticPreRenderFn_);
|
map.addPreRenderFunction(this.kineticPreRenderFn_);
|
||||||
|
|
||||||
var centerpx = map.getPixelFromCoordinate(center);
|
var centerpx = map.getPixelFromCoordinate(center);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ goog.provide('ol.Kinetic');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('ol.Pixel');
|
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 decay = this.decay_;
|
||||||
var v_0 = this.v_0_;
|
var v_0 = this.v_0_;
|
||||||
var v_min = this.v_min_;
|
var v_min = this.v_min_;
|
||||||
var duration = this.getDuration();
|
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 v_0 * (Math.exp((decay * t) * duration) - 1) / (v_min - v_0);
|
||||||
};
|
};
|
||||||
|
return ol.animation.createPanFrom({
|
||||||
|
source: source,
|
||||||
|
duration: duration,
|
||||||
|
easing: easingFunction
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user