I got requestAnimationFrame(loop); and I’m trying to make onclick button to start animation, once you press it animation starts, I got button figured out <button type="start" form="form1" value="start onclick="start()">start</button>
But i cannot figure out how to make it into a script.
>Solution :
Here is a snippet example :
<button onclick="start()">start</button>
<script>
var animId=false;
function start() {
animId=requestAnimationFrame(loop);
}
function loop() {
//your code here
}
// I added this in case you wanted to call a stop
function stop() {
animId && cancelAnimationFrame(animId);
}
</script>