Team:Uppsala/JavaScript

From 2014.igem.org

Revision as of 13:21, 16 July 2014 by Tjocko (Talk | contribs)

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;
   });

});