Skip to main content

browser_protocol/animation/
mod.rs

1use serde::{Serialize, Deserialize};
2
3/// Animation instance.
4
5#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6#[serde(rename_all = "camelCase")]
7pub struct Animation {
8    /// 'Animation''s id.
9
10    pub id: String,
11    /// 'Animation''s name.
12
13    pub name: String,
14    /// 'Animation''s internal paused state.
15
16    pub pausedState: bool,
17    /// 'Animation''s play state.
18
19    pub playState: String,
20    /// 'Animation''s playback rate.
21
22    pub playbackRate: f64,
23    /// 'Animation''s start time.
24    /// Milliseconds for time based animations and
25    /// percentage \[0 - 100\] for scroll driven animations
26    /// (i.e. when viewOrScrollTimeline exists).
27
28    pub startTime: f64,
29    /// 'Animation''s current time.
30
31    pub currentTime: f64,
32    /// Animation type of 'Animation'.
33
34    #[serde(rename = "type")]
35    pub type_: String,
36    /// 'Animation''s source animation node.
37
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub source: Option<AnimationEffect>,
40    /// A unique ID for 'Animation' representing the sources that triggered this CSS
41    /// animation/transition.
42
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub cssId: Option<String>,
45    /// View or scroll timeline
46
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub viewOrScrollTimeline: Option<ViewOrScrollTimeline>,
49}
50
51/// Timeline instance
52
53#[derive(Debug, Clone, Serialize, Deserialize, Default)]
54#[serde(rename_all = "camelCase")]
55pub struct ViewOrScrollTimeline {
56    /// Scroll container node
57
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub sourceNodeId: Option<crate::dom::BackendNodeId>,
60    /// Represents the starting scroll position of the timeline
61    /// as a length offset in pixels from scroll origin.
62
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub startOffset: Option<f64>,
65    /// Represents the ending scroll position of the timeline
66    /// as a length offset in pixels from scroll origin.
67
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub endOffset: Option<f64>,
70    /// The element whose principal box's visibility in the
71    /// scrollport defined the progress of the timeline.
72    /// Does not exist for animations with ScrollTimeline
73
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub subjectNodeId: Option<crate::dom::BackendNodeId>,
76    /// Orientation of the scroll
77
78    pub axis: crate::dom::ScrollOrientation,
79}
80
81/// AnimationEffect instance
82
83#[derive(Debug, Clone, Serialize, Deserialize, Default)]
84#[serde(rename_all = "camelCase")]
85pub struct AnimationEffect {
86    /// 'AnimationEffect''s delay.
87
88    pub delay: f64,
89    /// 'AnimationEffect''s end delay.
90
91    pub endDelay: f64,
92    /// 'AnimationEffect''s iteration start.
93
94    pub iterationStart: f64,
95    /// 'AnimationEffect''s iterations. Omitted if the value is infinite.
96
97    #[serde(skip_serializing_if = "Option::is_none")]
98    pub iterations: Option<f64>,
99    /// 'AnimationEffect''s iteration duration.
100    /// Milliseconds for time based animations and
101    /// percentage \[0 - 100\] for scroll driven animations
102    /// (i.e. when viewOrScrollTimeline exists).
103
104    pub duration: f64,
105    /// 'AnimationEffect''s playback direction.
106
107    pub direction: String,
108    /// 'AnimationEffect''s fill mode.
109
110    pub fill: String,
111    /// 'AnimationEffect''s target node.
112
113    #[serde(skip_serializing_if = "Option::is_none")]
114    pub backendNodeId: Option<crate::dom::BackendNodeId>,
115    /// 'AnimationEffect''s keyframes.
116
117    #[serde(skip_serializing_if = "Option::is_none")]
118    pub keyframesRule: Option<KeyframesRule>,
119    /// 'AnimationEffect''s timing function.
120
121    pub easing: String,
122}
123
124/// Keyframes Rule
125
126#[derive(Debug, Clone, Serialize, Deserialize, Default)]
127#[serde(rename_all = "camelCase")]
128pub struct KeyframesRule {
129    /// CSS keyframed animation's name.
130
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub name: Option<String>,
133    /// List of animation keyframes.
134
135    pub keyframes: Vec<KeyframeStyle>,
136}
137
138/// Keyframe Style
139
140#[derive(Debug, Clone, Serialize, Deserialize, Default)]
141#[serde(rename_all = "camelCase")]
142pub struct KeyframeStyle {
143    /// Keyframe's time offset.
144
145    pub offset: String,
146    /// 'AnimationEffect''s timing function.
147
148    pub easing: String,
149}
150
151/// Returns the current time of the an animation.
152
153#[derive(Debug, Clone, Serialize, Deserialize, Default)]
154#[serde(rename_all = "camelCase")]
155pub struct GetCurrentTimeParams {
156    /// Id of animation.
157
158    pub id: String,
159}
160
161/// Returns the current time of the an animation.
162
163#[derive(Debug, Clone, Serialize, Deserialize, Default)]
164#[serde(rename_all = "camelCase")]
165pub struct GetCurrentTimeReturns {
166    /// Current time of the page.
167
168    pub currentTime: f64,
169}
170
171/// Gets the playback rate of the document timeline.
172
173#[derive(Debug, Clone, Serialize, Deserialize, Default)]
174#[serde(rename_all = "camelCase")]
175pub struct GetPlaybackRateReturns {
176    /// Playback rate for animations on page.
177
178    pub playbackRate: f64,
179}
180
181/// Releases a set of animations to no longer be manipulated.
182
183#[derive(Debug, Clone, Serialize, Deserialize, Default)]
184#[serde(rename_all = "camelCase")]
185pub struct ReleaseAnimationsParams {
186    /// List of animation ids to seek.
187
188    pub animations: Vec<String>,
189}
190
191/// Gets the remote object of the Animation.
192
193#[derive(Debug, Clone, Serialize, Deserialize, Default)]
194#[serde(rename_all = "camelCase")]
195pub struct ResolveAnimationParams {
196    /// Animation id.
197
198    pub animationId: String,
199}
200
201/// Gets the remote object of the Animation.
202
203#[derive(Debug, Clone, Serialize, Deserialize, Default)]
204#[serde(rename_all = "camelCase")]
205pub struct ResolveAnimationReturns {
206    /// Corresponding remote object.
207
208    pub remoteObject: crate::runtime::RemoteObject,
209}
210
211/// Seek a set of animations to a particular time within each animation.
212
213#[derive(Debug, Clone, Serialize, Deserialize, Default)]
214#[serde(rename_all = "camelCase")]
215pub struct SeekAnimationsParams {
216    /// List of animation ids to seek.
217
218    pub animations: Vec<String>,
219    /// Set the current time of each animation.
220
221    pub currentTime: f64,
222}
223
224/// Sets the paused state of a set of animations.
225
226#[derive(Debug, Clone, Serialize, Deserialize, Default)]
227#[serde(rename_all = "camelCase")]
228pub struct SetPausedParams {
229    /// Animations to set the pause state of.
230
231    pub animations: Vec<String>,
232    /// Paused state to set to.
233
234    pub paused: bool,
235}
236
237/// Sets the playback rate of the document timeline.
238
239#[derive(Debug, Clone, Serialize, Deserialize, Default)]
240#[serde(rename_all = "camelCase")]
241pub struct SetPlaybackRateParams {
242    /// Playback rate for animations on page
243
244    pub playbackRate: f64,
245}
246
247/// Sets the timing of an animation node.
248
249#[derive(Debug, Clone, Serialize, Deserialize, Default)]
250#[serde(rename_all = "camelCase")]
251pub struct SetTimingParams {
252    /// Animation id.
253
254    pub animationId: String,
255    /// Duration of the animation.
256
257    pub duration: f64,
258    /// Delay of the animation.
259
260    pub delay: f64,
261}