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 = | + | var offset = 300; |
var duration = 1000; | var duration = 1000; | ||
jQuery(window).scroll(function() { | jQuery(window).scroll(function() { | ||
Line 9: | Line 9: | ||
timer = setTimeout(function() { | timer = setTimeout(function() { | ||
jQuery(stats).fadeOut(duration)}, 3000); | jQuery(stats).fadeOut(duration)}, 3000); | ||
- | } | + | } |
- | + | ||
}); | }); | ||
Revision as of 13:18, 16 July 2014
jQuery(document).ready(function() {
var stats = ('.back-to-top'), timer; var offset = 300; 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)}, 3000); } }); jQuery(stats).click(function(event) { event.preventDefault(); jQuery('html, body').animate({scrollTop: 0}, duration); return false; });
});