All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.chrome.devtools.client.core.animation.Animation Maven / Gradle / Ivy

package com.hubspot.chrome.devtools.client.core.animation;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hubspot.chrome.devtools.base.ChromeRequest;
import com.hubspot.chrome.devtools.base.ChromeSessionCore;
import com.hubspot.chrome.devtools.client.core.runtime.RemoteObject;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public final class Animation {
  ChromeSessionCore chromeSession;

  ObjectMapper objectMapper;

  public Animation(ChromeSessionCore chromeSession, ObjectMapper objectMapper) {
    this.chromeSession = chromeSession;
    this.objectMapper = objectMapper;
  }

  /**
   * Disables animation domain notifications.
   */
  public void disable() {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.disable");
    chromeSession.send(chromeRequest);
  }

  /**
   * Disables animation domain notifications.
   */
  public void disableAsync() {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.disable");
    chromeSession.sendAsync(chromeRequest);
  }

  /**
   * Enables animation domain notifications.
   */
  public void enable() {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.enable");
    chromeSession.send(chromeRequest);
  }

  /**
   * Enables animation domain notifications.
   */
  public void enableAsync() {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.enable");
    chromeSession.sendAsync(chromeRequest);
  }

  /**
   * Returns the current time of the an animation.
   *
   * @param id  Id of animation.
   */
  public Number getCurrentTime(String id) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.getCurrentTime");
    chromeRequest
        .putParams("id", id);
    return chromeSession.send(chromeRequest, new TypeReference(){});
  }

  /**
   * Returns the current time of the an animation.
   *
   * @param id  Id of animation.
   */
  public CompletableFuture getCurrentTimeAsync(String id) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.getCurrentTime");
    chromeRequest
        .putParams("id", id);
    return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
  }

  /**
   * Gets the playback rate of the document timeline.
   */
  public Number getPlaybackRate() {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.getPlaybackRate");
    return chromeSession.send(chromeRequest, new TypeReference(){});
  }

  /**
   * Gets the playback rate of the document timeline.
   */
  public CompletableFuture getPlaybackRateAsync() {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.getPlaybackRate");
    return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
  }

  /**
   * Releases a set of animations to no longer be manipulated.
   *
   * @param animations  List of animation ids to seek.
   */
  public void releaseAnimations(List animations) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.releaseAnimations");
    chromeRequest
        .putParams("animations", animations);
    chromeSession.send(chromeRequest);
  }

  /**
   * Releases a set of animations to no longer be manipulated.
   *
   * @param animations  List of animation ids to seek.
   */
  public void releaseAnimationsAsync(List animations) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.releaseAnimations");
    chromeRequest
        .putParams("animations", animations);
    chromeSession.sendAsync(chromeRequest);
  }

  /**
   * Gets the remote object of the Animation.
   *
   * @param animationId  Animation id.
   */
  public RemoteObject resolveAnimation(String animationId) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.resolveAnimation");
    chromeRequest
        .putParams("animationId", animationId);
    return chromeSession.send(chromeRequest, new TypeReference(){});
  }

  /**
   * Gets the remote object of the Animation.
   *
   * @param animationId  Animation id.
   */
  public CompletableFuture resolveAnimationAsync(String animationId) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.resolveAnimation");
    chromeRequest
        .putParams("animationId", animationId);
    return chromeSession.sendAsync(chromeRequest, new TypeReference(){});
  }

  /**
   * Seek a set of animations to a particular time within each animation.
   *
   * @param animations  List of animation ids to seek.
   * @param currentTime  Set the current time of each animation.
   */
  public void seekAnimations(List animations, Number currentTime) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.seekAnimations");
    chromeRequest
        .putParams("animations", animations)
        .putParams("currentTime", currentTime);
    chromeSession.send(chromeRequest);
  }

  /**
   * Seek a set of animations to a particular time within each animation.
   *
   * @param animations  List of animation ids to seek.
   * @param currentTime  Set the current time of each animation.
   */
  public void seekAnimationsAsync(List animations, Number currentTime) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.seekAnimations");
    chromeRequest
        .putParams("animations", animations)
        .putParams("currentTime", currentTime);
    chromeSession.sendAsync(chromeRequest);
  }

  /**
   * 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.
   */
  public void setPaused(List animations, Boolean paused) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.setPaused");
    chromeRequest
        .putParams("animations", animations)
        .putParams("paused", paused);
    chromeSession.send(chromeRequest);
  }

  /**
   * 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.
   */
  public void setPausedAsync(List animations, Boolean paused) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.setPaused");
    chromeRequest
        .putParams("animations", animations)
        .putParams("paused", paused);
    chromeSession.sendAsync(chromeRequest);
  }

  /**
   * Sets the playback rate of the document timeline.
   *
   * @param playbackRate  Playback rate for animations on page
   */
  public void setPlaybackRate(Number playbackRate) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.setPlaybackRate");
    chromeRequest
        .putParams("playbackRate", playbackRate);
    chromeSession.send(chromeRequest);
  }

  /**
   * Sets the playback rate of the document timeline.
   *
   * @param playbackRate  Playback rate for animations on page
   */
  public void setPlaybackRateAsync(Number playbackRate) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.setPlaybackRate");
    chromeRequest
        .putParams("playbackRate", playbackRate);
    chromeSession.sendAsync(chromeRequest);
  }

  /**
   * Sets the timing of an animation node.
   *
   * @param animationId  Animation id.
   * @param duration  Duration of the animation.
   * @param delay  Delay of the animation.
   */
  public void setTiming(String animationId, Number duration, Number delay) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.setTiming");
    chromeRequest
        .putParams("animationId", animationId)
        .putParams("duration", duration)
        .putParams("delay", delay);
    chromeSession.send(chromeRequest);
  }

  /**
   * Sets the timing of an animation node.
   *
   * @param animationId  Animation id.
   * @param duration  Duration of the animation.
   * @param delay  Delay of the animation.
   */
  public void setTimingAsync(String animationId, Number duration, Number delay) {
    ChromeRequest chromeRequest = new ChromeRequest("Animation.setTiming");
    chromeRequest
        .putParams("animationId", animationId)
        .putParams("duration", duration)
        .putParams("delay", delay);
    chromeSession.sendAsync(chromeRequest);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy