title: Rotating div with mouse
body: <p>I am building time picker in js where you can set hours on "Real" clocks.
  I'm rotating div with this script:</p>
  
  <pre><code>if (e.target.id == "rotationSliderContainer") {
      g = e.offsetX;
      h = e.offsetY;
  }
  var atan = Math.atan2(g - radius, h - radius);
  deg = -atan / (Math.PI / 180) + 180;
  </code></pre>
  
  <p>Although it works it has a little bug, whenever you try to move div between 2/3 and 9/10 its "stops" or freezes, it even returns degrees as <code>NaN</code> when I am rotating div while mouse is still on the div.</p>
  
  <p>I can't find any solution to this little problem.I tried to use <code>asin()</code> instead of <code>atan2</code> but it still didn't work.</p>
  
  <p>Did I overlook something? demo: <a href="http://jsfiddle.net/afo7ky03/6/" rel="nofollow">http://jsfiddle.net/afo7ky03/6/</a></p>