Add animation duration to ol.View2D.zoom
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
// FIXME works for View2D only
|
// FIXME works for View2D only
|
||||||
|
// FIXME dependency on ol.View2D suppressed to prevent dependency loop
|
||||||
|
|
||||||
goog.provide('ol.animation');
|
goog.provide('ol.animation');
|
||||||
|
|
||||||
goog.require('goog.fx.easing');
|
goog.require('goog.fx.easing');
|
||||||
goog.require('ol.PreRenderFunction');
|
goog.require('ol.PreRenderFunction');
|
||||||
goog.require('ol.View2D');
|
|
||||||
goog.require('ol.easing');
|
goog.require('ol.easing');
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ goog.require('ol.Projection');
|
|||||||
goog.require('ol.ResolutionConstraint');
|
goog.require('ol.ResolutionConstraint');
|
||||||
goog.require('ol.RotationConstraint');
|
goog.require('ol.RotationConstraint');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
|
goog.require('ol.animation');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -289,9 +290,16 @@ ol.View2D.prototype.zoom_ = function(map, resolution, opt_anchor) {
|
|||||||
* @param {ol.Map} map Map.
|
* @param {ol.Map} map Map.
|
||||||
* @param {number} delta Delta from previous zoom level.
|
* @param {number} delta Delta from previous zoom level.
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||||
|
* @param {number=} opt_duration Duration.
|
||||||
*/
|
*/
|
||||||
ol.View2D.prototype.zoom = function(map, delta, opt_anchor) {
|
ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) {
|
||||||
var resolution = this.constraints_.resolution(this.getResolution(), delta);
|
var currentResolution = this.getResolution();
|
||||||
|
if (goog.isDef(currentResolution) && goog.isDef(opt_duration)) {
|
||||||
|
map.requestRenderFrame();
|
||||||
|
map.addPreRenderFunction(ol.animation.createZoomFrom(
|
||||||
|
currentResolution, opt_duration));
|
||||||
|
}
|
||||||
|
var resolution = this.constraints_.resolution(currentResolution, delta);
|
||||||
this.zoom_(map, resolution, opt_anchor);
|
this.zoom_(map, resolution, opt_anchor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user