Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: instance methods SVGAnimationElement #37180

Merged
merged 9 commits into from
Jan 23, 2025
43 changes: 43 additions & 0 deletions files/en-us/web/api/svganimationelement/getcurrenttime/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: "SVGAnimationElement: getCurrentTime() method"
short-title: getCurrentTime()
slug: Web/API/SVGAnimationElement/getCurrentTime
page-type: web-api-instance-method
browser-compat: api.SVGAnimationElement.getCurrentTime
---

{{APIRef("SVG")}}

The {{domxref("SVGAnimationElement")}} method `getCurrentTime()` returns a float representing the current time in seconds relative to time zero for the given time container.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

```js-nolint
getCurrentTime()
```

### Parameters

None.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

### Return value

A float.

## Examples

This example demonstrates how to use `getCurrentTime()` to retrieve the current time of an animation element:

```js
const animationElement = document.querySelector("animate");
const currentTime = animationElement.getCurrentTime();
console.log(`The current time is: ${currentTime} seconds`);
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "SVGAnimationElement: getSimpleDuration() method"
short-title: getSimpleDuration()
slug: Web/API/SVGAnimationElement/getSimpleDuration
page-type: web-api-instance-method
browser-compat: api.SVGAnimationElement.getSimpleDuration
---

{{APIRef("SVG")}}

The {{domxref("SVGAnimationElement")}} method `getSimpleDuration()` returns a float representing the number of seconds for the simple duration for this animation.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

```js-nolint
getSimpleDuration()
```

### Parameters

None.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

### Return value

A float.

### Exceptions

- `NotSupportedError` {{domxref("DOMException")}}
- : Thrown if the `SVGAnimationElement`'s simple duration is undefined (e.g., the end time is indefinite).
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

## Examples

This example demonstrates how to use `getSimpleDuration()` to retrieve the simple duration of an animation element:

```js
const animationElement = document.querySelector("animate");
const duration = animationElement.getSimpleDuration();
console.log(`The simple duration is: ${duration} seconds`);
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
48 changes: 48 additions & 0 deletions files/en-us/web/api/svganimationelement/getstarttime/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "SVGAnimationElement: getStartTime() method"
short-title: getStartTime()
slug: Web/API/SVGAnimationElement/getStartTime
page-type: web-api-instance-method
browser-compat: api.SVGAnimationElement.getStartTime
---

{{APIRef("SVG")}}

The {{domxref("SVGAnimationElement")}} method `getStartTime()` returns a float representing the begin time, in seconds, for this animation element's current interval, if it exists, regardless of whether the interval has begun yet.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

## Syntax

```js-nolint
getStartTime()
```

### Parameters

None.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

### Return value

A float.

### Exceptions

- `InvalidStateError` {{domxref("DOMException")}}
- : Thrown if the `SVGAnimationElement` has no current interval.
yashrajbharti marked this conversation as resolved.
Show resolved Hide resolved

## Examples

This example demonstrates how to use `getStartTime()` to retrieve the start time of an animation element:

```js
const animationElement = document.querySelector("animate");
const startTime = animationElement.getStartTime();
console.log(`The animation starts at: ${startTime} seconds`);
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
Loading