A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/API/SVGAnimationElement/getCurrentTime below:

SVGAnimationElement: getCurrentTime() method - Web APIs

SVGAnimationElement: getCurrentTime() method

Baseline Widely available

The SVGAnimationElement method getCurrentTime() returns a float representing the current time in seconds relative to time zero for the given time container.

Time zero refers to the moment when the time container begins its timeline. It acts as the starting reference point for all animations within that container.

A time container is an element or context that defines a local timeline for one or more animations. Animations inside the time container are measured relative to its timeline. If a time container is delayed, paused, or manipulated, all animations within it adjust accordingly.

Syntax Parameters

None (undefined).

Return value

A float.

Examples

This example demonstrates how the getCurrentTime() method retrieves the time elapsed since the time container's time zero.

<svg width="200" height="200" viewBox="0 0 200 200">
  <circle cx="50" cy="50" r="20" fill="rebeccapurple">
    <animate
      attributeName="cx"
      from="50"
      to="150"
      dur="4s"
      repeatCount="indefinite" />
  </circle>
</svg>
const animationElement = document.querySelector("animate");

setInterval(() => {
  const currentTime = animationElement.getCurrentTime();
  console.log(
    `Current time relative to the time container: ${currentTime} seconds`,
  );
}, 1000);

The animation starts at time zero = 0 and runs indefinitely, and the getCurrentTime() value increments continuously within the context of the time container.

Specifications Browser compatibility

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4