diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/animation/currenttime/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/animation/currenttime/index.html')
-rw-r--r-- | files/zh-cn/web/api/animation/currenttime/index.html | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/animation/currenttime/index.html b/files/zh-cn/web/api/animation/currenttime/index.html new file mode 100644 index 0000000000..25c3ca441d --- /dev/null +++ b/files/zh-cn/web/api/animation/currenttime/index.html @@ -0,0 +1,114 @@ +--- +title: Animation.currentTime +slug: Web/API/Animation/currentTime +tags: + - 动画 +translation_of: Web/API/Animation/currentTime +--- +<p>{{APIRef("Web Animations API")}}{{SeeCompatTable}}</p> + +<p>Animation.currentTime属性返回或设置动画的当前时间值(以毫秒为单位),无论动画正在运行还是已暂停。</p> + +<p>如果动画缺少{{domxref("AnimationTimeline", "timeline")}},处于非活动状态或尚未播放,则当前时间返回值为null。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox">var <em>currentTime</em> = element.currentTime; +element.currentTime =<em> someValue;</em></pre> + +<h3 id="值">值</h3> + +<p>表示当前时间的数字(以毫秒为单位),或为null。</p> + +<h2 id="例子">例子</h2> + +<p>在<a href="http://codepen.io/rachelnabors/pen/PNYGZQ?editors=0010">Drink Me/Eat Me game</a>中,爱丽丝的高度是可变动的,所以它可以从小到大或从大到小。 在游戏开始时,通过将她的动画的currentTime设置为她的keyframeEffect的持续时间的一半让她的高度设置在两个极端之间:</p> + +<pre class="brush: js">aliceChange<strong>.currentTime</strong> = aliceChange.effect.timing.duration / 2;</pre> + +<p>寻求动画的50%标记的更通用的方法:</p> + +<pre class="brush: js">animation.currentTime = + animation.effect.getComputedTiming().delay + + animation.effect.getComputedTiming().activeDuration / 2;</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-currenttime', 'currentTime')}}</td> + <td>{{Spec2("Web Animations")}}</td> + <td> </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>Android Webview</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Phone</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome for Android</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(39.0)}}</td> + <td>{{CompatGeckoMobile(48)}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(39.0)}}</td> + </tr> + </tbody> +</table> +</div> + +<p> </p> + +<h2 id="相关内容" style="line-height: 30px; font-size: 2.14285714285714rem;">相关内容</h2> + +<ul> + <li>{{domxref("Animation")}} for other methods and properties you can use to control web page animation.</li> + <li>{{domxref("Animation.startTime")}} for the time an animation is scheduled to start.</li> + <li><a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a></li> +</ul> |