mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
got to layouts
This commit is contained in:
@@ -6,11 +6,9 @@
|
||||
Pair
|
||||
} from "ui/animation";
|
||||
|
||||
import { View, Color } from "ui/core/view";
|
||||
import * as trace from "trace";
|
||||
import { View, Color, traceEnabled, traceWrite, traceCategories } from "ui/core/view";
|
||||
|
||||
export * from "ui/core/view";
|
||||
export { trace };
|
||||
|
||||
export module Properties {
|
||||
export var opacity = "opacity";
|
||||
@@ -65,8 +63,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
|
||||
throw new Error("No animation definitions specified");
|
||||
}
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("Analyzing " + animationDefinitions.length + " animation definitions...", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Analyzing " + animationDefinitions.length + " animation definitions...", traceCategories.Animation);
|
||||
}
|
||||
|
||||
this._propertyAnimations = new Array<PropertyAnimation>();
|
||||
@@ -78,8 +76,8 @@ export abstract class AnimationBase implements AnimationBaseDefinition {
|
||||
if (this._propertyAnimations.length === 0) {
|
||||
throw new Error("Nothing to animate.");
|
||||
}
|
||||
if (trace.enabled) {
|
||||
trace.write("Created " + this._propertyAnimations.length + " individual property animations.", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Created " + this._propertyAnimations.length + " individual property animations.", traceCategories.Animation);
|
||||
}
|
||||
|
||||
this._playSequentially = playSequentially;
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
AnimationBase, Properties, PropertyAnimation, CubicBezierAnimationCurve, AnimationPromise,
|
||||
opacityProperty, backgroundColorProperty, rotateProperty,
|
||||
translateXProperty, translateYProperty,
|
||||
scaleXProperty, scaleYProperty, Color, layout, trace
|
||||
scaleXProperty, scaleYProperty, Color, layout, traceWrite, traceEnabled, traceCategories
|
||||
} from "./animation-common";
|
||||
|
||||
import { CacheLayerType } from "utils/utils";
|
||||
@@ -39,35 +39,35 @@ propertyKeys[Properties.translate] = Symbol(keyPrefix + Properties.translate);
|
||||
export function _resolveAnimationCurve(curve: string | CubicBezierAnimationCurve | android.view.animation.Interpolator): android.view.animation.Interpolator {
|
||||
switch (curve) {
|
||||
case "easeIn":
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.AccelerateInterpolator(1).", traceCategories.Animation);
|
||||
}
|
||||
return easeIn();
|
||||
case "easeOut":
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.DecelerateInterpolator(1).", traceCategories.Animation);
|
||||
}
|
||||
return easeOut();
|
||||
case "easeInOut":
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.AccelerateDecelerateInterpolator().", traceCategories.Animation);
|
||||
}
|
||||
return easeInOut();
|
||||
case "linear":
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.LinearInterpolator().", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.LinearInterpolator().", traceCategories.Animation);
|
||||
}
|
||||
return linear();
|
||||
case "spring":
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to android.view.animation.BounceInterpolator().", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation curve resolved to android.view.animation.BounceInterpolator().", traceCategories.Animation);
|
||||
}
|
||||
return bounce();
|
||||
case "ease":
|
||||
return (<any>android).support.v4.view.animation.PathInterpolatorCompat.create(0.25, 0.1, 0.25, 1.0);
|
||||
default:
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation curve resolved to original: " + curve, trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation curve resolved to original: " + curve, traceCategories.Animation);
|
||||
}
|
||||
if (curve instanceof CubicBezierAnimationCurve) {
|
||||
return (<any>android).support.v4.view.animation.PathInterpolatorCompat.create(curve.x1, curve.y1, curve.x2, curve.y2);
|
||||
@@ -99,24 +99,24 @@ 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 (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("MainAnimatorListener.onAndroidAnimationStart(" + animator + ")", traceCategories.Animation);
|
||||
}
|
||||
},
|
||||
onAnimationRepeat: function (animator: android.animation.Animator): void {
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAnimationRepeat(" + animator + ")", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("MainAnimatorListener.onAnimationRepeat(" + animator + ")", traceCategories.Animation);
|
||||
}
|
||||
},
|
||||
onAnimationEnd: function (animator: android.animation.Animator): void {
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAnimationEnd(" + animator + ")", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("MainAnimatorListener.onAnimationEnd(" + animator + ")", traceCategories.Animation);
|
||||
}
|
||||
that.get()._onAndroidAnimationEnd();
|
||||
},
|
||||
onAnimationCancel: function (animator: android.animation.Animator): void {
|
||||
if (trace.enabled) {
|
||||
trace.write("MainAnimatorListener.onAnimationCancel(" + animator + ")", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("MainAnimatorListener.onAnimationCancel(" + animator + ")", traceCategories.Animation);
|
||||
}
|
||||
that.get()._onAndroidAnimationCancel();
|
||||
}
|
||||
@@ -152,8 +152,8 @@ export class Animation extends AnimationBase {
|
||||
|
||||
this._enableHardwareAcceleration();
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Starting " + this._nativeAnimatorsArray.length + " animations " + (this._playSequentially ? "sequentially." : "together."), traceCategories.Animation);
|
||||
}
|
||||
this._animatorSet.setupStartValues();
|
||||
this._animatorSet.start();
|
||||
@@ -162,8 +162,8 @@ export class Animation extends AnimationBase {
|
||||
|
||||
public cancel(): void {
|
||||
super.cancel();
|
||||
if (trace.enabled) {
|
||||
trace.write("Cancelling AnimatorSet.", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Cancelling AnimatorSet.", traceCategories.Animation);
|
||||
}
|
||||
this._animatorSet.cancel();
|
||||
}
|
||||
@@ -202,8 +202,8 @@ export class Animation extends AnimationBase {
|
||||
return;
|
||||
}
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Creating ObjectAnimator(s) for animation: " + Animation._getAnimationInfo(propertyAnimation) + "...", traceCategories.Animation);
|
||||
}
|
||||
|
||||
if (!propertyAnimation.target) {
|
||||
@@ -384,8 +384,8 @@ export class Animation extends AnimationBase {
|
||||
animators[i].setInterpolator(propertyAnimation.curve);
|
||||
}
|
||||
|
||||
if (trace.enabled) {
|
||||
trace.write("Animator created: " + animators[i], trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animator created: " + animators[i], traceCategories.Animation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { AnimationDefinition } from "ui/animation";
|
||||
import {
|
||||
AnimationBase, Properties, PropertyAnimation, CubicBezierAnimationCurve, AnimationPromise, View, opacityProperty, backgroundColorProperty, rotateProperty,
|
||||
translateXProperty, translateYProperty,
|
||||
scaleXProperty, scaleYProperty, trace
|
||||
scaleXProperty, scaleYProperty, traceEnabled, traceWrite, traceCategories
|
||||
} from "./animation-common";
|
||||
|
||||
import { ios } from "utils/utils";
|
||||
@@ -155,12 +155,12 @@ export class Animation extends AnimationBase {
|
||||
}
|
||||
|
||||
if (!playSequentially) {
|
||||
if (trace.enabled) {
|
||||
trace.write("Non-merged Property Animations: " + this._propertyAnimations.length, trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Non-merged Property Animations: " + this._propertyAnimations.length, traceCategories.Animation);
|
||||
}
|
||||
this._mergedPropertyAnimations = Animation._mergeAffineTransformAnimations(this._propertyAnimations);
|
||||
if (trace.enabled) {
|
||||
trace.write("Merged Property Animations: " + this._mergedPropertyAnimations.length, trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Merged Property Animations: " + this._mergedPropertyAnimations.length, traceCategories.Animation);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -188,14 +188,14 @@ export class Animation extends AnimationBase {
|
||||
}
|
||||
|
||||
if (that._cancelledAnimations > 0 && (that._cancelledAnimations + that._finishedAnimations) === that._mergedPropertyAnimations.length) {
|
||||
if (trace.enabled) {
|
||||
trace.write(that._cancelledAnimations + " animations cancelled.", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite(that._cancelledAnimations + " animations cancelled.", traceCategories.Animation);
|
||||
}
|
||||
that._rejectAnimationFinishedPromise();
|
||||
}
|
||||
else if (that._finishedAnimations === that._mergedPropertyAnimations.length) {
|
||||
if (trace.enabled) {
|
||||
trace.write(that._finishedAnimations + " animations finished.", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite(that._finishedAnimations + " animations finished.", traceCategories.Animation);
|
||||
}
|
||||
that._resolveAnimationFinishedPromise();
|
||||
}
|
||||
@@ -235,8 +235,8 @@ export class Animation extends AnimationBase {
|
||||
return (cancelled?: boolean) => {
|
||||
|
||||
if (cancelled && finishedCallback) {
|
||||
if (trace.enabled) {
|
||||
trace.write("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Animation " + (index - 1).toString() + " was cancelled. Will skip the rest of animations and call finishedCallback(true).", traceCategories.Animation);
|
||||
}
|
||||
finishedCallback(cancelled);
|
||||
return;
|
||||
@@ -556,12 +556,12 @@ export class Animation extends AnimationBase {
|
||||
iterations: propertyAnimations[i].iterations,
|
||||
curve: propertyAnimations[i].curve
|
||||
};
|
||||
if (trace.enabled) {
|
||||
trace.write("Curve: " + propertyAnimations[i].curve, trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Curve: " + propertyAnimations[i].curve, traceCategories.Animation);
|
||||
}
|
||||
newTransformAnimation.value[propertyAnimations[i].property] = propertyAnimations[i].value;
|
||||
if (trace.enabled) {
|
||||
trace.write("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Created new transform animation: " + Animation._getAnimationInfo(newTransformAnimation), traceCategories.Animation);
|
||||
}
|
||||
|
||||
// Merge all compatible affine transform animations to the right into this new animation.
|
||||
@@ -569,8 +569,8 @@ export class Animation extends AnimationBase {
|
||||
if (j < length) {
|
||||
for (; j < length; j++) {
|
||||
if (Animation._canBeMerged(propertyAnimations[i], propertyAnimations[j])) {
|
||||
if (trace.enabled) {
|
||||
trace.write("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", trace.categories.Animation);
|
||||
if (traceEnabled) {
|
||||
traceWrite("Merging animations: " + Animation._getAnimationInfo(newTransformAnimation) + " + " + Animation._getAnimationInfo(propertyAnimations[j]) + ";", traceCategories.Animation);
|
||||
}
|
||||
newTransformAnimation.value[propertyAnimations[j].property] = propertyAnimations[j].value;
|
||||
// Mark that it has been merged so we can skip it on our outer loop.
|
||||
|
||||
Reference in New Issue
Block a user