mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Revert "Upgrade to TypeScript 2.1, and latest grunt-ts. (#3609)"
This reverts commit 79e6881ca6.
This commit is contained in:
@@ -44,6 +44,14 @@ export class CubicBezierAnimationCurve implements definition.CubicBezierAnimatio
|
||||
}
|
||||
}
|
||||
|
||||
// This is a BOGUS Class to make TypeScript happy - This is not needed other than to make TS happy.
|
||||
// We didn't want to actually modify Promise; as the cancel() is ONLY valid for animations "Promise"
|
||||
export class AnimationPromise implements definition.AnimationPromise {
|
||||
public cancel(): void { /* Do Nothing */ }
|
||||
public then(onFulfilled?: (value?: any) => void, onRejected?: (error?: any) => void): AnimationPromise { return new AnimationPromise(); }
|
||||
public catch(onRejected?: (error?: any) => void): AnimationPromise { return new AnimationPromise(); }
|
||||
}
|
||||
|
||||
export class Animation implements definition.Animation {
|
||||
public _propertyAnimations: Array<PropertyAnimation>;
|
||||
public _playSequentially: boolean;
|
||||
@@ -51,14 +59,14 @@ export class Animation implements definition.Animation {
|
||||
private _resolve;
|
||||
private _reject;
|
||||
|
||||
public play(): definition.AnimationPromise {
|
||||
public play(): AnimationPromise {
|
||||
if (this.isPlaying) {
|
||||
throw new Error("Animation is already playing.");
|
||||
}
|
||||
|
||||
// We have to actually create a "Promise" due to a bug in the v8 engine and decedent promises
|
||||
// We just cast it to a animationPromise so that all the rest of the code works fine
|
||||
var animationFinishedPromise = <definition.AnimationPromise>new Promise<void>((resolve, reject) => {
|
||||
var animationFinishedPromise = <AnimationPromise>new Promise<void>((resolve, reject) => {
|
||||
this._resolve = resolve;
|
||||
this._reject = reject;
|
||||
});
|
||||
@@ -69,7 +77,7 @@ export class Animation implements definition.Animation {
|
||||
return animationFinishedPromise;
|
||||
}
|
||||
|
||||
private fixupAnimationPromise(promise: definition.AnimationPromise): void {
|
||||
private fixupAnimationPromise(promise: AnimationPromise): void {
|
||||
// Since we are using function() below because of arguments, TS won't automatically do a _this for those functions.
|
||||
var _this = this;
|
||||
promise.cancel = () => {
|
||||
|
||||
14
tns-core-modules/ui/animation/animation.d.ts
vendored
14
tns-core-modules/ui/animation/animation.d.ts
vendored
@@ -82,14 +82,16 @@
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Cancelable {
|
||||
cancel(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Promise that can cancel the animation.
|
||||
* Create Promise that can cancel the animation, we have to pretend our returns itself along with the cancel
|
||||
*/
|
||||
export type AnimationPromise = Promise<void> & Cancelable;
|
||||
export class AnimationPromise extends Promise<void> {
|
||||
cancel(): void;
|
||||
then(onFulfilled?: (value?: any) => PromiseLike<void>, onRejected?: (error?: any) => PromiseLike<void>): AnimationPromise;
|
||||
then(onFulfilled?: (value?: any) => void, onRejected?: (error?: any) => void): AnimationPromise;
|
||||
catch(onRejected?: (error?: any) => PromiseLike<void>): AnimationPromise;
|
||||
catch(onRejected?: (error?: any) => void): AnimationPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a animation set.
|
||||
|
||||
Reference in New Issue
Block a user