Fix end state for animation on view with invalid state

This commit is contained in:
Maximilian Krög
2021-10-02 23:30:12 +02:00
parent 84729e985f
commit 1be2c459c4

View File

@@ -621,29 +621,36 @@ class View extends BaseObject {
callback = arguments[animationCount - 1]; callback = arguments[animationCount - 1];
--animationCount; --animationCount;
} }
if (!this.isDef()) {
let i = 0;
for (; i < animationCount && !this.isDef(); ++i) {
// if view properties are not yet set, shortcut to the final state // if view properties are not yet set, shortcut to the final state
const state = arguments[animationCount - 1]; const state = arguments[i];
if (state.center) { if (state.center) {
this.setCenterInternal(state.center); this.setCenterInternal(state.center);
} }
if (state.zoom !== undefined) { if (state.zoom !== undefined) {
this.setZoom(state.zoom); this.setZoom(state.zoom);
} else if (state.resolution) {
this.setResolution(state.resolution);
} }
if (state.rotation !== undefined) { if (state.rotation !== undefined) {
this.setRotation(state.rotation); this.setRotation(state.rotation);
} }
}
if (i === animationCount) {
if (callback) { if (callback) {
animationCallback(callback, true); animationCallback(callback, true);
} }
return; return;
} }
let start = Date.now(); let start = Date.now();
let center = this.targetCenter_.slice(); let center = this.targetCenter_.slice();
let resolution = this.targetResolution_; let resolution = this.targetResolution_;
let rotation = this.targetRotation_; let rotation = this.targetRotation_;
const series = []; const series = [];
for (let i = 0; i < animationCount; ++i) { for (; i < animationCount; ++i) {
const options = /** @type {AnimationOptions} */ (arguments[i]); const options = /** @type {AnimationOptions} */ (arguments[i]);
const animation = { const animation = {