UNPKG

3.45 kBTypeScriptView Raw
1type AnimationEffectTimingFillMode = "none" | "forwards" | "backwards" | "both" | "auto";
2type AnimationEffectTimingPlaybackDirection = "normal" | "reverse" | "alternate" | "alternate-reverse";
3
4interface AnimationPlaybackEvent {
5 target: Animation;
6 readonly currentTime: CSSNumberish | null;
7 readonly timelineTime: CSSNumberish | null;
8 type: string;
9 bubbles: boolean;
10 cancelable: boolean;
11 currentTarget: Animation;
12 defaultPrevented: boolean;
13 eventPhase: number;
14 timeStamp: number;
15}
16
17interface AnimationPlaybackEventInit extends EventInit {
18 currentTime?: CSSNumberish | null;
19 timelineTime?: CSSNumberish | null;
20}
21
22declare var AnimationPlaybackEvent: {
23 prototype: AnimationPlaybackEvent;
24 new(type: string, eventInitDict?: AnimationPlaybackEventInit): AnimationPlaybackEvent;
25};
26
27interface AnimationKeyFrame {
28 easing?: string | string[] | undefined;
29 offset?: number | Array<number | null> | null | undefined;
30 opacity?: number | number[] | undefined;
31 transform?: string | string[] | undefined;
32 // [key: string]: string | number | [string | number, string | number] | undefined; (duplicate string indexer in TypeScript 2.7+)
33}
34
35interface AnimationTimeline {
36 readonly currentTime: CSSNumberish | null;
37 getAnimations(): Animation[];
38 play(effect: KeyframeEffect): Animation;
39}
40interface AnimationEffectTiming {
41 delay?: number | undefined;
42 direction?: AnimationEffectTimingPlaybackDirection | undefined;
43 duration?: number | undefined;
44 easing?: string | undefined;
45 endDelay?: number | undefined;
46 fill?: AnimationEffectTimingFillMode | undefined;
47 iterationStart?: number | undefined;
48 iterations?: number | undefined;
49 playbackRate?: number | undefined;
50}
51
52interface AnimationEffectReadOnly {
53 readonly timing: number;
54 getComputedTiming(): ComputedTimingProperties;
55}
56
57interface ComputedTimingProperties {
58 endTime: number;
59 activeDuration: number;
60 localTime: number | null;
61 progress: number | null;
62 currentIteration: number | null;
63}
64
65type AnimationEventListener = ((this: Animation, evt: AnimationPlaybackEvent) => any) | null;
66
67interface Animation extends EventTarget {
68 currentTime: CSSNumberish | null;
69 id: string;
70 oncancel: AnimationEventListener;
71 onfinish: AnimationEventListener;
72 readonly playState: AnimationPlayState;
73 playbackRate: number;
74 startTime: CSSNumberish | null;
75 cancel(): void;
76 finish(): void;
77 pause(): void;
78 play(): void;
79 reverse(): void;
80 addEventListener(type: "finish" | "cancel", handler: EventListener): void;
81 removeEventListener(type: "finish" | "cancel", handler: EventListener): void;
82 effect: AnimationEffect | null;
83 readonly finished: Promise<Animation>;
84 readonly ready: Promise<Animation>;
85 timeline: AnimationTimeline | null;
86}
87
88declare var Animation: {
89 prototype: Animation;
90 new(effect?: AnimationEffect | null, timeline?: AnimationTimeline | null): Animation;
91};
92
93declare class SequenceEffect extends KeyframeEffect {
94 constructor(effects: KeyframeEffect[]);
95}
96declare class GroupEffect extends KeyframeEffect {
97 constructor(effects: KeyframeEffect[]);
98}
99interface Element {
100 animate(effect: AnimationKeyFrame | AnimationKeyFrame[] | null, timing: number | AnimationEffectTiming): Animation;
101 getAnimations(): Animation[];
102}
103interface Document {
104 readonly timeline: AnimationTimeline;
105}
106
\No newline at end of file