Add duration and easing options to view.fit() for animations

This commit is contained in:
Thomas Chandelle
2016-11-28 11:48:21 +01:00
parent d47e5aed10
commit 5b04771d3f
3 changed files with 78 additions and 4 deletions

View File

@@ -735,7 +735,6 @@ ol.View.prototype.fit = function(geometry, size, opt_options) {
}
resolution = constrainedResolution;
}
this.setResolution(resolution);
// calculate center
sinAngle = -sinAngle; // go back to original rotation
@@ -745,8 +744,19 @@ ol.View.prototype.fit = function(geometry, size, opt_options) {
centerRotY += (padding[0] - padding[2]) / 2 * resolution;
var centerX = centerRotX * cosAngle - centerRotY * sinAngle;
var centerY = centerRotY * cosAngle + centerRotX * sinAngle;
var center = [centerX, centerY];
this.setCenter([centerX, centerY]);
if (options.duration !== undefined) {
this.animate({
resolution: resolution,
center: center,
duration: options.duration,
easing: options.easing
});
} else {
this.setResolution(resolution);
this.setCenter(center);
}
};