mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
Add a flag we can use to skip string template calcs in release
This commit is contained in:
@ -114,7 +114,9 @@ export class Animation implements definition.Animation {
|
||||
|
||||
ensureTrace();
|
||||
|
||||
trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", trace.categories.Animation);
|
||||
}
|
||||
this._propertyAnimations = new Array<PropertyAnimation>();
|
||||
var i = 0;
|
||||
var length = animationDefinitions.length;
|
||||
@ -126,7 +128,9 @@ export class Animation implements definition.Animation {
|
||||
if (this._propertyAnimations.length === 0) {
|
||||
throw new Error("Nothing to animate.");
|
||||
}
|
||||
trace.write("Created " + this._propertyAnimations.length + " individual property animations.", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Created " + this._propertyAnimations.length + " individual property animations.", trace.categories.Animation);
|
||||
}
|
||||
|
||||
this._playSequentially = playSequentially;
|
||||
}
|
||||
|
@ -72,7 +72,9 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
}
|
||||
}
|
||||
|
||||
trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), trace.categories.Animation);
|
||||
}
|
||||
this._animatorSet.setupStartValues();
|
||||
this._animatorSet.start();
|
||||
return animationFinishedPromise;
|
||||
@ -80,7 +82,9 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
|
||||
public cancel(): void {
|
||||
super.cancel();
|
||||
trace.write("Cancelling AnimatorSet.", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Cancelling AnimatorSet.", trace.categories.Animation);
|
||||
}
|
||||
this._animatorSet.cancel();
|
||||
}
|
||||
|
||||
@ -94,17 +98,25 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
let that = this;
|
||||
this._animatorListener = new android.animation.Animator.AnimatorListener({
|
||||
onAnimationStart: function (animator: android.animation.Animator): void {
|
||||
trace.write("MainAnimatorListener.onAndroidAnimationStart(" + animator +")", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAndroidAnimationStart(" + animator +")", trace.categories.Animation);
|
||||
}
|
||||
},
|
||||
onAnimationRepeat: function (animator: android.animation.Animator): void {
|
||||
trace.write("MainAnimatorListener.onAnimationRepeat(" + animator + ")", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAnimationRepeat(" + animator + ")", trace.categories.Animation);
|
||||
}
|
||||
},
|
||||
onAnimationEnd: function (animator: android.animation.Animator): void {
|
||||
trace.write("MainAnimatorListener.onAnimationEnd(" + animator + ")", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAnimationEnd(" + animator + ")", trace.categories.Animation);
|
||||
}
|
||||
that._onAndroidAnimationEnd();
|
||||
},
|
||||
onAnimationCancel: function (animator: android.animation.Animator): void {
|
||||
trace.write("MainAnimatorListener.onAnimationCancel(" + animator + ")", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAnimationCancel(" + animator + ")", trace.categories.Animation);
|
||||
}
|
||||
that._onAndroidAnimationCancel();
|
||||
}
|
||||
});
|
||||
@ -139,7 +151,9 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
return;
|
||||
}
|
||||
|
||||
trace.write("Creating ObjectAnimator(s) for animation: " + common.Animation._getAnimationInfo(propertyAnimation) + "...", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Creating ObjectAnimator(s) for animation: " + common.Animation._getAnimationInfo(propertyAnimation) + "...", trace.categories.Animation);
|
||||
}
|
||||
|
||||
if (types.isNullOrUndefined(propertyAnimation.target)) {
|
||||
throw new Error("Animation target cannot be null or undefined!");
|
||||
@ -347,7 +361,10 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
if (propertyAnimation.curve !== undefined) {
|
||||
animators[i].setInterpolator(propertyAnimation.curve);
|
||||
}
|
||||
trace.write("Animator created: " + animators[i], trace.categories.Animation);
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("Animator created: " + animators[i], trace.categories.Animation);
|
||||
}
|
||||
}
|
||||
|
||||
this._animators = this._animators.concat(animators);
|
||||
@ -368,24 +385,36 @@ let bounce = lazy(() => new android.view.animation.BounceInterpolator());
|
||||
export function _resolveAnimationCurve(curve: any): any {
|
||||
switch (curve) {
|
||||
case enums.AnimationCurve.easeIn:
|
||||
trace.write("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", trace.categories.Animation);
|
||||
}
|
||||
return easeIn();
|
||||
case enums.AnimationCurve.easeOut:
|
||||
trace.write("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", trace.categories.Animation);
|
||||
}
|
||||
return easeOut();
|
||||
case enums.AnimationCurve.easeInOut:
|
||||
trace.write("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", trace.categories.Animation);
|
||||
}
|
||||
return easeInOut();
|
||||
case enums.AnimationCurve.linear:
|
||||
trace.write("Animation curve resolved to android.view.animation.LinearInterpolator().", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.LinearInterpolator().", trace.categories.Animation);
|
||||
}
|
||||
return linear();
|
||||
case enums.AnimationCurve.spring:
|
||||
trace.write("Animation curve resolved to android.view.animation.BounceInterpolator().", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.BounceInterpolator().", trace.categories.Animation);
|
||||
}
|
||||
return bounce();
|
||||
case enums.AnimationCurve.ease:
|
||||
return (<any>android).support.v4.view.animation.PathInterpolatorCompat.create(0.25, 0.1, 0.25, 1.0);
|
||||
default:
|
||||
trace.write("Animation curve resolved to original: " + curve, trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to original: " + curve, trace.categories.Animation);
|
||||
}
|
||||
if (curve instanceof common.CubicBezierAnimationCurve) {
|
||||
let animationCurve = <common.CubicBezierAnimationCurve>curve;
|
||||
let interpolator = (<any>android).support.v4.view.animation.PathInterpolatorCompat.create(animationCurve.x1, animationCurve.y1, animationCurve.x2, animationCurve.y2);
|
||||
|
@ -142,9 +142,13 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
}
|
||||
|
||||
if (!playSequentially) {
|
||||
trace.write("Non-merged Property Animations: " + this._propertyAnimations.length, trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Non-merged Property Animations: " + this._propertyAnimations.length, trace.categories.Animation);
|
||||
}
|
||||
this._mergedPropertyAnimations = Animation._mergeAffineTransformAnimations(this._propertyAnimations);
|
||||
trace.write("Merged Property Animations: " + this._mergedPropertyAnimations.length, trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Merged Property Animations: " + this._mergedPropertyAnimations.length, trace.categories.Animation);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._mergedPropertyAnimations = this._propertyAnimations;
|
||||
@ -171,11 +175,15 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
}
|
||||
|
||||
if (that._cancelledAnimations > 0 && (that._cancelledAnimations + that._finishedAnimations) === that._mergedPropertyAnimations.length) {
|
||||
trace.write(that._cancelledAnimations + " animations cancelled.", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write(that._cancelledAnimations + " animations cancelled.", trace.categories.Animation);
|
||||
}
|
||||
that._rejectAnimationFinishedPromise();
|
||||
}
|
||||
else if (that._finishedAnimations === that._mergedPropertyAnimations.length) {
|
||||
trace.write(that._finishedAnimations + " animations finished.", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write(that._finishedAnimations + " animations finished.", trace.categories.Animation);
|
||||
}
|
||||
that._resolveAnimationFinishedPromise();
|
||||
}
|
||||
}
|
||||
@ -188,7 +196,9 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
return (cancelled?: boolean) => {
|
||||
|
||||
if (cancelled && finishedCallback) {
|
||||
trace.write("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", trace.categories.Animation);
|
||||
}
|
||||
finishedCallback(cancelled);
|
||||
return;
|
||||
}
|
||||
@ -526,16 +536,22 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
iterations: propertyAnimations[i].iterations,
|
||||
curve: propertyAnimations[i].curve
|
||||
};
|
||||
trace.write("Curve: " + propertyAnimations[i].curve, trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Curve: " + propertyAnimations[i].curve, trace.categories.Animation);
|
||||
}
|
||||
newTransformAnimation.value[propertyAnimations[i].property] = propertyAnimations[i].value;
|
||||
trace.write("Created new transform animation: " + common.Animation._getAnimationInfo(newTransformAnimation), trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Created new transform animation: " + common.Animation._getAnimationInfo(newTransformAnimation), trace.categories.Animation);
|
||||
}
|
||||
|
||||
// Merge all compatible affine transform animations to the right into this new animation.
|
||||
j = i + 1;
|
||||
if (j < length) {
|
||||
for (; j < length; j++) {
|
||||
if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) {
|
||||
trace.write("Merging animations: " + common.Animation._getAnimationInfo(newTransformAnimation) + " + " + common.Animation._getAnimationInfo(propertyAnimations[j]) + ";", trace.categories.Animation);
|
||||
if (trace.enabled) {
|
||||
trace.write("Merging animations: " + common.Animation._getAnimationInfo(newTransformAnimation) + " + " + common.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.
|
||||
propertyAnimations[j][_skip] = true;
|
||||
|
Reference in New Issue
Block a user