forked from chromedp/cdproto
/
animation.go
288 lines (248 loc) · 9.01 KB
/
animation.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
// Package animation provides the Chrome DevTools Protocol
// commands, types, and events for the Animation domain.
//
// Generated by the cdproto-gen command.
package animation
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/seddonm1/cdproto/cdp"
"github.com/seddonm1/cdproto/runtime"
)
// DisableParams disables animation domain notifications.
type DisableParams struct{}
// Disable disables animation domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Animation.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// EnableParams enables animation domain notifications.
type EnableParams struct{}
// Enable enables animation domain notifications.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Animation.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// GetCurrentTimeParams returns the current time of the an animation.
type GetCurrentTimeParams struct {
ID string `json:"id"` // Id of animation.
}
// GetCurrentTime returns the current time of the an animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-getCurrentTime
//
// parameters:
// id - Id of animation.
func GetCurrentTime(id string) *GetCurrentTimeParams {
return &GetCurrentTimeParams{
ID: id,
}
}
// GetCurrentTimeReturns return values.
type GetCurrentTimeReturns struct {
CurrentTime float64 `json:"currentTime,omitempty"` // Current time of the page.
}
// Do executes Animation.getCurrentTime against the provided context.
//
// returns:
// currentTime - Current time of the page.
func (p *GetCurrentTimeParams) Do(ctx context.Context) (currentTime float64, err error) {
// execute
var res GetCurrentTimeReturns
err = cdp.Execute(ctx, CommandGetCurrentTime, p, &res)
if err != nil {
return 0, err
}
return res.CurrentTime, nil
}
// GetPlaybackRateParams gets the playback rate of the document timeline.
type GetPlaybackRateParams struct{}
// GetPlaybackRate gets the playback rate of the document timeline.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-getPlaybackRate
func GetPlaybackRate() *GetPlaybackRateParams {
return &GetPlaybackRateParams{}
}
// GetPlaybackRateReturns return values.
type GetPlaybackRateReturns struct {
PlaybackRate float64 `json:"playbackRate,omitempty"` // Playback rate for animations on page.
}
// Do executes Animation.getPlaybackRate against the provided context.
//
// returns:
// playbackRate - Playback rate for animations on page.
func (p *GetPlaybackRateParams) Do(ctx context.Context) (playbackRate float64, err error) {
// execute
var res GetPlaybackRateReturns
err = cdp.Execute(ctx, CommandGetPlaybackRate, nil, &res)
if err != nil {
return 0, err
}
return res.PlaybackRate, nil
}
// ReleaseAnimationsParams releases a set of animations to no longer be
// manipulated.
type ReleaseAnimationsParams struct {
Animations []string `json:"animations"` // List of animation ids to seek.
}
// ReleaseAnimations releases a set of animations to no longer be
// manipulated.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-releaseAnimations
//
// parameters:
// animations - List of animation ids to seek.
func ReleaseAnimations(animations []string) *ReleaseAnimationsParams {
return &ReleaseAnimationsParams{
Animations: animations,
}
}
// Do executes Animation.releaseAnimations against the provided context.
func (p *ReleaseAnimationsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandReleaseAnimations, p, nil)
}
// ResolveAnimationParams gets the remote object of the Animation.
type ResolveAnimationParams struct {
AnimationID string `json:"animationId"` // Animation id.
}
// ResolveAnimation gets the remote object of the Animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-resolveAnimation
//
// parameters:
// animationID - Animation id.
func ResolveAnimation(animationID string) *ResolveAnimationParams {
return &ResolveAnimationParams{
AnimationID: animationID,
}
}
// ResolveAnimationReturns return values.
type ResolveAnimationReturns struct {
RemoteObject *runtime.RemoteObject `json:"remoteObject,omitempty"` // Corresponding remote object.
}
// Do executes Animation.resolveAnimation against the provided context.
//
// returns:
// remoteObject - Corresponding remote object.
func (p *ResolveAnimationParams) Do(ctx context.Context) (remoteObject *runtime.RemoteObject, err error) {
// execute
var res ResolveAnimationReturns
err = cdp.Execute(ctx, CommandResolveAnimation, p, &res)
if err != nil {
return nil, err
}
return res.RemoteObject, nil
}
// SeekAnimationsParams seek a set of animations to a particular time within
// each animation.
type SeekAnimationsParams struct {
Animations []string `json:"animations"` // List of animation ids to seek.
CurrentTime float64 `json:"currentTime"` // Set the current time of each animation.
}
// SeekAnimations seek a set of animations to a particular time within each
// animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-seekAnimations
//
// parameters:
// animations - List of animation ids to seek.
// currentTime - Set the current time of each animation.
func SeekAnimations(animations []string, currentTime float64) *SeekAnimationsParams {
return &SeekAnimationsParams{
Animations: animations,
CurrentTime: currentTime,
}
}
// Do executes Animation.seekAnimations against the provided context.
func (p *SeekAnimationsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSeekAnimations, p, nil)
}
// SetPausedParams sets the paused state of a set of animations.
type SetPausedParams struct {
Animations []string `json:"animations"` // Animations to set the pause state of.
Paused bool `json:"paused"` // Paused state to set to.
}
// SetPaused sets the paused state of a set of animations.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-setPaused
//
// parameters:
// animations - Animations to set the pause state of.
// paused - Paused state to set to.
func SetPaused(animations []string, paused bool) *SetPausedParams {
return &SetPausedParams{
Animations: animations,
Paused: paused,
}
}
// Do executes Animation.setPaused against the provided context.
func (p *SetPausedParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPaused, p, nil)
}
// SetPlaybackRateParams sets the playback rate of the document timeline.
type SetPlaybackRateParams struct {
PlaybackRate float64 `json:"playbackRate"` // Playback rate for animations on page
}
// SetPlaybackRate sets the playback rate of the document timeline.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-setPlaybackRate
//
// parameters:
// playbackRate - Playback rate for animations on page
func SetPlaybackRate(playbackRate float64) *SetPlaybackRateParams {
return &SetPlaybackRateParams{
PlaybackRate: playbackRate,
}
}
// Do executes Animation.setPlaybackRate against the provided context.
func (p *SetPlaybackRateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPlaybackRate, p, nil)
}
// SetTimingParams sets the timing of an animation node.
type SetTimingParams struct {
AnimationID string `json:"animationId"` // Animation id.
Duration float64 `json:"duration"` // Duration of the animation.
Delay float64 `json:"delay"` // Delay of the animation.
}
// SetTiming sets the timing of an animation node.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#method-setTiming
//
// parameters:
// animationID - Animation id.
// duration - Duration of the animation.
// delay - Delay of the animation.
func SetTiming(animationID string, duration float64, delay float64) *SetTimingParams {
return &SetTimingParams{
AnimationID: animationID,
Duration: duration,
Delay: delay,
}
}
// Do executes Animation.setTiming against the provided context.
func (p *SetTimingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetTiming, p, nil)
}
// Command names.
const (
CommandDisable = "Animation.disable"
CommandEnable = "Animation.enable"
CommandGetCurrentTime = "Animation.getCurrentTime"
CommandGetPlaybackRate = "Animation.getPlaybackRate"
CommandReleaseAnimations = "Animation.releaseAnimations"
CommandResolveAnimation = "Animation.resolveAnimation"
CommandSeekAnimations = "Animation.seekAnimations"
CommandSetPaused = "Animation.setPaused"
CommandSetPlaybackRate = "Animation.setPlaybackRate"
CommandSetTiming = "Animation.setTiming"
)