JavaScript window.cancelAnimationFrame() Method
You are Here:
JavaScript window.cancelAnimationFrame() Method
The window.cancelAnimationFrame()
method cancels an animation frame request previously scheduled through a call to window.requestAnimationFrame().
Example
HTML Online Editor
<!DOCTYPE html>
<html>
<body>
<button onclick="myStart()">start</button>
<button onclick="myStop()">stop</button>
<p id="point"></p>
<script>
var x = document.getElementById("point");
var num = 0;
var globalID = "";
function myFunction(){
num += 1
x.innerHTML = num;
globalID = requestAnimationFrame(myFunction);
}
function myStart(){
globalID = requestAnimationFrame(myFunction);
}
function myStop(){
cancelAnimationFrame(globalID);
}
</script>
</body>
</html>
Syntax
window.cancelAnimationFrame(requestID)
Parameter Values
Value | Type | Explanation |
---|---|---|
requestID | Required | Specifies the ID value returned by the call to window.requestAnimationFrame() that requested the callback. |
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.