8000 Merge pull request #1941 from NativeScript/raikov/fix-animation-crash · hbcodeXCI/NativeScript@77ef136 · GitHub
[go: up one dir, main page]

Skip to content

Commit 77ef136

Browse files
committed
Merge pull request NativeScript#1941 from NativeScript/raikov/fix-animation-crash
Fixed: There is a crash when executing animations in Android too fast
2 parents dfcb33f + df2ad08 commit 77ef136

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

ui/animation/animation.android.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export class Animation extends common.Animation implements definition.Animation
3232
private _propertyUpdateCallbacks: Array<Function>;
3333
private _propertyResetCallbacks: Array<Function>;
3434
private _valueSource: number;
35-
35+
3636
public play(): definition.AnimationPromise {
37-
var animationFinishedPromise = super.play();
37+
let animationFinishedPromise = super.play();
3838

3939
let i: number;
4040
let length: number;
@@ -58,11 +58,13 @@ export class Animation extends common.Animation implements definition.Animation
5858

5959
this._animatorSet = new android.animation.AnimatorSet();
6060
this._animatorSet.addListener(this._animatorListener);
61-
if (this._playSequentially) {
62-
this._animatorSet.playSequentially(this._nativeAnimatorsArray);
63-
}
64-
else {
65-
this._animatorSet.playTogether(this._nativeAnimatorsArray);
61+
if (length > 0) {
62+
if (this._playSequentially) {
63+
this._animatorSet.playSequentially(this._nativeAnimatorsArray);
64+
}
65+
else {
66+
this._animatorSet.playTogether(this._nativeAnimatorsArray);
67+
}
6668
}
6769

6870
trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), trace.categories.Animation);
@@ -127,6 +129,11 @@ export class Animation extends common.Animation implements definition.Animation
127129
}
128130

129131
private _createAnimators(propertyAnimation: common.PropertyAnimation): void {
132+
133+
if (!propertyAnimation.target._nativeView) {
134+
return;
135+
}
136+
130137
trace.write("Creating ObjectAnimator(s) for animation: " + common.Animation._getAnimationInfo(propertyAnimation) + "...", trace.categories.Animation);
131138

132139
if (types.isNullOrUndefined(propertyAnimation.target)) {

ui/styling/css-selector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class CssSelector {
8888
}
8989
}
9090
});
91-
if (this.animations && view.isLoaded) {
91+
if (this.animations && view.isLoaded && view._nativeView !== undefined) {
9292
for (let animationInfo of this.animations) {
9393
let animation = keyframeAnimation.KeyframeAnimation.keyframeAnimationFromInfo(animationInfo, modifier);
9494
if (animation) {

0 commit comments

Comments
 (0)
0