Team:Uppsala/JavaScript
From 2014.igem.org
(Difference between revisions)
Line 7: | Line 7: | ||
$(window).scroll(function() { | $(window).scroll(function() { | ||
- | if ((this).scrollTop() > offset) { | + | if (jQuery(this).scrollTop() > offset) { |
stats.fadeIn(); | stats.fadeIn(); | ||
clearTimeout(timer); | clearTimeout(timer); | ||
- | timer = setTimeout(function() { | + | timer = setTimeout(function() { |
stats.stop(true,true).fadeOut('slow'); | stats.stop(true,true).fadeOut('slow'); | ||
}, 3000); | }, 3000); |
Revision as of 12:46, 16 July 2014
$(document).ready(function (){ var stats = $('.back-to-top'), timer;
var offset = 220;
stats.hide();
$(function () { $(window).scroll(function() {
if (jQuery(this).scrollTop() > offset) { stats.fadeIn(); clearTimeout(timer); timer = setTimeout(function() {
stats.stop(true,true).fadeOut('slow'); }, 3000);
}
});
$('.back-to-top').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); }); });
jQuery(window).scroll(function() { if ((this).scrollTop() > offset) { ('.back-to-top').fadeIn(duration); }