Updated the animations API

This commit is contained in:
Tsvetan Raikov
2016-02-10 11:35:03 +02:00
parent eba3502f03
commit 7b440c822f
6 changed files with 21 additions and 8 deletions

View File

@@ -27,7 +27,7 @@ export interface PropertyAnimation {
curve?: any;
}
export class CustomAnimationCurve implements definition.CustomAnimationCurve {
export class CubicBezierAnimationCurve implements definition.CubicBezierAnimationCurve {
public x1: number;
public y1: number;

View File

@@ -327,9 +327,9 @@ export function _resolveAnimationCurve(curve: any): any {
return bounce;
default:
trace.write("Animation curve resolved to original: " + curve, trace.categories.Animation);
if (curve instanceof common.CustomAnimationCurve) {
var animationCurve = <common.CustomAnimationCurve>curve;
var interpolator = (<any>(<any>(<any>android.support.v4.view).animation).PathInterpolatorCompat).create(animationCurve.x1, animationCurve.y1, animationCurve.x2, animationCurve.y2);
if (curve instanceof common.CubicBezierAnimationCurve) {
var animationCurve = <common.CubicBezierAnimationCurve>curve;
var interpolator = (<any>android).support.v4.view.animation.PathInterpolatorCompat.create(animationCurve.x1, animationCurve.y1, animationCurve.x2, animationCurve.y2);
return interpolator;
}
return curve;

View File

@@ -64,7 +64,7 @@
* Defines a custom animation timing curve by using the cubic-bezier function.
* Possible values are numeric values from 0 to 1
*/
export class CustomAnimationCurve {
export class CubicBezierAnimationCurve {
public x1: number;
public y1: number;

View File

@@ -517,8 +517,8 @@ export function _resolveAnimationCurve(curve: any): any {
if (curve instanceof CAMediaTimingFunction) {
return curve;
}
else if (curve instanceof common.CustomAnimationCurve) {
var animationCurve = <common.CustomAnimationCurve>curve;
else if (curve instanceof common.CubicBezierAnimationCurve) {
var animationCurve = <common.CubicBezierAnimationCurve>curve;
return CAMediaTimingFunction.functionWithControlPoints(animationCurve.x1, animationCurve.y1, animationCurve.x2, animationCurve.y2);
}
return undefined;

8
ui/enums/enums.d.ts vendored
View File

@@ -1,5 +1,7 @@
declare module "ui/enums" {
import animationModule = require("ui/animation");
/**
* Represents a soft keyboard flavor.
*/
@@ -522,6 +524,7 @@
* Represents an animation curve type.
*/
module AnimationCurve {
/**
* An ease-in curve causes the animation to begin slowly, and then speed up as it progresses.
*/
@@ -546,5 +549,10 @@
* A spring animation curve causes an animation to produce a spring (bounce) effect.
*/
export var spring: string;
/**
* A custom cubic bezier function defined by its two control points. Possible values are numeric values from 0 to 1
*/
export function cubicBezier(x1: number, y1: number, x2: number, y2: number): animationModule.CubicBezierAnimationCurve;
}
}

View File

@@ -1,4 +1,6 @@
export module KeyboardType {
import animationModule = require("ui/animation");
export module KeyboardType {
export var datetime = "datetime";
export var phone = "phone";
export var number = "number";
@@ -163,4 +165,7 @@ export module AnimationCurve {
export var easeInOut = "easeInOut";
export var linear = "linear";
export var spring = "spring";
export function cubicBezier(x1: number, y1: number, x2: number, y2: number): animationModule.CubicBezierAnimationCurve {
return new animationModule.CubicBezierAnimationCurve(x1, y1 ,x2, y2);
}
}