Skip to content

animation

Animation dataclass

Animation instance.

Source code in zendriver/cdp/animation.py
@dataclass class Animation:  """  Animation instance.  """   #: ``Animation``'s id.  id_: str   #: ``Animation``'s name.  name: str   #: ``Animation``'s internal paused state.  paused_state: bool   #: ``Animation``'s play state.  play_state: str   #: ``Animation``'s playback rate.  playback_rate: float   #: ``Animation``'s start time.  #: Milliseconds for time based animations and  #: percentage [0 - 100] for scroll driven animations  #: (i.e. when viewOrScrollTimeline exists).  start_time: float   #: ``Animation``'s current time.  current_time: float   #: Animation type of ``Animation``.  type_: str   #: ``Animation``'s source animation node.  source: typing.Optional[AnimationEffect] = None   #: A unique ID for ``Animation`` representing the sources that triggered this CSS  #: animation/transition.  css_id: typing.Optional[str] = None   #: View or scroll timeline  view_or_scroll_timeline: typing.Optional[ViewOrScrollTimeline] = None   def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["id"] = self.id_  json["name"] = self.name  json["pausedState"] = self.paused_state  json["playState"] = self.play_state  json["playbackRate"] = self.playback_rate  json["startTime"] = self.start_time  json["currentTime"] = self.current_time  json["type"] = self.type_  if self.source is not None:  json["source"] = self.source.to_json()  if self.css_id is not None:  json["cssId"] = self.css_id  if self.view_or_scroll_timeline is not None:  json["viewOrScrollTimeline"] = self.view_or_scroll_timeline.to_json()  return json   @classmethod  def from_json(cls, json: T_JSON_DICT) -> Animation:  return cls(  id_=str(json["id"]),  name=str(json["name"]),  paused_state=bool(json["pausedState"]),  play_state=str(json["playState"]),  playback_rate=float(json["playbackRate"]),  start_time=float(json["startTime"]),  current_time=float(json["currentTime"]),  type_=str(json["type"]),  source=AnimationEffect.from_json(json["source"])  if json.get("source", None) is not None  else None,  css_id=str(json["cssId"]) if json.get("cssId", None) is not None else None,  view_or_scroll_timeline=ViewOrScrollTimeline.from_json(  json["viewOrScrollTimeline"]  )  if json.get("viewOrScrollTimeline", None) is not None  else None,  ) 

css_id: typing.Optional[str] = None class-attribute instance-attribute

current_time: float instance-attribute

id_: str instance-attribute

name: str instance-attribute

paused_state: bool instance-attribute

play_state: str instance-attribute

playback_rate: float instance-attribute

source: typing.Optional[AnimationEffect] = None class-attribute instance-attribute

start_time: float instance-attribute

type_: str instance-attribute

view_or_scroll_timeline: typing.Optional[ViewOrScrollTimeline] = None class-attribute instance-attribute

__init__(id_, name, paused_state, play_state, playback_rate, start_time, current_time, type_, source=None, css_id=None, view_or_scroll_timeline=None)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> Animation:  return cls(  id_=str(json["id"]),  name=str(json["name"]),  paused_state=bool(json["pausedState"]),  play_state=str(json["playState"]),  playback_rate=float(json["playbackRate"]),  start_time=float(json["startTime"]),  current_time=float(json["currentTime"]),  type_=str(json["type"]),  source=AnimationEffect.from_json(json["source"])  if json.get("source", None) is not None  else None,  css_id=str(json["cssId"]) if json.get("cssId", None) is not None else None,  view_or_scroll_timeline=ViewOrScrollTimeline.from_json(  json["viewOrScrollTimeline"]  )  if json.get("viewOrScrollTimeline", None) is not None  else None,  ) 

to_json()

Source code in zendriver/cdp/animation.py
def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["id"] = self.id_  json["name"] = self.name  json["pausedState"] = self.paused_state  json["playState"] = self.play_state  json["playbackRate"] = self.playback_rate  json["startTime"] = self.start_time  json["currentTime"] = self.current_time  json["type"] = self.type_  if self.source is not None:  json["source"] = self.source.to_json()  if self.css_id is not None:  json["cssId"] = self.css_id  if self.view_or_scroll_timeline is not None:  json["viewOrScrollTimeline"] = self.view_or_scroll_timeline.to_json()  return json 

AnimationCanceled dataclass

Event for when an animation has been cancelled.

Source code in zendriver/cdp/animation.py
@event_class("Animation.animationCanceled") @dataclass class AnimationCanceled:  """  Event for when an animation has been cancelled.  """   #: Id of the animation that was cancelled.  id_: str   @classmethod  def from_json(cls, json: T_JSON_DICT) -> AnimationCanceled:  return cls(id_=str(json["id"])) 

id_: str instance-attribute

__init__(id_)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> AnimationCanceled:  return cls(id_=str(json["id"])) 

AnimationCreated dataclass

Event for each animation that has been created.

Source code in zendriver/cdp/animation.py
@event_class("Animation.animationCreated") @dataclass class AnimationCreated:  """  Event for each animation that has been created.  """   #: Id of the animation that was created.  id_: str   @classmethod  def from_json(cls, json: T_JSON_DICT) -> AnimationCreated:  return cls(id_=str(json["id"])) 

id_: str instance-attribute

__init__(id_)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> AnimationCreated:  return cls(id_=str(json["id"])) 

AnimationEffect dataclass

AnimationEffect instance

Source code in zendriver/cdp/animation.py
@dataclass class AnimationEffect:  """  AnimationEffect instance  """   #: ``AnimationEffect``'s delay.  delay: float   #: ``AnimationEffect``'s end delay.  end_delay: float   #: ``AnimationEffect``'s iteration start.  iteration_start: float   #: ``AnimationEffect``'s iterations.  iterations: float   #: ``AnimationEffect``'s iteration duration.  #: Milliseconds for time based animations and  #: percentage [0 - 100] for scroll driven animations  #: (i.e. when viewOrScrollTimeline exists).  duration: float   #: ``AnimationEffect``'s playback direction.  direction: str   #: ``AnimationEffect``'s fill mode.  fill: str   #: ``AnimationEffect``'s timing function.  easing: str   #: ``AnimationEffect``'s target node.  backend_node_id: typing.Optional[dom.BackendNodeId] = None   #: ``AnimationEffect``'s keyframes.  keyframes_rule: typing.Optional[KeyframesRule] = None   def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["delay"] = self.delay  json["endDelay"] = self.end_delay  json["iterationStart"] = self.iteration_start  json["iterations"] = self.iterations  json["duration"] = self.duration  json["direction"] = self.direction  json["fill"] = self.fill  json["easing"] = self.easing  if self.backend_node_id is not None:  json["backendNodeId"] = self.backend_node_id.to_json()  if self.keyframes_rule is not None:  json["keyframesRule"] = self.keyframes_rule.to_json()  return json   @classmethod  def from_json(cls, json: T_JSON_DICT) -> AnimationEffect:  return cls(  delay=float(json["delay"]),  end_delay=float(json["endDelay"]),  iteration_start=float(json["iterationStart"]),  iterations=float(json["iterations"]),  duration=float(json["duration"]),  direction=str(json["direction"]),  fill=str(json["fill"]),  easing=str(json["easing"]),  backend_node_id=dom.BackendNodeId.from_json(json["backendNodeId"])  if json.get("backendNodeId", None) is not None  else None,  keyframes_rule=KeyframesRule.from_json(json["keyframesRule"])  if json.get("keyframesRule", None) is not None  else None,  ) 

backend_node_id: typing.Optional[dom.BackendNodeId] = None class-attribute instance-attribute

delay: float instance-attribute

direction: str instance-attribute

duration: float instance-attribute

easing: str instance-attribute

end_delay: float instance-attribute

fill: str instance-attribute

iteration_start: float instance-attribute

iterations: float instance-attribute

keyframes_rule: typing.Optional[KeyframesRule] = None class-attribute instance-attribute

__init__(delay, end_delay, iteration_start, iterations, duration, direction, fill, easing, backend_node_id=None, keyframes_rule=None)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> AnimationEffect:  return cls(  delay=float(json["delay"]),  end_delay=float(json["endDelay"]),  iteration_start=float(json["iterationStart"]),  iterations=float(json["iterations"]),  duration=float(json["duration"]),  direction=str(json["direction"]),  fill=str(json["fill"]),  easing=str(json["easing"]),  backend_node_id=dom.BackendNodeId.from_json(json["backendNodeId"])  if json.get("backendNodeId", None) is not None  else None,  keyframes_rule=KeyframesRule.from_json(json["keyframesRule"])  if json.get("keyframesRule", None) is not None  else None,  ) 

to_json()

Source code in zendriver/cdp/animation.py
def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["delay"] = self.delay  json["endDelay"] = self.end_delay  json["iterationStart"] = self.iteration_start  json["iterations"] = self.iterations  json["duration"] = self.duration  json["direction"] = self.direction  json["fill"] = self.fill  json["easing"] = self.easing  if self.backend_node_id is not None:  json["backendNodeId"] = self.backend_node_id.to_json()  if self.keyframes_rule is not None:  json["keyframesRule"] = self.keyframes_rule.to_json()  return json 

AnimationStarted dataclass

Event for animation that has been started.

Source code in zendriver/cdp/animation.py
@event_class("Animation.animationStarted") @dataclass class AnimationStarted:  """  Event for animation that has been started.  """   #: Animation that was started.  animation: Animation   @classmethod  def from_json(cls, json: T_JSON_DICT) -> AnimationStarted:  return cls(animation=Animation.from_json(json["animation"])) 

animation: Animation instance-attribute

__init__(animation)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> AnimationStarted:  return cls(animation=Animation.from_json(json["animation"])) 

AnimationUpdated dataclass

Event for animation that has been updated.

Source code in zendriver/cdp/animation.py
@event_class("Animation.animationUpdated") @dataclass class AnimationUpdated:  """  Event for animation that has been updated.  """   #: Animation that was updated.  animation: Animation   @classmethod  def from_json(cls, json: T_JSON_DICT) -> AnimationUpdated:  return cls(animation=Animation.from_json(json["animation"])) 

animation: Animation instance-attribute

__init__(animation)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> AnimationUpdated:  return cls(animation=Animation.from_json(json["animation"])) 

KeyframeStyle dataclass

Keyframe Style

Source code in zendriver/cdp/animation.py
@dataclass class KeyframeStyle:  """  Keyframe Style  """   #: Keyframe's time offset.  offset: str   #: ``AnimationEffect``'s timing function.  easing: str   def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["offset"] = self.offset  json["easing"] = self.easing  return json   @classmethod  def from_json(cls, json: T_JSON_DICT) -> KeyframeStyle:  return cls(  offset=str(json["offset"]),  easing=str(json["easing"]),  ) 

easing: str instance-attribute

offset: str instance-attribute

__init__(offset, easing)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> KeyframeStyle:  return cls(  offset=str(json["offset"]),  easing=str(json["easing"]),  ) 

to_json()

Source code in zendriver/cdp/animation.py
def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["offset"] = self.offset  json["easing"] = self.easing  return json 

KeyframesRule dataclass

Keyframes Rule

Source code in zendriver/cdp/animation.py
@dataclass class KeyframesRule:  """  Keyframes Rule  """   #: List of animation keyframes.  keyframes: typing.List[KeyframeStyle]   #: CSS keyframed animation's name.  name: typing.Optional[str] = None   def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["keyframes"] = [i.to_json() for i in self.keyframes]  if self.name is not None:  json["name"] = self.name  return json   @classmethod  def from_json(cls, json: T_JSON_DICT) -> KeyframesRule:  return cls(  keyframes=[KeyframeStyle.from_json(i) for i in json["keyframes"]],  name=str(json["name"]) if json.get("name", None) is not None else None,  ) 

keyframes: typing.List[KeyframeStyle] instance-attribute

name: typing.Optional[str] = None class-attribute instance-attribute

__init__(keyframes, name=None)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> KeyframesRule:  return cls(  keyframes=[KeyframeStyle.from_json(i) for i in json["keyframes"]],  name=str(json["name"]) if json.get("name", None) is not None else None,  ) 

to_json()

Source code in zendriver/cdp/animation.py
def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["keyframes"] = [i.to_json() for i in self.keyframes]  if self.name is not None:  json["name"] = self.name  return json 

ViewOrScrollTimeline dataclass

Timeline instance

Source code in zendriver/cdp/animation.py
@dataclass class ViewOrScrollTimeline:  """  Timeline instance  """   #: Orientation of the scroll  axis: dom.ScrollOrientation   #: Scroll container node  source_node_id: typing.Optional[dom.BackendNodeId] = None   #: Represents the starting scroll position of the timeline  #: as a length offset in pixels from scroll origin.  start_offset: typing.Optional[float] = None   #: Represents the ending scroll position of the timeline  #: as a length offset in pixels from scroll origin.  end_offset: typing.Optional[float] = None   #: The element whose principal box's visibility in the  #: scrollport defined the progress of the timeline.  #: Does not exist for animations with ScrollTimeline  subject_node_id: typing.Optional[dom.BackendNodeId] = None   def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["axis"] = self.axis.to_json()  if self.source_node_id is not None:  json["sourceNodeId"] = self.source_node_id.to_json()  if self.start_offset is not None:  json["startOffset"] = self.start_offset  if self.end_offset is not None:  json["endOffset"] = self.end_offset  if self.subject_node_id is not None:  json["subjectNodeId"] = self.subject_node_id.to_json()  return json   @classmethod  def from_json(cls, json: T_JSON_DICT) -> ViewOrScrollTimeline:  return cls(  axis=dom.ScrollOrientation.from_json(json["axis"]),  source_node_id=dom.BackendNodeId.from_json(json["sourceNodeId"])  if json.get("sourceNodeId", None) is not None  else None,  start_offset=float(json["startOffset"])  if json.get("startOffset", None) is not None  else None,  end_offset=float(json["endOffset"])  if json.get("endOffset", None) is not None  else None,  subject_node_id=dom.BackendNodeId.from_json(json["subjectNodeId"])  if json.get("subjectNodeId", None) is not None  else None,  ) 

axis: dom.ScrollOrientation instance-attribute

end_offset: typing.Optional[float] = None class-attribute instance-attribute

source_node_id: typing.Optional[dom.BackendNodeId] = None class-attribute instance-attribute

start_offset: typing.Optional[float] = None class-attribute instance-attribute

subject_node_id: typing.Optional[dom.BackendNodeId] = None class-attribute instance-attribute

__init__(axis, source_node_id=None, start_offset=None, end_offset=None, subject_node_id=None)

from_json(json) classmethod

Source code in zendriver/cdp/animation.py
@classmethod def from_json(cls, json: T_JSON_DICT) -> ViewOrScrollTimeline:  return cls(  axis=dom.ScrollOrientation.from_json(json["axis"]),  source_node_id=dom.BackendNodeId.from_json(json["sourceNodeId"])  if json.get("sourceNodeId", None) is not None  else None,  start_offset=float(json["startOffset"])  if json.get("startOffset", None) is not None  else None,  end_offset=float(json["endOffset"])  if json.get("endOffset", None) is not None  else None,  subject_node_id=dom.BackendNodeId.from_json(json["subjectNodeId"])  if json.get("subjectNodeId", None) is not None  else None,  ) 

to_json()

Source code in zendriver/cdp/animation.py
def to_json(self) -> T_JSON_DICT:  json: T_JSON_DICT = dict()  json["axis"] = self.axis.to_json()  if self.source_node_id is not None:  json["sourceNodeId"] = self.source_node_id.to_json()  if self.start_offset is not None:  json["startOffset"] = self.start_offset  if self.end_offset is not None:  json["endOffset"] = self.end_offset  if self.subject_node_id is not None:  json["subjectNodeId"] = self.subject_node_id.to_json()  return json 

disable()

Disables animation domain notifications.

Source code in zendriver/cdp/animation.py
def disable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Disables animation domain notifications.  """  cmd_dict: T_JSON_DICT = {  "method": "Animation.disable",  }  json = yield cmd_dict 

enable()

Enables animation domain notifications.

Source code in zendriver/cdp/animation.py
def enable() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Enables animation domain notifications.  """  cmd_dict: T_JSON_DICT = {  "method": "Animation.enable",  }  json = yield cmd_dict 

get_current_time(id_)

Returns the current time of the an animation.

Parameters:

Name Type Description Default
id_ str

Id of animation.

required

Returns:

Type Description
Generator[T_JSON_DICT, T_JSON_DICT, float]

Current time of the page.

Source code in zendriver/cdp/animation.py
def get_current_time(id_: str) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, float]:  """  Returns the current time of the an animation.   :param id_: Id of animation.  :returns: Current time of the page.  """  params: T_JSON_DICT = dict()  params["id"] = id_  cmd_dict: T_JSON_DICT = {  "method": "Animation.getCurrentTime",  "params": params,  }  json = yield cmd_dict  return float(json["currentTime"]) 

get_playback_rate()

Gets the playback rate of the document timeline.

Returns:

Type Description
Generator[T_JSON_DICT, T_JSON_DICT, float]

Playback rate for animations on page.

Source code in zendriver/cdp/animation.py
def get_playback_rate() -> typing.Generator[T_JSON_DICT, T_JSON_DICT, float]:  """  Gets the playback rate of the document timeline.   :returns: Playback rate for animations on page.  """  cmd_dict: T_JSON_DICT = {  "method": "Animation.getPlaybackRate",  }  json = yield cmd_dict  return float(json["playbackRate"]) 

release_animations(animations)

Releases a set of animations to no longer be manipulated.

Parameters:

Name Type Description Default
animations List[str]

List of animation ids to seek.

required
Source code in zendriver/cdp/animation.py
def release_animations(  animations: typing.List[str], ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Releases a set of animations to no longer be manipulated.   :param animations: List of animation ids to seek.  """  params: T_JSON_DICT = dict()  params["animations"] = [i for i in animations]  cmd_dict: T_JSON_DICT = {  "method": "Animation.releaseAnimations",  "params": params,  }  json = yield cmd_dict 

resolve_animation(animation_id)

Gets the remote object of the Animation.

Parameters:

Name Type Description Default
animation_id str

Animation id.

required

Returns:

Type Description
Generator[T_JSON_DICT, T_JSON_DICT, RemoteObject]

Corresponding remote object.

Source code in zendriver/cdp/animation.py
def resolve_animation(  animation_id: str, ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, runtime.RemoteObject]:  """  Gets the remote object of the Animation.   :param animation_id: Animation id.  :returns: Corresponding remote object.  """  params: T_JSON_DICT = dict()  params["animationId"] = animation_id  cmd_dict: T_JSON_DICT = {  "method": "Animation.resolveAnimation",  "params": params,  }  json = yield cmd_dict  return runtime.RemoteObject.from_json(json["remoteObject"]) 

seek_animations(animations, current_time)

Seek a set of animations to a particular time within each animation.

Parameters:

Name Type Description Default
animations List[str]

List of animation ids to seek.

required
current_time float

Set the current time of each animation.

required
Source code in zendriver/cdp/animation.py
def seek_animations(  animations: typing.List[str], current_time: float ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Seek a set of animations to a particular time within each animation.   :param animations: List of animation ids to seek.  :param current_time: Set the current time of each animation.  """  params: T_JSON_DICT = dict()  params["animations"] = [i for i in animations]  params["currentTime"] = current_time  cmd_dict: T_JSON_DICT = {  "method": "Animation.seekAnimations",  "params": params,  }  json = yield cmd_dict 

set_paused(animations, paused)

Sets the paused state of a set of animations.

Parameters:

Name Type Description Default
animations List[str]

Animations to set the pause state of.

required
paused bool

Paused state to set to.

required
Source code in zendriver/cdp/animation.py
def set_paused(  animations: typing.List[str], paused: bool ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Sets the paused state of a set of animations.   :param animations: Animations to set the pause state of.  :param paused: Paused state to set to.  """  params: T_JSON_DICT = dict()  params["animations"] = [i for i in animations]  params["paused"] = paused  cmd_dict: T_JSON_DICT = {  "method": "Animation.setPaused",  "params": params,  }  json = yield cmd_dict 

set_playback_rate(playback_rate)

Sets the playback rate of the document timeline.

Parameters:

Name Type Description Default
playback_rate float

Playback rate for animations on page

required
Source code in zendriver/cdp/animation.py
def set_playback_rate(  playback_rate: float, ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Sets the playback rate of the document timeline.   :param playback_rate: Playback rate for animations on page  """  params: T_JSON_DICT = dict()  params["playbackRate"] = playback_rate  cmd_dict: T_JSON_DICT = {  "method": "Animation.setPlaybackRate",  "params": params,  }  json = yield cmd_dict 

set_timing(animation_id, duration, delay)

Sets the timing of an animation node.

Parameters:

Name Type Description Default
animation_id str

Animation id.

required
duration float

Duration of the animation.

required
delay float

Delay of the animation.

required
Source code in zendriver/cdp/animation.py
def set_timing(  animation_id: str, duration: float, delay: float ) -> typing.Generator[T_JSON_DICT, T_JSON_DICT, None]:  """  Sets the timing of an animation node.   :param animation_id: Animation id.  :param duration: Duration of the animation.  :param delay: Delay of the animation.  """  params: T_JSON_DICT = dict()  params["animationId"] = animation_id  params["duration"] = duration  params["delay"] = delay  cmd_dict: T_JSON_DICT = {  "method": "Animation.setTiming",  "params": params,  }  json = yield cmd_dict