diff options
Diffstat (limited to 'files/ru/web/api/window/cancelanimationframe/index.html')
-rw-r--r-- | files/ru/web/api/window/cancelanimationframe/index.html | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/files/ru/web/api/window/cancelanimationframe/index.html b/files/ru/web/api/window/cancelanimationframe/index.html new file mode 100644 index 0000000000..897d147ae0 --- /dev/null +++ b/files/ru/web/api/window/cancelanimationframe/index.html @@ -0,0 +1,65 @@ +--- +title: window.cancelAnimationFrame() +slug: Web/API/Window/cancelAnimationFrame +translation_of: Web/API/Window/cancelAnimationFrame +--- +<div>{{APIRef}}</div> + +<p>Метод <code><strong>window.cancelAnimationFrame()</strong></code> останавливает анимацию, запланированную с помощью {{domxref("window.requestAnimationFrame()")}}.</p> + +<h2 id="Синтаксис">Синтаксис</h2> + +<pre class="syntaxbox notranslate">window.cancelAnimationFrame(<em>requestID</em>); +</pre> + +<h3 id="Параметры">Параметры</h3> + +<dl> + <dt><code>requestID</code></dt> + <dd>Значение, которое возвращает {{domxref("window.requestAnimationFrame()")}} при запросе callback.</dd> +</dl> + +<h2 id="Примеры">Примеры</h2> + +<pre class="brush: js notranslate">var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || + window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; + +var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame; + +var start = window.mozAnimationStartTime; // Поддерживается только FF. В других браузерах можно использовать Date.now(). + +var myReq; + +function step(timestamp) { + var progress = timestamp - start; + d.style.left = Math.min(progress / 10, 200) + 'px'; + if (progress < 2000) { + // Важно обновлять requestId при каждом запросе requestAnimationFrame + myReq = requestAnimationFrame(step); + } +} +myReq = requestAnimationFrame(step); +// остановка с использованием последнего requestId +cancelAnimationFrame(myReq); +</pre> + +<h2 id="Совместимость_с_браузерами">Совместимость с браузерами</h2> + +<div> + + +<p>{{Compat("api.Window.cancelAnimationFrame")}}</p> +</div> + +<h2 id="Спецификация">Спецификация</h2> + +<ul> + <li>{{spec("https://www.w3.org/TR/html51/webappapis.html#animation-frames", "Timing control for script-based animations: cancelAnimationFrame", "WD")}}</li> +</ul> + +<h2 id="Смотрите_также">Смотрите также</h2> + +<ul> + <li>{{domxref("window.mozAnimationStartTime")}}</li> + <li>{{domxref("window.requestAnimationFrame()")}}</li> +</ul> |