Merge pull request #9055 from fredj/less_typecast

Remove type cast in ol.View
This commit is contained in:
Frédéric Junod
2018-12-12 14:10:59 +01:00
committed by GitHub
+14 -17
View File
@@ -439,13 +439,14 @@ class View extends BaseObject {
for (let i = 0; i < animationCount; ++i) { for (let i = 0; i < animationCount; ++i) {
const options = /** @type {AnimationOptions} */ (arguments[i]); const options = /** @type {AnimationOptions} */ (arguments[i]);
const animation = /** @type {Animation} */ ({ const animation = {
start: start, start: start,
complete: false, complete: false,
anchor: options.anchor, anchor: options.anchor,
duration: options.duration !== undefined ? options.duration : 1000, duration: options.duration !== undefined ? options.duration : 1000,
easing: options.easing || inAndOut easing: options.easing || inAndOut,
}); callback: callback
};
if (options.center) { if (options.center) {
animation.sourceCenter = center; animation.sourceCenter = center;
@@ -471,8 +472,6 @@ class View extends BaseObject {
rotation = animation.targetRotation; rotation = animation.targetRotation;
} }
animation.callback = callback;
// check if animation is a no-op // check if animation is a no-op
if (isNoopAnimation(animation)) { if (isNoopAnimation(animation)) {
animation.complete = true; animation.complete = true;
@@ -902,18 +901,16 @@ class View extends BaseObject {
const resolution = /** @type {number} */ (this.getResolution()); const resolution = /** @type {number} */ (this.getResolution());
const pixelResolution = resolution / pixelRatio; const pixelResolution = resolution / pixelRatio;
const rotation = this.getRotation(); const rotation = this.getRotation();
return ( return {
/** @type {State} */ ({ center: [
center: [ Math.round(center[0] / pixelResolution) * pixelResolution,
Math.round(center[0] / pixelResolution) * pixelResolution, Math.round(center[1] / pixelResolution) * pixelResolution
Math.round(center[1] / pixelResolution) * pixelResolution ],
], projection: projection !== undefined ? projection : null,
projection: projection !== undefined ? projection : null, resolution: resolution,
resolution: resolution, rotation: rotation,
rotation: rotation, zoom: this.getZoom()
zoom: this.getZoom() };
})
);
} }
/** /**