Merge pull request #179 from fredj/kinetic-update-arg

Change ol.Kinetic.update and begin arguments.
This commit is contained in:
Frédéric Junod
2013-02-07 00:08:01 -08:00
2 changed files with 13 additions and 9 deletions

View File

@@ -51,7 +51,9 @@ goog.inherits(ol.interaction.DragPan, ol.interaction.Drag);
*/
ol.interaction.DragPan.prototype.handleDrag = function(mapBrowserEvent) {
if (this.kinetic_) {
this.kinetic_.update(mapBrowserEvent.browserEvent);
this.kinetic_.update(
mapBrowserEvent.browserEvent.clientX,
mapBrowserEvent.browserEvent.clientY);
}
var map = mapBrowserEvent.map;
// FIXME works for View2D only
@@ -104,7 +106,7 @@ ol.interaction.DragPan.prototype.handleDragStart = function(mapBrowserEvent) {
var browserEvent = mapBrowserEvent.browserEvent;
if (this.condition_(browserEvent)) {
if (this.kinetic_) {
this.kinetic_.begin(browserEvent);
this.kinetic_.begin(browserEvent.clientX, browserEvent.clientY);
}
var map = mapBrowserEvent.map;
map.requestRenderFrame();

View File

@@ -63,23 +63,25 @@ ol.Kinetic = function(decay, minVelocity, delay) {
/**
* @param {goog.events.BrowserEvent} browserEvent Browser event.
* @param {number} x X.
* @param {number} y Y.
*/
ol.Kinetic.prototype.begin = function(browserEvent) {
ol.Kinetic.prototype.begin = function(x, y) {
this.points_.length = 0;
this.angle_ = 0;
this.initialVelocity_ = 0;
this.update(browserEvent);
this.update(x, y);
};
/**
* @param {goog.events.BrowserEvent} browserEvent Browser event.
* @param {number} x X.
* @param {number} y Y.
*/
ol.Kinetic.prototype.update = function(browserEvent) {
ol.Kinetic.prototype.update = function(x, y) {
this.points_.push({
x: browserEvent.clientX,
y: browserEvent.clientY,
x: x,
y: y,
t: goog.now()
});
};