Optimizing animations driven by onMouseMove
<p>To add some personality to our web application, I've added a little animation on certain elements where our robot mascot peeks out from behind when the mouse moves close. To do this, I've used the onmousemove function to check how far the cursor is and animate the robot when the mouse gets close.</p>

<p>It works fine, but it seems terribly unoptimized to be running this function many times a second all the time when a user is moving their mouse, even when it's not animating anything. My question is, are there other common methods to do animations like this that don't use as CPU unecessarily?</p>

<p>You can see examples and the code on our blog here <a href="http://www.hiringthing.com/2011/10/31/buttons-with-a-surprise.html" rel="nofollow">http://www.hiringthing.com/2011/10/31/buttons-with-a-surprise.html</a></p>

<p>Thanks</p>
