Team:Uppsala/JavaScript

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
-
 
$(document).ready(function (){
$(document).ready(function (){
-
var stats = $('.back-to-top'),
+
var stats = $('.back-to-top'), timer;
-
    timer;
+
        var offset = 220;
stats.hide();
stats.hide();
$(function () {
$(function () {
$(window).scroll(function() {
$(window).scroll(function() {
-
stats.fadeIn();
+
 
-
clearTimeout(timer);
+
  if ((this).scrollTop() > offset) {
-
timer = setTimeout(function() {
+
            stats.fadeIn();
 +
            clearTimeout(timer);
 +
timer = setTimeout(function() {
stats.stop(true,true).fadeOut('slow');
stats.stop(true,true).fadeOut('slow');
-
}, 3000);
+
}, 3000);
-
+
 
-
});
+
    }
 +
});
 +
$('.back-to-top').click(function () {
$('.back-to-top').click(function () {
$('body,html').animate({
$('body,html').animate({
Line 22: Line 25:
});
});
});
});
 +
 +
 +
jQuery(window).scroll(function() {
 +
        if ((this).scrollTop() > offset) {
 +
            ('.back-to-top').fadeIn(duration);     
 +
    }

Revision as of 12:41, 16 July 2014

$(document).ready(function (){ var stats = $('.back-to-top'), timer;

       var offset = 220;

stats.hide();

$(function () { $(window).scroll(function() {

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