request animation frame loop
<p>I came across this code 
<a href="https://gist.github.com/joelambert/1002116" rel="nofollow">https://gist.github.com/joelambert/1002116</a> and i thought of playing around with it</p>

<p>I tried to create a loop and stop it </p>

<pre><code>var tick = 0;
var dor = requestInterval(function(){
  tick++;
   console.log("hi", tick)
  if (tick &gt; 10){

     stop();
  }
},300)

function stop(){ 
  console.log("stop")
     clearRequestInterval(dor);
}
</code></pre>

<p>But the clearRequestInterval is not clearing the timer. But when i tried to call it from a button's event handler its working. Am I missing something?</p>

<p>I have attached a codepen
<a href="http://codepen.io/srajagop/pen/KgbbpR" rel="nofollow">http://codepen.io/srajagop/pen/KgbbpR</a></p>