bootstrap-386.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. self._386 = self._386 || {};
  2. $(function(){
  3. var character = { height: 20, width: 12.4 };
  4. function scrollLock() {
  5. var last = 0;
  6. $(window).bind('scroll', function(e) {
  7. var func, off = $(window).scrollTop();
  8. console.log(off, last, off < last ? "up" : "down");
  9. // this determines whether the user is intending to go up or down.
  10. func = off < last ? "floor" : "ceil";
  11. // make sure we don't run this from ourselves
  12. if(off % character.height === 0) {
  13. return;
  14. }
  15. last = off;
  16. window.scrollTo(
  17. 0,
  18. Math[func](off / character.height) * character.height
  19. );
  20. });
  21. }
  22. function loading() {
  23. if(_386.fastLoad) {
  24. document.body.style.visibility='visible';
  25. return;
  26. }
  27. var
  28. onePass = _386.onePass,
  29. speedFactor = 1 / (_386.speedFactor || 1) * 165000;
  30. wrap = document.createElement('div'),
  31. bar = wrap.appendChild(document.createElement('div')),
  32. cursor = document.createElement('div'),
  33. // If the user specified that the visibility is hidden, then we
  34. // start at the first pass ... otherwise we just do the
  35. // cursor fly-by
  36. pass = ($(document.body).css('visibility') == 'visible') ? 1 : 0,
  37. height = $(window).height(),
  38. width = $(window).width(),
  39. // this makes the loading of the screen proportional to the real-estate of the window.
  40. // it helps keep the cool sequence there while not making it waste too much time.
  41. rounds = (height * width / speedFactor),
  42. column = width, row = height - character.height;
  43. wrap.id = "wrap386";
  44. bar.id = "bar386";
  45. cursor.id = "cursor386";
  46. cursor.innerHTML = bar.innerHTML = '&#9604;';
  47. // only inject the wrap if the pass is 0
  48. if(pass === 0) {
  49. document.body.appendChild(wrap);
  50. document.body.style.visibility='visible';
  51. } else {
  52. document.body.appendChild(cursor);
  53. rounds /= 2;
  54. character.height *= 4;
  55. }
  56. var ival = setInterval(function(){
  57. for(var m = 0; m < rounds; m++) {
  58. column -= character.width;
  59. if(column <= 0) {
  60. column = width;
  61. row -= character.height;
  62. }
  63. if(row <= 0) {
  64. pass++;
  65. row = height - character.height;
  66. if(pass == 2) {
  67. document.body.removeChild(cursor);
  68. clearInterval(ival);
  69. } else {
  70. wrap.parentNode.removeChild(wrap);
  71. if(onePass) {
  72. clearInterval(ival);
  73. } else {
  74. document.body.appendChild(cursor);
  75. rounds /= 2;
  76. character.height *= 4;
  77. }
  78. }
  79. }
  80. if(pass === 0) {
  81. bar.style.width = column + "px";
  82. wrap.style.height = row + "px";
  83. } else {
  84. cursor.style.right = column + "px";
  85. cursor.style.bottom = row + "px";
  86. }
  87. }
  88. }, 1);
  89. }
  90. loading();
  91. });