Team:Uppsala/JavaScript

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
jQuery(document).ready(function() {
jQuery(document).ready(function() {
     var stats = ('.back-to-top'), timer;
     var stats = ('.back-to-top'), timer;
-
     var offset = 300;
+
     var offset = 500;
     var duration = 1000;
     var duration = 1000;
   jQuery(window).scroll(function() {
   jQuery(window).scroll(function() {
Line 8: Line 8:
             clearTimeout(timer);
             clearTimeout(timer);
             timer = setTimeout(function() {
             timer = setTimeout(function() {
-
             jQuery(stats).fadeOut(duration)}, 3000);     
+
             jQuery(stats).fadeOut(duration)}, 2000);     
     }   
     }   
         });
         });

Revision as of 13:21, 16 July 2014

jQuery(document).ready(function() {

   var stats = ('.back-to-top'), timer;
   var offset = 500;
   var duration = 1000;
 jQuery(window).scroll(function() {
       if (jQuery(this).scrollTop() > offset) {
           jQuery(stats).fadeIn(duration);
           clearTimeout(timer);
           timer = setTimeout(function() {
           jQuery(stats).fadeOut(duration)}, 2000);     
   }   
       });
      
   jQuery(stats).click(function(event) {
       event.preventDefault();
       jQuery('html, body').animate({scrollTop: 0}, duration);
       return false;
   });

});