aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/svganimationelement/index.html
blob: 6444e9167d12309ee48204cdd3d750b9f7a272e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
---
title: SVGAnimationElement
slug: Web/API/SVGAnimationElement
tags:
  - API
  - NeedsExample
  - NeedsTranslation
  - Reference
  - SVG
  - SVG DOM
  - TopicStub
translation_of: Web/API/SVGAnimationElement
---
<div>{{APIRef("SVG")}}</div>

<p>The <strong><code>SVGAnimationElement</code></strong> interface is the base interface for all of the animation element interfaces: {{domxref("SVGAnimateElement")}}, {{domxref("SVGSetElement")}}, {{domxref("SVGAnimateColorElement")}}, {{domxref("SVGAnimateMotionElement")}} and {{domxref("SVGAnimateTransformElement")}}.</p>

<p>{{InheritanceDiagram(600, 140)}}</p>

<h2 id="Properties">Properties</h2>

<p><em>This interface also inherits properties from its parent, {{domxref("SVGElement")}}.</em></p>

<dl>
 <dt>{{domxref("SVGAnimationElement.targetElement")}} {{ReadOnlyInline}}</dt>
 <dd>An {{domxref("SVGElement")}} representing the element which is being animated. If no target element is being animated (for example, because the {{SVGAttr("href")}} specifies an unknown element) the value returned is <code>null</code>.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em>This interface also inherits methods from its parent, {{domxref("SVGElement")}}.</em></p>

<dl>
 <dt>{{domxref("SVGAnimationElement.getStartTime()")}}</dt>
 <dd>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. If there is no current interval, then a {{domxref("DOMException")}} with code <code>INVALID_STATE_ERR</code> is thrown.</dd>
 <dt>{{domxref("SVGAnimationElement.getCurrentTime()")}}</dt>
 <dd>Returns a float representing the current time in seconds relative to time zero for the given time container.</dd>
 <dt>{{domxref("SVGAnimationElement.getSimpleDuration()")}}</dt>
 <dd>Returns a float representing the number of seconds for the simple duration for this animation. If the simple duration is undefined (e.g., the end time is indefinite), then a {{domxref("DOMException")}} with code <code>NOT_SUPPORTED_ERR</code> is raised.</dd>
 <dt>{{domxref("SVGAnimationElement.beginElement()")}} {{experimental_inline}}</dt>
 <dd>Creates a begin instance time for the current time. The new instance time is added to the begin instance times list. The behavior of this method is equivalent to <code>beginElementAt(0)</code>.</dd>
 <dt>{{domxref("SVGAnimationElement.beginElementAt()")}} {{experimental_inline}}</dt>
 <dd>
 <p>Creates a begin instance time for the current time plus the specified offset. The new instance time is added to the begin instance times list.</p>
 </dd>
 <dt>{{domxref("SVGAnimationElement.endElement()")}} {{experimental_inline}}</dt>
 <dd>
 <p>Creates an end instance time for the current time. The new instance time is added to the end instance times list. The behavior of this method is equivalent to <code>endElementAt(0)</code>.</p>
 </dd>
 <dt>{{domxref("SVGAnimationElement.endElementAt()")}} {{experimental_inline}}</dt>
 <dd>Creates a end instance time for the current time plus the specified offset. The new instance time is added to the end instance times list.</dd>
</dl>

<h2 id="Events">Events</h2>

<p>Listen to these events using <code><a href="/en-US/docs/Web/API/EventTarget/addEventListener">addEventListener()</a></code> or by assigning an event listener to the <code>on...</code> handler property of this interface.</p>

<dl>
 <dt><code><a href="/en-US/docs/Web/API/SVGAnimationElement/beginEvent_event">beginEvent</a></code></dt>
 <dd>Fired when the element local timeline begins to play.<br>
 Also available via the <code><a href="/en-US/docs/Web/API/SVGAnimationElement/onbegin">onbegin</a></code> property.</dd>
 <dt><code><a href="/en-US/docs/Web/API/SVGAnimationElement/endEvent_event">endEvent</a></code></dt>
 <dd>Fired when at the active end of the animation is reached.<br>
 Also available via the <code><a href="/en-US/docs/Web/API/SVGAnimationElement/onend">onend</a></code> property.</dd>
 <dt><code><a href="/en-US/docs/Web/API/SVGAnimationElement/repeatEvent_event">repeatEvent</a></code></dt>
 <dd>Fired when the element's local timeline repeats. It will be fired each time the element repeats, after the first iteration.<br>
 Also available via the <code><a href="/en-US/docs/Web/API/SVGAnimationElement/onrepeat">onrepeat</a></code> property.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <td>Specification</td>
   <td>Status</td>
   <td>Comment</td>
  </tr>
  <tr>
   <td>{{SpecName("SVG Animations 2", "#InterfaceSVGAnimationElement", "SVGAnimationElement")}}</td>
   <td>{{Spec2("SVG Animations 2")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName("SVG1.1", "animate.html#InterfaceSVGAnimationElement", "SVGAnimationElement")}}</td>
   <td>{{Spec2("SVG1.1")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("api.SVGAnimationElement")}}</p>