mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: cleanup
This commit is contained in:
@@ -12,12 +12,10 @@ import {
|
||||
// Requires.
|
||||
import { Color } from "../../color";
|
||||
import {
|
||||
isEnabled as traceEnabled, write as traceWrite,
|
||||
categories as traceCategories, messageType as traceType
|
||||
Trace
|
||||
} from "../../trace";
|
||||
import { PercentLength } from "../styling/style-properties";
|
||||
|
||||
export { Color, traceEnabled, traceWrite, traceCategories, traceType };
|
||||
export * from "./animation-interfaces";
|
||||
|
||||
export module Properties {
|
||||
@@ -57,8 +55,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
|
||||
throw new Error("No animation definitions specified");
|
||||
}
|
||||
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Analyzing " + animationDefinitions.length + " animation definitions...", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
this._propertyAnimations = new Array<PropertyAnimation>();
|
||||
@@ -72,8 +70,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
|
||||
if (this._propertyAnimations.length === 0) {
|
||||
throw new Error("Nothing to animate.");
|
||||
}
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Created " + this._propertyAnimations.length + " individual property animations.", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Created " + this._propertyAnimations.length + " individual property animations.", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
this._playSequentially = playSequentially;
|
||||
@@ -83,7 +81,7 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
|
||||
|
||||
protected _rejectAlreadyPlaying(): AnimationPromiseDefinition {
|
||||
const reason = "Animation is already playing.";
|
||||
traceWrite(reason, traceCategories.Animation, traceType.warn);
|
||||
Trace.write(reason, Trace.categories.Animation, Trace.messageType.warn);
|
||||
|
||||
return <AnimationPromiseDefinition>new Promise<void>((resolve, reject) => {
|
||||
reject(reason);
|
||||
|
||||
@@ -4,9 +4,10 @@ import { View } from "../core/view";
|
||||
|
||||
// Requires
|
||||
import {
|
||||
AnimationBase, Properties, CubicBezierAnimationCurve, Color, traceWrite,
|
||||
traceEnabled, traceCategories, traceType
|
||||
AnimationBase, Properties, CubicBezierAnimationCurve
|
||||
} from "./animation-common";
|
||||
import { Color } from "../../color";
|
||||
import { Trace } from "../../trace";
|
||||
import {
|
||||
opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty,
|
||||
translateXProperty, translateYProperty, scaleXProperty, scaleYProperty,
|
||||
@@ -44,40 +45,40 @@ propertyKeys[Properties.width] = Symbol(keyPrefix + Properties.width);
|
||||
export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator | android.view.animation.LinearInterpolator): android.view.animation.Interpolator {
|
||||
switch (curve) {
|
||||
case "easeIn":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
return easeIn();
|
||||
case "easeOut":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
return easeOut();
|
||||
case "easeInOut":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
return easeInOut();
|
||||
case "linear":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.LinearInterpolator().", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation curve resolved to android.view.animation.LinearInterpolator().", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
return linear();
|
||||
case "spring":
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.BounceInterpolator().", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation curve resolved to android.view.animation.BounceInterpolator().", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
return bounce();
|
||||
case "ease":
|
||||
return (<any>androidx).core.view.animation.PathInterpolatorCompat.create(0.25, 0.1, 0.25, 1.0);
|
||||
default:
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation curve resolved to original: " + curve, traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation curve resolved to original: " + curve, Trace.categories.Animation);
|
||||
}
|
||||
if (curve instanceof CubicBezierAnimationCurve) {
|
||||
return (<any>androidx).core.view.animation.PathInterpolatorCompat.create(curve.x1, curve.y1, curve.x2, curve.y2);
|
||||
@@ -143,18 +144,18 @@ export class Animation extends AnimationBase {
|
||||
let that = new WeakRef(this);
|
||||
this._animatorListener = new android.animation.Animator.AnimatorListener({
|
||||
onAnimationStart: function (animator: android.animation.Animator): void {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", Trace.categories.Animation);
|
||||
}
|
||||
},
|
||||
onAnimationRepeat: function (animator: android.animation.Animator): void {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("MainAnimatorListener.onAnimationRepeat(" + animator + ")", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("MainAnimatorListener.onAnimationRepeat(" + animator + ")", Trace.categories.Animation);
|
||||
}
|
||||
},
|
||||
onAnimationEnd: function (animator: android.animation.Animator): void {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("MainAnimatorListener.onAnimationEnd(" + animator + ")", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("MainAnimatorListener.onAnimationEnd(" + animator + ")", Trace.categories.Animation);
|
||||
}
|
||||
const thisRef = that.get();
|
||||
if (thisRef) {
|
||||
@@ -162,8 +163,8 @@ export class Animation extends AnimationBase {
|
||||
}
|
||||
},
|
||||
onAnimationCancel: function (animator: android.animation.Animator): void {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("MainAnimatorListener.onAnimationCancel(" + animator + ")", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("MainAnimatorListener.onAnimationCancel(" + animator + ")", Trace.categories.Animation);
|
||||
}
|
||||
const thisRef = that.get();
|
||||
if (thisRef) {
|
||||
@@ -207,12 +208,12 @@ export class Animation extends AnimationBase {
|
||||
|
||||
public cancel(): void {
|
||||
if (!this.isPlaying) {
|
||||
traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn);
|
||||
Trace.write("Animation is not currently playing.", Trace.categories.Animation, Trace.messageType.warn);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
traceWrite("Cancelling AnimatorSet.", traceCategories.Animation);
|
||||
Trace.write("Cancelling AnimatorSet.", Trace.categories.Animation);
|
||||
|
||||
this._animatorSet.cancel();
|
||||
}
|
||||
@@ -238,8 +239,8 @@ export class Animation extends AnimationBase {
|
||||
}
|
||||
}
|
||||
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), Trace.categories.Animation);
|
||||
}
|
||||
|
||||
this._animatorSet.setupStartValues();
|
||||
@@ -276,8 +277,8 @@ export class Animation extends AnimationBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", Trace.categories.Animation);
|
||||
}
|
||||
|
||||
if (propertyAnimation.target === null || propertyAnimation.target === undefined) {
|
||||
@@ -546,8 +547,8 @@ export class Animation extends AnimationBase {
|
||||
animators[i].setInterpolator(propertyAnimation.curve);
|
||||
}
|
||||
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animator created: " + animators[i], traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animator created: " + animators[i], Trace.categories.Animation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
/**
|
||||
* @module "ui/animation"
|
||||
*/ /** */
|
||||
|
||||
import { View, Color } from "../core/view";
|
||||
import { View } from "../core/view";
|
||||
import { Color } from "../../color";
|
||||
import { PercentLength } from "../styling/style-properties";
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,9 +7,9 @@ import { View } from "../core/view";
|
||||
|
||||
// Requires
|
||||
import {
|
||||
AnimationBase, Properties, CubicBezierAnimationCurve,
|
||||
traceWrite, traceEnabled, traceCategories, traceType
|
||||
AnimationBase, Properties, CubicBezierAnimationCurve
|
||||
} from "./animation-common";
|
||||
import { Trace } from "../../trace";
|
||||
import {
|
||||
opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty,
|
||||
translateXProperty, translateYProperty, scaleXProperty, scaleYProperty,
|
||||
@@ -167,12 +167,12 @@ export class Animation extends AnimationBase {
|
||||
}
|
||||
|
||||
if (!playSequentially) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Non-merged Property Animations: " + this._propertyAnimations.length, traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Non-merged Property Animations: " + this._propertyAnimations.length, Trace.categories.Animation);
|
||||
}
|
||||
this._mergedPropertyAnimations = Animation._mergeAffineTransformAnimations(this._propertyAnimations);
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Merged Property Animations: " + this._mergedPropertyAnimations.length, traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Merged Property Animations: " + this._mergedPropertyAnimations.length, Trace.categories.Animation);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -200,14 +200,14 @@ export class Animation extends AnimationBase {
|
||||
}
|
||||
|
||||
if (that._cancelledAnimations > 0 && (that._cancelledAnimations + that._finishedAnimations) === that._mergedPropertyAnimations.length) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite(that._cancelledAnimations + " animations cancelled.", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write(that._cancelledAnimations + " animations cancelled.", Trace.categories.Animation);
|
||||
}
|
||||
that._rejectAnimationFinishedPromise();
|
||||
}
|
||||
else if (that._finishedAnimations === that._mergedPropertyAnimations.length) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite(that._finishedAnimations + " animations finished.", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write(that._finishedAnimations + " animations finished.", Trace.categories.Animation);
|
||||
}
|
||||
that._resolveAnimationFinishedPromise();
|
||||
}
|
||||
@@ -232,7 +232,7 @@ export class Animation extends AnimationBase {
|
||||
|
||||
public cancel(): void {
|
||||
if (!this.isPlaying) {
|
||||
traceWrite("Animation is not currently playing.", traceCategories.Animation, traceType.warn);
|
||||
Trace.write("Animation is not currently playing.", Trace.categories.Animation, Trace.messageType.warn);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -256,8 +256,8 @@ export class Animation extends AnimationBase {
|
||||
return (cancelled?: boolean) => {
|
||||
|
||||
if (cancelled && finishedCallback) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", Trace.categories.Animation);
|
||||
}
|
||||
finishedCallback(cancelled);
|
||||
|
||||
@@ -664,12 +664,12 @@ export class Animation extends AnimationBase {
|
||||
iterations: propertyAnimations[i].iterations,
|
||||
curve: propertyAnimations[i].curve
|
||||
};
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Curve: " + propertyAnimations[i].curve, traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Curve: " + propertyAnimations[i].curve, Trace.categories.Animation);
|
||||
}
|
||||
newTransformAnimation.value[propertyAnimations[i].property] = propertyAnimations[i].value;
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), Trace.categories.Animation);
|
||||
}
|
||||
|
||||
// Merge all compatible affine transform animations to the right into this new animation.
|
||||
@@ -677,8 +677,8 @@ export class Animation extends AnimationBase {
|
||||
if (j < length) {
|
||||
for (; j < length; j++) {
|
||||
if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) {
|
||||
if (traceEnabled()) {
|
||||
traceWrite("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", traceCategories.Animation);
|
||||
if (Trace.isEnabled()) {
|
||||
Trace.write("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", Trace.categories.Animation);
|
||||
}
|
||||
newTransformAnimation.value[propertyAnimations[j].property] = propertyAnimations[j].value;
|
||||
// Mark that it has been merged so we can skip it on our outer loop.
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/**
|
||||
* @module "ui/animation/keyframe-animation"
|
||||
*/ /** */
|
||||
|
||||
import { View } from "../core/view";
|
||||
|
||||
export declare const ANIMATION_PROPERTIES;
|
||||
|
||||
@@ -8,11 +8,12 @@ import {
|
||||
KeyframeAnimation as KeyframeAnimationDefinition,
|
||||
} from "./keyframe-animation";
|
||||
|
||||
import { View, Color } from "../core/view";
|
||||
import { View } from "../core/view";
|
||||
import { Color } from "../../color";
|
||||
|
||||
import { AnimationCurve } from "../enums";
|
||||
|
||||
import { write as traceWrite, categories as traceCategories, messageType as traceType } from "../../trace";
|
||||
import { Trace } from "../../trace";
|
||||
|
||||
// Types.
|
||||
import { unsetValue } from "../core/properties";
|
||||
@@ -148,7 +149,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
|
||||
|
||||
public cancel() {
|
||||
if (!this.isPlaying) {
|
||||
traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn);
|
||||
Trace.write("Keyframe animation is already playing.", Trace.categories.Animation, Trace.messageType.warn);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -169,7 +170,7 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
|
||||
|
||||
public play(view: View): Promise<void> {
|
||||
if (this._isPlaying) {
|
||||
traceWrite("Keyframe animation is already playing.", traceCategories.Animation, traceType.warn);
|
||||
Trace.write("Keyframe animation is already playing.", Trace.categories.Animation, Trace.messageType.warn);
|
||||
|
||||
return new Promise<void>(resolve => {
|
||||
resolve();
|
||||
@@ -262,9 +263,9 @@ export class KeyframeAnimation implements KeyframeAnimationDefinition {
|
||||
animation.play(isLastIteration).then(() => {
|
||||
this.animate(view, index + 1, iterations);
|
||||
}, (error: any) => {
|
||||
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
|
||||
Trace.write(typeof error === "string" ? error : error.message, Trace.categories.Animation, Trace.messageType.warn);
|
||||
}).catch((error: any) => {
|
||||
traceWrite(typeof error === "string" ? error : error.message, traceCategories.Animation, traceType.warn);
|
||||
Trace.write(typeof error === "string" ? error : error.message, Trace.categories.Animation, Trace.messageType.warn);
|
||||
}); // tslint:disable-line
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user