animation.go 9.0 KB

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