How does Google do a barrel roll?
by Dan Linn, Technical Lead/Fun Master
By now you've probably seen Google "do a barrel roll". If you haven't, head over to google.com and enter "Do a barrel roll". What? You're using IE? Ok, well then no tricks for you. I suggest Chrome. For the rest of us, Google's page does a nice little in-place spin. When you saw it you may have thought "How the heck did they pull that off?" or maybe you said "Since when does google use flash?" or possibly "I feel the need... ...the need for speed!". The answer to the first question is easy. I'll show you how they did it:
Step 1: Create an animation in css3
@-moz-keyframes roll { 100% { -moz-transform: rotate(360deg); } } @-o-keyframes roll { 100% { -o-transform: rotate(360deg); } } @-webkit-keyframes roll { 100% { -webkit-transform: rotate(360deg); } }
Step 2: Apply to the body
body{ -moz-animation-name: roll; -moz-animation-duration: 4s; -moz-animation-iteration-count: 1; -o-animation-name: roll; -o-animation-duration: 4s; -o-animation-iteration-count: 1; -webkit-animation-name: roll; -webkit-animation-duration: 4s; -webkit-animation-iteration-count: 1; }
This is fairly cutting edge, so we still have to use the vendor prefixes, but the code is pretty straight forward. What's surprising is how little of it they needed. If this were a webkit only app, they could have done it with two lines of code using a transition. You never know though, the webkit standard could end up becoming a standard and this will be as easy as this:
body { transform:rotate(360deg); transition: 4s rotate; }
Someday, IE will adopt the standards (or die) and we'll all be able to see fun stuff like this. Since IE doesn't support this, it may not be something we can implement across the board yet, but for a little bit of fun on 'modern browsers' it's great.
Comments
neat
Posted by Robbie Ferrero on . [Reply]
Didn't know about that one. Pretty cool. You can also search for the words "tilt" and "askew" on google to get some subtle transform action... -webkit-transform: rotate(1deg)
Browser upgrade?
Posted by Joaquin Lippincott on . [Reply]
What's an IE user to do? How can Google do this? Does this mean I need to migrate away from IE 5.5 for the Mac?
IE6 nad below
Posted by Victor Stanescu on . [Reply]
Dude, it's not called migrating it's called evolution! Do you still chase down a buffalo or go to the supermarket?! It's the same thing..
Drupal module for Barrel Rolls
Posted by Capi Etheriel on . [Reply]
I just couldn't resist the urge of coding it. It is available at my sandbox, drop a few lines here to see the project approved for a full release!
Cool trick! I only got to see
Posted by Dr. Robert Doebler on . [Reply]
Cool trick! I only got to see it just now. :) I've pretty much given up on IE a long time ago, it just doesn't offer the things that Google Chrome can. And Chrome rarely has any bugs which is the main reason why I use it now.
Soo cool!
Posted by Victor Stanescu on . [Reply]
Thanks for the info, it's a cool trick i will add to my blog also :P
In the meantime, there are a ton of other tricks made by google:
http://www.vectorash.ro/google-hoaxes-practical-jokes/
P.S. Decent browser is required of course!!!
its awesome.....
Posted by srinivasrao uggina on . [Reply]
cool.............
Add new comment