Animate rotation when releasing mouse or fingers

This commit is contained in:
Éric Lemoine
2013-03-04 20:30:15 +01:00
parent c431acacca
commit d42d88c198
2 changed files with 18 additions and 2 deletions

View File

@@ -6,6 +6,12 @@ goog.require('ol.interaction.ConditionType');
goog.require('ol.interaction.Drag');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGROTATE_ANIMATION_DURATION = 250;
/**
* @constructor
@@ -62,7 +68,8 @@ ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) {
// FIXME supports View2D only
var view = map.getView();
goog.asserts.assert(view instanceof ol.View2D);
view.rotate(map, view.getRotation());
view.rotate(map, view.getRotation(), undefined,
ol.interaction.DRAGROTATE_ANIMATION_DURATION);
view.setHint(ol.ViewHint.INTERACTING, -1);
};

View File

@@ -8,6 +8,14 @@ goog.require('ol.ViewHint');
goog.require('ol.interaction.Touch');
/**
* @define {number} Animation duration.
*/
ol.interaction.TOUCHROTATE_ANIMATION_DURATION = 250;
/**
/**
* @constructor
@@ -104,7 +112,8 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd =
var map = mapBrowserEvent.map;
var view = map.getView();
if (this.rotating_) {
view.rotate(map, view.getRotation());
view.rotate(map, view.getRotation(), undefined,
ol.interaction.TOUCHROTATE_ANIMATION_DURATION);
}
view.setHint(ol.ViewHint.INTERACTING, -1);
return false;