Skip to content

Commit

Permalink
Animate rotation when releasing mouse or fingers
Browse files Browse the repository at this point in the history
  • Loading branch information
elemoine authored and tschaub committed Mar 6, 2013
1 parent 33eb13d commit b9a286f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/ol/interaction/dragrotateinteraction.js
Expand Up @@ -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
Expand Down Expand Up @@ -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);
};

Expand Down
11 changes: 10 additions & 1 deletion src/ol/interaction/touchrotateinteraction.js
Expand Up @@ -8,6 +8,14 @@ goog.require('ol.ViewHint');
goog.require('ol.interaction.Touch');


/**
* @define {number} Animation duration.
*/
ol.interaction.TOUCHROTATE_ANIMATION_DURATION = 250;



/**
/**
* @constructor
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit b9a286f

Please sign in to comment.