An Animated Google Doodle for Newton’s Apple Tree

Newton AppleIssac Newton was sitting under an apple tree, an apple fell on his head and that inspired Newton to develop his theory of gravity.

Today is the 366th birthday of Sir Isaac Newton and Google is celebrating it with an interesting logo on their homepage.

This is probably the first Google Doodle that’s animated but they haven’t used Flash or GIF animation for this logo – it’s a simple JavaScript. Hat tip Suhel.

<img width="384" height="138" border="0" onload="window.lol&amp;&amp;lol();setTimeout(function(){var h=0,v=1,f=document.getElementById('fall'),i=setInterval(function(){if(f){var r=parseInt(f.style.right)+h,b=parseInt(f.style.bottom)-v;f.style.right=r+'px';f.style.bottom=b+'px';if(b>-210){v+=2}else{h=(v>9)?v*0.1:0;v*=(v>9)?-0.3:0}}},25);google.rein&amp;&amp;google.rein.push(function(){clearInterval(i);h=0;v=1})},2000)" style="margin-top: -1.22em;" id="logo" title="Birthday of Sir Isaac Newton" alt="Birthday of Sir Isaac Newton" src="/logos/newton10-tree.jpg"/>

Find this article at: http://labnol.org/?p=12297

Reader Comments

Great experience !! first Animated Google Doodle …such a good job

This wouldn’t be a subtle salute to Apple would it?

Its a Google API. Take a look at google.rein.push() funct. It takes the return of JS’s setInterval and, if the ID of img exists, change the ‘right’ and ‘bottom’ style atributtes.
The rest is just the google API adjustments, like clearInterval and visibility issues.

Excellent, thanks for explaining that, it had me flumoxed how they could animate over the top of the search bar without using flash or a gif. Genius!

Does anyone know how this was actually done? The code above is incomplete. Would love to have exact code for creating that effect. :)

I really liked it…. two thumbs up for google…


Questions & Answers