mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Updated the animations API
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
2
ui/animation/animation.d.ts
vendored
2
ui/animation/animation.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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
8
ui/enums/enums.d.ts
vendored
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user