UNPKG

2.93 kBTypeScriptView Raw
1import { View } from '../core/view';
2import { CoreTypes } from '../../core-types';
3import { Color } from '../../color';
4
5export declare const ANIMATION_PROPERTIES;
6
7interface Keyframe {
8 backgroundColor?: Color;
9 scale?: { x: number; y: number };
10 translate?: { x: number; y: number };
11 rotate?: { x: number; y: number; z: number };
12 opacity?: number;
13 width?: CoreTypes.PercentLengthType;
14 height?: CoreTypes.PercentLengthType;
15 valueSource?: 'keyframe' | 'animation';
16 duration?: number;
17 curve?: any;
18 forceLayer?: boolean;
19}
20
21export interface Keyframes {
22 name: string;
23 keyframes: Array<UnparsedKeyframe>;
24}
25
26export interface UnparsedKeyframe {
27 values: Array<any>;
28 declarations: Array<KeyframeDeclaration>;
29}
30
31export interface KeyframeDeclaration {
32 property: string;
33 value: any;
34}
35
36export interface KeyframeInfo {
37 duration: number;
38 declarations: Array<KeyframeDeclaration>;
39 curve?: any;
40}
41
42/**
43 * Defines animation options for the View.animate method.
44 */
45export class KeyframeAnimationInfo {
46 /**
47 * Return animation keyframes.
48 */
49 keyframes: Array<KeyframeInfo>;
50
51 /**
52 * The animation name.
53 */
54 name?: string;
55
56 /**
57 * The length of the animation in milliseconds. The default duration is 300 milliseconds.
58 */
59 duration?: number;
60
61 /**
62 * The amount of time, in milliseconds, to delay starting the animation.
63 */
64 delay?: number;
65
66 /**
67 * Specifies how many times the animation should be played. Default is 1.
68 * iOS animations support fractional iterations, i.e. 1.5.
69 * To repeat an animation infinitely, use Number.POSITIVE_INFINITY
70 */
71 iterations?: number;
72
73 /**
74 * An optional animation curve. Possible values are contained in the [AnimationCurve enumeration](../modules/_ui_enums_.animationcurve.html).
75 * Alternatively, you can pass an instance of type UIViewAnimationCurve for iOS or android.animation.TimeInterpolator for Android.
76 */
77 curve?: any;
78
79 /**
80 * Determines whether the animation values will be applied on the animated object after the animation finishes.
81 */
82 isForwards: boolean;
83
84 /**
85 * If true the animation will be played backwards.
86 */
87 isReverse?: boolean;
88}
89
90export class KeyframeAnimation {
91 animations: Array<Keyframe>;
92
93 /**
94 * The amount of time, in milliseconds, to delay starting the animation.
95 */
96 delay: number;
97
98 /**
99 * Specifies how many times the animation should be played. Default is 1.
100 * iOS animations support fractional iterations, i.e. 1.5.
101 * To repeat an animation infinitely, use Number.POSITIVE_INFINITY
102 */
103 iterations: number;
104
105 /**
106 * Returns true if the application is currently running.
107 */
108 isPlaying: boolean;
109
110 /**
111 * Plays the animation.
112 */
113 public play: (view: View) => Promise<void>;
114
115 /**
116 * Cancels a playing animation.
117 */
118 public cancel: () => void;
119
120 /**
121 * Creates a keyframe animation from animation definition.
122 */
123 public static keyframeAnimationFromInfo(info: KeyframeAnimationInfo): KeyframeAnimation;
124}