Today, JavaScript animation is implemented on the Google homepage. Okay, I'm late...

Source: Internet
Author: User

Many people are interested in the dynamic logo on the Google homepage today. I have also implemented it, but I just found someone in the garden has already logged on first (please refer to here )...

After all, it is the result of my own work. I 'd like to let it go. In fact, the implementation of Hu yunrui and his colleagues is still somewhat opportunistic, he copies all the HTML generated after the animation is executed, hides all the HTML, and then displays them one by one...

My method is implemented by constantly inserting Div with background like Google. First, we create a div style information [left, top, width, height, array of background-position-X, background-position-y], and then use setTimeout to regularly Insert the DIV with these styles.

The results are as follows :(Click Run!)

Background images used in animation:

CodeIt is relatively simple:

 (  Function  (){
VaR Style_info = [
[ 307 , 48 , 88 , 89 , 0 , 0 ],
[ 307 , 48 , 89 , 89 , - 88 , 0 ],
// N rows are omitted here...
];
VaR Logo = Document. getelementbyid ( ' Hplogo ' );
( Function Logo_run (){
SetTimeout ( Function (){
VaR A, div;
If ( = Style_info.shift ()){
Div = Document. createelement ( ' Div ' );
Div.style.css text = ' Position: absolute; ' +
' Left: ' + A [ 0 ] + ' Px; top: ' + A [ 1 ] + ' Px; width: ' + A [ 2 ] + ' Px; height: ' + A [ 3 ] + ' Px; ' +
' Background: URL ("graham11-hp-sprite.png") No-repeat ' + A [ 4 ] + ' Px ' + A [ 5 ] + ' Px; ' ;
Logo. appendchild (DIV );
Logo_run ();
}
}, 83 );
})();
})();
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.