FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(animations): avoid steady mem consumption rise (#6004) · NativeScript/NativeScript@bcadcbe · GitHub

Commit bcadcbe

Browse files
authored
fix(animations): avoid steady mem consumption rise (#6004)
1 parent a37da87 commit bcadcbe

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎tns-core-modules/ui/animation/keyframe-animation.ts‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
106106
}
107107
}
108108

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

111111
const animation: KeyframeAnimation = new KeyframeAnimation();
112112
animation.delay = info.delay;
@@ -230,9 +230,19 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
230230
}
231231
}
232232
else {
233-
let animationDef = this.animations[index];
234-
(<any>animationDef).target = view;
235-
let animation = new Animation([animationDef]);
233+
let animation;
234+
const cachedAnimation = this._nativeAnimations[index - 1];
235+
236+
if (cachedAnimation) {
237+
animation = cachedAnimation;
238+
}
239+
else {
240+
let animationDef = this.animations[index];
241+
(<any>animationDef).target = view;
242+
animation = new Animation([animationDef]);
243+
this._nativeAnimations.push(animation);
244+
}
245+
236246
// Catch the animation cancel to prevent unhandled promise rejection warnings
237247
animation.play().then(() => {
238248
this.animate(view, index + 1, iterations);
@@ -241,7 +251,6 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
241251
}).catch((error: any) => {
242252
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
243253
}); // tslint:disable-line
244-
this._nativeAnimations.push(animation);
245254
}
246255
}
247256

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL