Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function preload() {
  2.  
  3.         // Get the site width / height
  4.         siteWidth = $(window).width();
  5.         siteHeight = $(window).height();
  6.    
  7.         // Prepend the Loader Icon (circle) & the Hand
  8.         $('body').prepend('<div id="loadIcon" /><div id="hand" class="grabv" />');
  9.        
  10.         // Set the Icon variables
  11.         var loadicon = $('#loadIcon');
  12.         var hand = $('#hand');
  13.        
  14.         // Additional CSS Dependant on the site width / icon width.
  15.         loadicon.css({marginLeft: - loadicon.width() / 2, left: siteWidth / 2});
  16.         hand.css({marginLeft: - hand.width() / 2, left: siteWidth / 2});
  17.        
  18.         // Position 1 (pull down)
  19.         position1 = (siteHeight / 2) - 21;
  20.        
  21.         // Positions 2 (throw the load)
  22.         position2v = (siteHeight / 4);
  23.         position2h = (siteWidth / 4);
  24.        
  25.        
  26.         // Set a quick timeout
  27.         // for loading of icons
  28.         setTimeout(function() {
  29.        
  30.             // Animate the position 1 (pull down)
  31.             loadicon.stop().animate({top: position1}, 1500);
  32.             hand.stop().animate({top: position1 + 36}, 1500, function() {
  33.            
  34.                 // Remove + Add the default hand icon
  35.                 $(this).removeClass().addClass('default');
  36.                
  37.                 // Animate it to the bottom right a little
  38.                 $(this).animate({left: '+=50', top: '+=30'}, 400, function() {
  39.                
  40.                     // This in scope. [hand]
  41.                     var $this = $(this);
  42.                    
  43.                     // One finger
  44.                     setTimeout(function() {
  45.                         $this.addClass('one').css({left: '-=5', top: '+=1'});
  46.                     }, 500);
  47.                    
  48.                     // Two fingers
  49.                     setTimeout(function() {
  50.                         $this.addClass('two').css({top: '-=2'});
  51.                     }, 1000);
  52.                    
  53.                     // Three fingers
  54.                     setTimeout(function() {
  55.                         $this.addClass('three');
  56.                     }, 1500);
  57.                    
  58.                     // 'OK' hand
  59.                     setTimeout(function() {
  60.                         $this.addClass('ok');
  61.                     }, 2000);
  62.                    
  63.                     // 2.8 Seconds
  64.                     // with 'OK' hand
  65.                     setTimeout(function() {
  66.                    
  67.                         // Remove + Add the default hand icon
  68.                         $this.removeClass().addClass('default');
  69.                        
  70.                         // Animate the hand icon to the loader
  71.                         $this.animate({left: '-=41', top: '-=31'}, 400, function() {
  72.                        
  73.                             // Change to drag icon
  74.                             $(this).addClass('drag');
  75.                            
  76.                             // 0.2 Second timeout
  77.                             setTimeout(function() {
  78.                            
  79.                                 // Animate the hand to [position2h/position2v] - use 'easeOutBack' for momentum effect.
  80.                                 hand.animate({left: '+='+position2h+'', top: '-='+position2v+''}, 500, 'easeOutBack', function() {
  81.                                
  82.                                     // Add the default hand icon
  83.                                     $(this).removeClass().addClass('default');
  84.                                    
  85.                                     // Animate the hand icon to the bottom middle of browser window.
  86.                                     $(this).animate({top: siteHeight, left: siteWidth / 2}, 400, function() {
  87.                                    
  88.                                         // Add upside down grab hand icon
  89.                                         $(this).removeClass().addClass('grabu');
  90.                                        
  91.                                         // Animate to top -24 (icon height)
  92.                                         $(this).animate({top: -24}, 1000, function() {
  93.                                             $(this).remove();
  94.                                         });
  95.                                        
  96.                                         // Animate wrapper to top creating a pulling effect
  97.                                         // -1 because of the top border
  98.                                         $('#wrapper').css({display:'block'}).animate({top: -1}, 1000, function() {
  99.                                            
  100.                                             // Add block, overides
  101.                                             // absolute positioning
  102.                                             $(this).addClass('block');
  103.                                            
  104.                                             // Site load complete
  105.                                             // Run the footer function
  106.                                             footer();
  107.                                            
  108.                                         });
  109.                                        
  110.                                     });
  111.                                    
  112.                                 });
  113.                                
  114.                                 // Animate the load icon in sync with the hand icon
  115.                                 // Faster because of no easing.
  116.                                 loadicon.animate({left: '+='+position2h+'', top: '-='+position2v+''}, 200);
  117.                                
  118.                                 // Set timeout to keep it animating
  119.                                 setTimeout(function() {
  120.                                
  121.                                     // Speed up the animation for
  122.                                     // momentum effect.
  123.                                     loadicon.animate({left: '+=4000', top: '-=3000'}, 7500);
  124.                                    
  125.                                     // Set timeout to fade
  126.                                     // the loader out
  127.                                     setTimeout(function() {
  128.                                         loadicon.fadeOut(400, function() {
  129.                                             $(this).remove();
  130.                                         });
  131.                                     }, 3000);
  132.                                    
  133.                                 }, 195);
  134.                                
  135.                             }, 200);
  136.    
  137.                         });
  138.                        
  139.                     }, 2800);
  140.                    
  141.                 });
  142.             });
  143.      
  144.         }, 100);
  145.    
  146.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement