Skip to content

Commit

Permalink
fix(animations): avoid steady mem consumption rise (#6004)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartoYankov committed Jul 4, 2018
1 parent a37da87 commit bcadcbe
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions tns-core-modules/ui/animation/keyframe-animation.ts
Expand Up @@ -106,7 +106,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
}
}

animations.map(a => a["curve"] ? a : Object.assign(a, {curve: info.curve}));
animations.map(a => a["curve"] ? a : Object.assign(a, { curve: info.curve }));

const animation: KeyframeAnimation = new KeyframeAnimation();
animation.delay = info.delay;
Expand Down Expand Up @@ -230,9 +230,19 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
}
}
else {
let animationDef = this.animations[index];
(<any>animationDef).target = view;
let animation = new Animation([animationDef]);
let animation;
const cachedAnimation = this._nativeAnimations[index - 1];

if (cachedAnimation) {
animation = cachedAnimation;
}
else {
let animationDef = this.animations[index];
(<any>animationDef).target = view;
animation = new Animation([animationDef]);
this._nativeAnimations.push(animation);
}

// Catch the animation cancel to prevent unhandled promise rejection warnings
animation.play().then(() => {
this.animate(view, index + 1, iterations);
Expand All @@ -241,7 +251,6 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
}).catch((error: any) => {
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
}); // tslint:disable-line
this._nativeAnimations.push(animation);
}
}

Expand Down

0 comments on commit bcadcbe

Please sign in to comment.