Share code js cá bơi cực chất

22 bài đăng
13.08.2016 / 17:47
kaiser
Bài đăng: 238
Member
HTML5
  1. <script type='text/javascript'>
  2. //<![CDATA[
  3. var pictureSrc ="http://i.imgur.com/le0GAxx.jpg"; //the location of the snowflakes
  4. var pictureWidth = 120; //the width of the snowflakes
  5. var pictureHeight = 120; //the height of the snowflakes
  6. var numFlakes = 10; //the number of snowflakes
  7. var downSpeed = 0.01; //the falling speed of snowflakes (portion of screen per 100 ms)
  8. var lrFlakes = 10; //the speed that the snowflakes should swing from side to side
  9.  
  10.  
  11. if( typeof( numFlakes ) != 'number' || Math.round( numFlakes ) != numFlakes || numFlakes < 1 ) { numFlakes = 10; }
  12.  
  13. //draw the snowflakes
  14. for( var x = 0; x < numFlakes; x++ ) {
  15. if( document.layers ) { //releave NS4 bug
  16. document.write('<layer id="snFlkDiv'+x+'"><imgsrc="'+pictureSrc+'" height="'+pictureHeight+'"width="'+pictureWidth+'" alt="*" border="0"></layer>');
  17. } else {
  18. document.write('<div style="position:absolute; z-index:9999;"id="snFlkDiv'+x+'"><img src="'+pictureSrc+'"height="'+pictureHeight+'" width="'+pictureWidth+'" alt="*"border="0"></div>');
  19. }
  20. }
  21.  
  22. //calculate initial positions (in portions of browser window size)
  23. var xcoords = new Array(), ycoords = new Array(), snFlkTemp;
  24. for( var x = 0; x < numFlakes; x++ ) {
  25. xcoords[x] = ( x + 1 ) / ( numFlakes + 1 );
  26. do { snFlkTemp = Math.round( ( numFlakes - 1 ) * Math.random() );
  27. } while( typeof( ycoords[snFlkTemp] ) == 'number' );
  28. ycoords[snFlkTemp] = x / numFlakes;
  29. }
  30.  
  31. //now animate
  32. function flakeFall() {
  33. if( !getRefToDivNest('snFlkDiv0') ) { return; }
  34. var scrWidth = 0, scrHeight = 0, scrollHeight = 0, scrollWidth = 0;
  35. //find screen settings for all variations. doing this every time allows for resizing and scrolling
  36. if( typeof( window.innerWidth ) == 'number' ) { scrWidth = window.innerWidth; scrHeight = window.innerHeight; } else {
  37. if( document.documentElement && (document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
  38. scrWidth = document.documentElement.clientWidth; scrHeight = document.documentElement.clientHeight; } else {
  39. if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  40. scrWidth = document.body.clientWidth; scrHeight = document.body.clientHeight; } } }
  41. if( typeof( window.pageYOffset ) == 'number' ) { scrollHeight = pageYOffset; scrollWidth = pageXOffset; } else {
  42. if( document.body && ( document.body.scrollLeft ||document.body.scrollTop ) ) { scrollHeight = document.body.scrollTop;scrollWidth = document.body.scrollLeft; } else {
  43. if(document.documentElement && (document.documentElement.scrollLeft ||document.documentElement.scrollTop ) ) { scrollHeight =document.documentElement.scrollTop; scrollWidth =document.documentElement.scrollLeft; } }
  44. }
  45. //move the snowflakes to their new position
  46. for( var x = 0; x < numFlakes; x++ ) {
  47. if( ycoords[x] * scrHeight > scrHeight - pictureHeight ) { ycoords[x] = 0; }
  48. var divRef = getRefToDivNest('snFlkDiv'+x); if( !divRef ) { return; }
  49. if( divRef.style ) { divRef = divRef.style; } var oPix = document.childNodes ? 'px' : 0;
  50. divRef.top = ( Math.round( ycoords[x] * scrHeight ) + scrollHeight ) + oPix;
  51. divRef.left = ( Math.round( ( ( xcoords[x] * scrWidth ) - (pictureWidth / 2 ) ) + ( ( scrWidth / ( ( numFlakes + 1 ) * 4 ) ) * (Math.sin( lrFlakes * ycoords[x] ) - Math.sin( 3 * lrFlakes * ycoords[x]) ) ) ) + scrollWidth ) + oPix;
  52. ycoords[x] += downSpeed;
  53. }
  54. }
  55.  
  56. //DHTML handlers
  57. function getRefToDivNest(divName) {
  58. if( document.layers ) { return document.layers[divName]; } //NS4
  59. if( document[divName] ) { return document[divName]; } //NS4 also
  60. if( document.getElementById ) { return document.getElementById(divName); } //DOM (IE5+, NS6+, Mozilla0.9+, Opera)
  61. if( document.all ) { return document.all[divName]; } //Proprietary DOM - IE4
  62. return false;
  63. }
  64.  
  65. window.setInterval('flakeFall();',100);
  66. //]]>
  67. </script>
13.08.2016 / 18:06
bnduongdz
Bài đăng: 250
Member
™™ itym.CF ™™

:47:

13.08.2016 / 18:09
ga_bong
Bài đăng: 519
Member
♔ Lovemoon.wap.mu ♔

ko có demo là ko thích rùi :p

13.08.2016 / 18:10
mad
Bài đăng: 2434
Member
Nhào vô cắn tao đi, tao sợ mày à cắn bừa.

hình như tui có xem demo 1 lần rùi

13.08.2016 / 18:13
nasic
Bài đăng: 784
Member
Ma Văn Nguyên

Demo đâu

13.08.2016 / 18:18
kaiser
Bài đăng: 238
Member

Demo à :v

[IMAGE]
13.08.2016 / 18:20
kaiser
Bài đăng: 238
Member

:ngon:

13.08.2016 / 18:22
HuyAnh
Bài đăng: 1142
Member
https://www.facebook.com/boduyvidai9999/videos/219

Wap tên gì đấy :v show đi

13.08.2016 / 18:24
kaiser
Bài đăng: 238
Member

Cùi mà :'v

13.08.2016 / 18:27
TrieuLuan
Bài đăng: 453
Member
Happy New Year

http://i.imgur.com/le0GAxx.jpg

[IMAGE]

đây mà là cá à chủ top