Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Animation

This CDP domain is experimental.

- Types

- Commands

- Events

## Types

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

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

  Animation instance.

  id_: `str`

    `Animation`’s id.

  name: `str`

    `Animation`’s name.

  paused_state: `bool`

    `Animation`’s internal paused state.

  play_state: `str`

    `Animation`’s play state.

  playback_rate: `float`

    `Animation`’s playback rate.

  start_time: `float`

    `Animation`’s start time. Milliseconds for time based animations and percentage [0 - 100] for scroll driven animations (i.e. when viewOrScrollTimeline exists).

  current_time: `float`

    `Animation`’s current time.

  type_: `str`

    Animation type of `Animation`.

  source: `Optional`[`AnimationEffect`] = None

    `Animation`’s source animation node.

  css_id: `Optional`[`str`] = None

    A unique ID for `Animation` representing the sources that triggered this CSS animation/transition.

  view_or_scroll_timeline: `Optional`[`ViewOrScrollTimeline`] = None

    View or scroll timeline

class ViewOrScrollTimeline(axis, source_node_id=None, start_offset=None, end_offset=None, subject_node_id=None)

  Timeline instance

  axis: `ScrollOrientation`

    Orientation of the scroll

  source_node_id: `Optional`[`BackendNodeId`] = None

    Scroll container node

  start_offset: `Optional`[`float`] = None

    Represents the starting scroll position of the timeline as a length offset in pixels from scroll origin.

  end_offset: `Optional`[`float`] = None

    Represents the ending scroll position of the timeline as a length offset in pixels from scroll origin.

  subject_node_id: `Optional`[`BackendNodeId`] = None

    The element whose principal box’s visibility in the scrollport defined the progress of the timeline. Does not exist for animations with ScrollTimeline

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

  AnimationEffect instance

  delay: `float`

    `AnimationEffect`’s delay.

  end_delay: `float`

    `AnimationEffect`’s end delay.

  iteration_start: `float`

    `AnimationEffect`’s iteration start.

  iterations: `float`

    `AnimationEffect`’s iterations.

  duration: `float`

    `AnimationEffect`’s iteration duration. Milliseconds for time based animations and percentage [0 - 100] for scroll driven animations (i.e. when viewOrScrollTimeline exists).

  direction: `str`

    `AnimationEffect`’s playback direction.

  fill: `str`

    `AnimationEffect`’s fill mode.

  easing: `str`

    `AnimationEffect`’s timing function.

  backend_node_id: `Optional`[`BackendNodeId`] = None

    `AnimationEffect`’s target node.

  keyframes_rule: `Optional`[`KeyframesRule`] = None

    `AnimationEffect`’s keyframes.

class KeyframesRule(keyframes, name=None)

  Keyframes Rule

  keyframes: `List`[`KeyframeStyle`]

    List of animation keyframes.

  name: `Optional`[`str`] = None

    CSS keyframed animation’s name.

class KeyframeStyle(offset, easing)

  Keyframe Style

  offset: `str`

    Keyframe’s time offset.

  easing: `str`

    `AnimationEffect`’s timing function.

## Commands

Each command is a generator function. The return type `Generator[x, y, z]` indicates that the generator yields arguments of type `x`, it must be resumed with an argument of type `y`, and it returns type `z`. In this library, types `x` and `y` are the same for all commands, and `z` is the return type you should pay attention to. For more information, see Getting Started: Commands.

disable()

  Disables animation domain notifications.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

enable()

  Enables animation domain notifications.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

get_current_time(id_)

  Returns the current time of the an animation.

  Parameters:

    id – Id of animation.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `float`]

  Returns:

    Current time of the page.

get_playback_rate()

  Gets the playback rate of the document timeline.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `float`]

  Returns:

    Playback rate for animations on page.

release_animations(animations)

  Releases a set of animations to no longer be manipulated.

  Parameters:

    animations (`List`[`str`]) – List of animation ids to seek.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

resolve_animation(animation_id)

  Gets the remote object of the Animation.

  Parameters:

    animation_id (`str`) – Animation id.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `RemoteObject`]

  Returns:

    Corresponding remote object.

seek_animations(animations, current_time)

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

  Parameters:

    - animations (`List`[`str`]) – List of animation ids to seek.

    - current_time (`float`) – Set the current time of each animation.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

set_paused(animations, paused)

  Sets the paused state of a set of animations.

  Parameters:

    - animations (`List`[`str`]) – Animations to set the pause state of.

    - paused (`bool`) – Paused state to set to.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

set_playback_rate(playback_rate)

  Sets the playback rate of the document timeline.

  Parameters:

    playback_rate (`float`) – Playback rate for animations on page

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

set_timing(animation_id, duration, delay)

  Sets the timing of an animation node.

  Parameters:

    - animation_id (`str`) – Animation id.

    - duration (`float`) – Duration of the animation.

    - delay (`float`) – Delay of the animation.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

## Events

Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.

class AnimationCanceled(id_)

  Event for when an animation has been cancelled.

  id_: `str`

    Id of the animation that was cancelled.

class AnimationCreated(id_)

  Event for each animation that has been created.

  id_: `str`

    Id of the animation that was created.

class AnimationStarted(animation)

  Event for animation that has been started.

  animation: `Animation`

    Animation that was started.

class AnimationUpdated(animation)

  Event for animation that has been updated.

  animation: `Animation`

    Animation that was updated.