blob: 9bb90e7e035629b34c888ae4282008af896390e0 (
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
|
---
title: Animation.currentTime
slug: Web/API/Animation/currentTime
tags:
- Animacion
translation_of: Web/API/Animation/currentTime
original_slug: Web/API/Animation/tiempoActual
---
<p>{{APIRef("Web Animations")}}{{SeeCompatTable}}</p>
<p>La propiedad <code><strong>Animation</strong></code><strong><code>.currentTime</code></strong> de la <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a> devuelve y establece el valor del tiempo de la animación en milisegundos, tanto si se está ejecutando como en pausa.</p>
<p>Si la animación carece de un {{domxref("AnimationTimeline", "timeline")}}, está inactiva, o no ha sido reproducida todavía, el valor devuelto por <code>currentTime</code> es <code>null</code>.</p>
<h2 id="Sintaxis">Sintaxis</h2>
<pre class="syntaxbox">var <em>currentTime</em> = <em>Animation</em>.currentTime;
<em>Animation</em>.currentTime =<em> newTime;</em></pre>
<h3 id="Valor">Valor</h3>
<p>Un número que representa el tiempo actual en milisegundos, o <code>null</code> para desactivar la animación.</p>
<h2 id="Ejemplos">Ejemplos</h2>
<p>En el juego <a href="http://codepen.io/rachelnabors/pen/PNYGZQ?editors=0010">Drink Me/Eat Me </a>, la altura de Alicia está animada, por lo que puede cambiar de pequeña a grande y de grande a pequeña. Al inicio del juego, su altura de fija estableciendo el <code>currentTime</code> (tiempoActual) a la mitad de la duración total del<a href="/en-US/docs/Web/API/Web_Animations_API/Animation_timing_options"><code>KeyframeEffect</code></a>:</p>
<pre class="brush: js">aliceChange<strong>.</strong>currentTime = aliceChange.effect.timing.duration / 2;</pre>
<p>Un modo más genérico para encontrar la marca del 50% en una animación sería :</p>
<pre class="brush: js">animation.currentTime =
animation.effect.getComputedTiming().delay +
animation.effect.getComputedTiming().activeDuration / 2;</pre>
<h2 id="Especificaciones">Especificaciones</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
<tr>
<td>{{SpecName('Web Animations', '#dom-animation-currenttime', 'currentTime')}}</td>
<td>{{Spec2("Web Animations")}}</td>
<td> </td>
</tr>
</tbody>
</table>
<h2 id="Compatibilidad_del_navegador">Compatibilidad del navegador</h2>
{{Compat("api.Animation.currentTime")}}
<h2 id="Ver_también" style="line-height: 30px; font-size: 2.14285714285714rem;">Ver también</h2>
<ul>
<li>{{domxref("Animation")}} <span id="result_box" lang="es"><span>para otros métodos y propiedades que puede usar para controlar la animación de la página web</span></span>.</li>
<li>{{domxref("Animation.startTime")}} para programar el tiempo de inicio de una animación.</li>
<li><a href="/en-US/docs/Web/API/Web_Animations_API">Web Animations API</a></li>
</ul>
|