Advertisement
ryuken2

Youtube loading effect

Oct 15th, 2013
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <!DOCTYPE>
  2. <html>
  3. <header>
  4. <style>
  5. #progress {
  6. position: fixed;
  7. z-index: 2147483647;
  8. top: 0;
  9. left: -6px;
  10. width: 1%;
  11. height: 2px;
  12. background: #0088CC;
  13. -moz-border-radius: 1px;
  14. -webkit-border-radius: 1px;
  15. border-radius: 1px;
  16. -moz-transition: width 500ms ease-out,opacity 400ms linear;
  17. -ms-transition: width 500ms ease-out,opacity 400ms linear;
  18. -o-transition: width 500ms ease-out,opacity 400ms linear;
  19. -webkit-transition: width 500ms ease-out,opacity 400ms linear;
  20. transition: width 500ms ease-out,opacity 400ms linear;
  21. }
  22. #progress dd, #progress dt {
  23. position: absolute;
  24. top: 0;
  25. height: 2px;
  26. -moz-box-shadow: #0088CC 1px 0 6px 1px;
  27. -ms-box-shadow: #0088CC 1px 0 6px 1px;
  28. -webkit-box-shadow: #0088CC 1px 0 6px 1px;
  29. box-shadow: #0088CC 1px 0 6px 1px;
  30. -moz-border-radius: 100%;
  31. -webkit-border-radius: 100%;
  32. border-radius: 100%;
  33. }
  34.  
  35. #progress dt {
  36. opacity: .6;
  37. width: 180px;
  38. right: -80px;
  39. clip: rect(-6px,90px,14px,-6px);
  40. }
  41.  
  42. #progress dd {
  43. opacity: .6;
  44. width: 20px;
  45. right: 0;
  46. clip: rect(-6px,22px,14px,10px);
  47. }
  48. </style>
  49. <script>
  50. function show () {
  51. document.body.innerHTML+="<div id=\"progress\"><dt></dt><dd></dd></div>";
  52. var pr=document.querySelector("#progress");
  53. setTimeout(function(){
  54. pr.style.width="60%";
  55. },300);
  56.  
  57. setTimeout(function(){
  58. pr.style.width="101%";
  59. },800);
  60.  
  61.  
  62. setTimeout(function(){
  63. pr.parentNode.removeChild(pr);
  64. },1600);
  65. return false;
  66. }
  67. $(document).ajaxStart(function() {
  68. //only add progress bar if added yet.
  69. if ($("#progress").length === 0) {
  70. $("body").append($("<div><dt/><dd/></div>").attr("id", "progress"));
  71. $("#progress").width((50 + Math.random() * 30) + "%");
  72. }
  73. });
  74.  
  75. $(document).ajaxComplete(function() {
  76. //End loading animation
  77. $("#progress").width("101%").delay(200).fadeOut(400, function() {
  78. $(this).remove();
  79. });
  80. });
  81. </script>
  82. </header>
  83. <body>
  84. <div>
  85. <a onclick='show();' href='#' class='btn'>Show Demo</a>
  86. </div>
  87. </body>
  88. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement