mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
fix(animations): avoid steady mem consumption rise (#6004)
This commit is contained in:
@ -229,10 +229,20 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
|
|||||||
this._resolveAnimationFinishedPromise();
|
this._resolveAnimationFinishedPromise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
let animation;
|
||||||
|
const cachedAnimation = this._nativeAnimations[index - 1];
|
||||||
|
|
||||||
|
if (cachedAnimation) {
|
||||||
|
animation = cachedAnimation;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
let animationDef = this.animations[index];
|
let animationDef = this.animations[index];
|
||||||
(<any>animationDef).target = view;
|
(<any>animationDef).target = view;
|
||||||
let animation = new Animation([animationDef]);
|
animation = new Animation([animationDef]);
|
||||||
|
this._nativeAnimations.push(animation);
|
||||||
|
}
|
||||||
|
|
||||||
// Catch the animation cancel to prevent unhandled promise rejection warnings
|
// Catch the animation cancel to prevent unhandled promise rejection warnings
|
||||||
animation.play().then(() => {
|
animation.play().then(() => {
|
||||||
this.animate(view, index + 1, iterations);
|
this.animate(view, index + 1, iterations);
|
||||||
@ -241,7 +251,6 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
|
|||||||
}).catch((error: any) => {
|
}).catch((error: any) => {
|
||||||
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
|
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
|
||||||
}); // tslint:disable-line
|
}); // tslint:disable-line
|
||||||
this._nativeAnimations.push(animation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user