Skip to content

Commit 622f365

Browse files
authored
fix(animation): avoid uncaught reject on cancel (#10309)
1 parent 109dad1 commit 622f365

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

packages/core/ui/animation/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export class Animation extends AnimationBase {
248248
private _onAndroidAnimationCancel() {
249249
// tslint:disable-line
250250
this._propertyResetCallbacks.forEach((v) => v());
251-
this._rejectAnimationFinishedPromise();
251+
this._resolveAnimationFinishedPromise();
252252

253253
if (this._target) {
254254
this._target._removeAnimation(this);

packages/core/ui/animation/index.ios.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AnimationBase, Properties, CubicBezierAnimationCurve } from './animatio
77
import { Trace } from '../../trace';
88
import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, heightProperty, widthProperty, PercentLength } from '../styling/style-properties';
99

10-
import { iOSNativeHelper } from '../../utils/native-helper';
10+
import { ios as iosHelper } from '../../utils/native-helper';
1111

1212
import { Screen } from '../../platform';
1313

@@ -168,33 +168,28 @@ export class Animation extends AnimationBase {
168168
this._mergedPropertyAnimations = this._propertyAnimations;
169169
}
170170

171-
const that = this;
172171
const animationFinishedCallback = (cancelled: boolean) => {
173-
if (that._playSequentially) {
172+
if (this._playSequentially) {
174173
// This function will be called by the last animation when done or by another animation if the user cancels them halfway through.
175-
if (cancelled) {
176-
that._rejectAnimationFinishedPromise();
177-
} else {
178-
that._resolveAnimationFinishedPromise();
179-
}
174+
this._resolveAnimationFinishedPromise();
180175
} else {
181176
// This callback will be called by each INDIVIDUAL animation when it finishes or is cancelled.
182177
if (cancelled) {
183-
that._cancelledAnimations++;
178+
this._cancelledAnimations++;
184179
} else {
185-
that._finishedAnimations++;
180+
this._finishedAnimations++;
186181
}
187182

188-
if (that._cancelledAnimations > 0 && that._cancelledAnimations + that._finishedAnimations === that._mergedPropertyAnimations.length) {
183+
if (this._cancelledAnimations > 0 && this._cancelledAnimations + this._finishedAnimations === this._mergedPropertyAnimations.length) {
189184
if (Trace.isEnabled()) {
190-
Trace.write(that._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation);
185+
Trace.write(this._cancelledAnimations + ' animations cancelled.', Trace.categories.Animation);
191186
}
192-
that._rejectAnimationFinishedPromise();
193-
} else if (that._finishedAnimations === that._mergedPropertyAnimations.length) {
187+
this._resolveAnimationFinishedPromise();
188+
} else if (this._finishedAnimations === this._mergedPropertyAnimations.length) {
194189
if (Trace.isEnabled()) {
195-
Trace.write(that._finishedAnimations + ' animations finished.', Trace.categories.Animation);
190+
Trace.write(this._finishedAnimations + ' animations finished.', Trace.categories.Animation);
196191
}
197-
that._resolveAnimationFinishedPromise();
192+
this._resolveAnimationFinishedPromise();
198193
}
199194
}
200195
};
@@ -719,7 +714,7 @@ function calculateTransform(view: View): CATransform3D {
719714
}
720715

721716
expectedTransform = CATransform3DTranslate(expectedTransform, view.translateX, view.translateY, 0);
722-
expectedTransform = iOSNativeHelper.applyRotateTransform(expectedTransform, view.rotateX, view.rotateY, view.rotate);
717+
expectedTransform = iosHelper.applyRotateTransform(expectedTransform, view.rotateX, view.rotateY, view.rotate);
723718
expectedTransform = CATransform3DScale(expectedTransform, scaleX, scaleY, 1);
724719

725720
return expectedTransform;

0 commit comments

Comments
 (0)