Add duration and easing options to view.fit() for animations
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user