UNPKG

8.84 kBTypeScriptView Raw
1declare namespace gsap {
2 type Timeline = SimpleTimeline | TimelineLite | TimelineMax;
3
4 class SimpleTimeline extends Animation {
5 /**
6 * SimpleTimeline is the base class for TimelineLite and TimelineMax, providing the most basic timeline () => voidality and it is used for the root timelines in TweenLite but is only
7 * intended for internal use in the GreenSock tweening platform. It is meant to be very fast and lightweight.
8 */
9 constructor(vars?: any);
10
11 /** If true, child tweens/timelines will be removed as soon as they complete. */
12 autoRemoveChildren: boolean;
13
14 /** Controls whether or not child tweens/timelines are repositioned automatically (changing their startTime) in order to maintain smooth playback when properties are changed on-the-fly. */
15 smoothChildTiming: boolean;
16
17 /** Adds a TweenLite, TweenMax, TimelineLite, or TimelineMax instance to the timeline at a specific time. */
18 add(child: any, position?: any, align?: string, stagger?: number): SimpleTimeline;
19
20 /** renders */
21 render(time: number, suppressEvents?: boolean, force?: boolean): SimpleTimeline;
22 }
23
24 class TimelineLite extends SimpleTimeline {
25 constructor(vars?: {});
26
27 /** Adds a tween, timeline, callback, or label (or an array of them) to the timeline. */
28 add(value: any, position?: any, align?: string, stagger?: number): TimelineLite;
29
30 /** Adds a label to the timeline, making it easy to mark important positions/times. */
31 addLabel(label: string, position: any): TimelineLite;
32
33 /** Inserts a special callback that pauses playback of the timeline at a particular time or label. */
34 addPause(position?: any, callback?: () => void, params?: any[], scope?: any): TimelineLite;
35
36 /**
37 * Adds a callback to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as
38 * add( TweenLite.delayedCall(...) ) but with less code.
39 */
40 call(callback: () => void, params?: any[], scope?: any, position?: any): TimelineLite;
41
42 /** Empties the timeline of all tweens, timelines, and callbacks (and optionally labels too). */
43 clear(labels?: boolean): TimelineLite;
44
45 /** Returns the time at which the animation will finish according to the parent timeline's local time. */
46 endTime(includeRepeats?: boolean): number;
47
48 /**
49 * Seamlessly transfers all tweens, timelines, and [optionally] delayed calls from the root timeline into a new TimelineLite so that you can perform advanced tasks on a seemingly global
50 * basis without affecting tweens/timelines that you create after the export.
51 */
52 static exportRoot(vars?: {}, omitDelayedCalls?: boolean): TimelineLite;
53
54 /**
55 * Adds a TweenLite.from() tween to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as
56 * add( TweenLite.from(...) ) but with less code.
57 */
58 from(target: {}, duration: number, vars: {}, position?: any): TimelineLite;
59
60 /** Adds a TweenLite.fromTo() tween to the end of the timeline - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.fromTo(...) ) but with less code. */
61 fromTo(target: {}, duration: number, fromVars: {}, toVars: {}, position?: any): TimelineLite;
62
63 /** Returns an array containing all the tweens and/or timelines nested in this timeline. */
64 getChildren(nested?: boolean, tweens?: boolean, timelines?: boolean, ignoreBeforeTime?: number): Array<Tween | Timeline>;
65
66 /** Returns the time associated with a particular label. */
67 getLabelTime(label: string): number;
68
69 /** Returns the tweens of a particular object that are inside this timeline. */
70 getTweensOf(target: {}, nested?: boolean): Tween[];
71
72 /**
73 * Clears any initialization data (like starting/ending values in tweens) which can be useful if, for example, you want to restart a tween without reverting to any previously recorded
74 * starting values.
75 */
76 invalidate(): TimelineLite;
77
78 /** Returns the most recently added child tween/timeline/callback regardless of its position in the timeline. */
79 recent(): Animation;
80
81 /** Removes a tween, timeline, callback, or label (or array of them) from the timeline. */
82 remove(value: any): TimelineLite;
83
84 /** Removes a label from the timeline and returns the time of that label. */
85 removeLabel(label: string): any;
86
87 /** Jumps to a specific time (or label) without affecting whether or not the instance is paused or reversed. */
88 seek(position: string | number, supressEvents?: boolean): TimelineLite;
89
90 /**
91 * Adds a zero-duration tween to the end of the timeline (or elsewhere using the "position" parameter) that sets values immediately (when the virtual playhead reaches that
92 * position on the timeline) - this is a convenience method that accomplishes exactly the same thing as add( TweenLite.to(target, 0, {...}) ) but with less code.
93 */
94 set(target: {}, vars: {}, position?: any): TimelineLite;
95
96 /** Shifts the startTime of the timeline's children by a certain amount and optionally adjusts labels too. */
97 shiftChildren(amount: number, adjustLabels?: boolean, ignoreBeforeTime?: number): TimelineLite;
98
99 /**
100 * Tweens an array of targets from a common set of destination values (using the current values as the destination), but staggers their start times by a specified amount of time,
101 * creating an evenly-spaced sequence with a surprisingly small amount of code.
102 */
103 staggerFrom(
104 targets: any,
105 duration: number,
106 vars: {},
107 stagger?: number,
108 position?: any,
109 onCompleteAll?: () => void,
110 onCompleteAllParams?: any[],
111 onCompleteScope?: any
112 ): TimelineLite;
113
114 /**
115 * Tweens an array of targets from and to a common set of values, but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly
116 * small amount of code.
117 */
118 staggerFromTo(
119 targets: any,
120 duration: number,
121 fromVars: {},
122 toVars: {},
123 stagger?: number,
124 position?: any,
125 onCompleteAll?: () => void,
126 onCompleteAllParams?: any[],
127 onCompleteAllScope?: any
128 ): TimelineLite;
129
130 /**
131 * Tweens an array of targets to a common set of destination values, but staggers their start times by a specified amount of time, creating an evenly-spaced sequence with a surprisingly
132 * small amount of code.
133 */
134 staggerTo(
135 targets: any,
136 duration: number,
137 vars: {},
138 stagger: number,
139 position?: any,
140 onCompleteAll?: () => void,
141 onCompleteAllParams?: any[],
142 onCompleteAllScope?: any
143 ): TimelineLite;
144
145 /**
146 * Adds a TweenLite.to() tween to the end of the timeline (or elsewhere using the "position" parameter) - this is a convenience method that accomplishes exactly the same thing as
147 * add( TweenLite.to(...) ) but with less code.
148 */
149 to(target: {}, duration: number, vars: {}, position?: any): TimelineLite;
150 usesFrames(): boolean;
151
152 /** If true, the timeline's timing mode is frames-based instead of seconds. */
153 useFrames(): boolean;
154 }
155
156 class TimelineMax extends TimelineLite {
157 constructor(vars?: {});
158
159 addCallback(callback: () => void, position: any, params?: any[], scope?: any): TimelineMax;
160 currentLabel(): string;
161 currentLabel(value: string): TimelineMax;
162 getActive(nested?: boolean, tweens?: boolean, timelines?: boolean): Tween | Timeline[];
163 getLabelAfter(time: number): string;
164 getLabelBefore(time: number): string;
165 getLabelsArray(): Array<{ name: string; time: number }>;
166 removeCallback(callback: () => void, timeOrLabel?: any): TimelineMax;
167 removePause(position: any): TimelineMax;
168 repeat(): number;
169 repeat(value: number): TimelineMax;
170 repeatDelay(): number;
171 repeatDelay(value: number): TimelineMax;
172 tweenFromTo(fromPosition: any, toPosition: any, vars?: {}): TweenLite;
173 tweenTo(position: any, vars?: {}): TweenLite;
174 yoyo(): boolean;
175 yoyo(value: boolean): TimelineMax;
176 }
177}