blob: 29e267b854c43cec1a82812d70cf44312f67c8bc (
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
97
98
99
100
101
102
103
104
105
106
107
108
109
|
---
title: Animation.id
slug: Web/API/Animation/id
tags:
- 动画
translation_of: Web/API/Animation/id
---
<p>{{ SeeCompatTable() }}{{ APIRef("Web Animations API") }}</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> 的 <code><strong>Animation</strong></code><strong><code>.id </code></strong>属性可返回或设置用于识别某个动画的唯一标识.</p>
<h2 id="获取与设置_animation.id">获取与设置 <code>animation.<em>id</em></code></h2>
<div class="syntaxbox">
<pre class="brush: js">// 获取动画的 id
var animationsId = animation.<em>id</em>;
// 设置动画的 id
animation.<em>id</em> = "newId";
</pre>
</div>
<h2 id="返回值">返回值</h2>
<p>当该动画已被分配 id, 返回一个 {{domxref("DOMString")}}, 当该动画未被分配 id 则返回 null.</p>
<h2 id="示例">示例</h2>
<p>在 <a href="http://codepen.io/rachelnabors/pen/eJyWzm?editors=0010">Follow the White Rabbit example</a> 这个例子里, 你可以像下面的方式一样,为 <code>rabbitDownAnimation</code> 分配一个 id:</p>
<pre class="brush: js">rabbitDownAnimation.effect.<em>id</em> = "rabbitGo";
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">说明</th>
</tr>
<tr>
<td>{{SpecName('Web Animations', '#dom-animation-id', 'Animation.id' )}}</td>
<td>{{Spec2('Web Animations')}}</td>
<td>Editor's draft.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器支持">浏览器支持</h2>
<div>{{CompatibilityTable}}</div>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Chrome</th>
<th>Firefox (Gecko)</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari (WebKit)</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatChrome(39.0)}}</td>
<td>{{CompatGeckoDesktop(48)}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Android</th>
<th>Firefox Mobile (Gecko)</th>
<th>IE Phone</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatVersionUnknown}}</td>
<td>{{CompatGeckoDesktop(48)}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
<td>{{CompatNo}}</td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<h2 id="相关文档" style="line-height: 30px; font-size: 2.14285714285714rem;">相关文档</h2>
<ul>
<li><a href="/en-US/docs/Web/API/KeyframeEffect">KeyframeEffect Interface</a></li>
<li><a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a></li>
<li>{{domxref("Animation")}}</li>
</ul>
|