Hacker News new | ask | show | jobs
by unlog 1600 days ago
Yes, but you have to code for it. I guess you mean you want to "kill the process" in some way, and that's not possible as far as I know.

One easy way is to add a flag

        let working = true;
        (function work() {
          console.log("running");
          if (working) requestAnimationFrame(work);
          else console.log("stopped");
        })();
Programmatically, you have the function cancelAnimationFrame that you give as parameter what requestAnimationFrame returns. The same as setTimeout and clearTimeout