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

fix(animations): check if target is present before removing its anima… · NativeScript/NativeScript@4bd3a94 · GitHub

Commit 4bd3a94

Browse files
authored andcommitted
fix(animations): check if target is present before removing its animation (#4586)
In Angular, if the NativeScriptAnimationModule is imported in another NgModule more than once (which shouldn't be done), the renderer is instantiated twice. This causes animation with empty targets to be created. If such animation is removed, the app will crash. Additional check if the target is present will prevent this.
1 parent 1f9a64e commit 4bd3a94

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,20 @@ export class Animation extends AnimationBase {
192192
this._propertyUpdateCallbacks.forEach(v => v());
193193
this._disableHardwareAcceleration();
194194
this._resolveAnimationFinishedPromise();
195-
this._target._removeAnimation(this);
195+
196+
if (this._target) {
197+
this._target._removeAnimation(this);
198+
}
196199
}
197200

198201
private _onAndroidAnimationCancel() { // tslint:disable-line
199202
this._propertyResetCallbacks.forEach(v => v());
200203
this._disableHardwareAcceleration();
201204
this._rejectAnimationFinishedPromise();
202-
this._target._removeAnimation(this);
205+
206+
if (this._target) {
207+
this._target._removeAnimation(this);
208+
}
203209
}
204210

205211
private _createAnimators(propertyAnimation: PropertyAnimation): void {
@@ -482,4 +488,4 @@ export class Animation extends AnimationBase {
482488
}
483489
}
484490
}
485-
}
491+
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL