Template:Team:KIT-Kyoto/Scroll
From 2014.igem.org
(Difference between revisions)
(6 intermediate revisions not shown) | |||
Line 4: | Line 4: | ||
$(".btn").click(function () { | $(".btn").click(function () { | ||
var i = $(".btn").index(this) | var i = $(".btn").index(this) | ||
- | var p = $(". | + | var p = $(".scroll").eq(i).offset().top; |
- | p -= | + | p -= 70; |
$('html,body').animate({ scrollTop: p }, 500, 'swing'); | $('html,body').animate({ scrollTop: p }, 500, 'swing'); | ||
return false; | return false; | ||
}); | }); | ||
- | var | + | var top = $('#page-top'); |
- | + | top.hide(); | |
$(window).scroll(function () { | $(window).scroll(function () { | ||
- | if ($(this).scrollTop() > 150) { | + | if ($(this).scrollTop() > 150) {top.fadeIn();} |
- | else { | + | else {top.fadeOut();} |
}); | }); | ||
- | + | top.click(function () { | |
$('body,html').animate({scrollTop: 0 }, 500, 'swing'); | $('body,html').animate({scrollTop: 0 }, 500, 'swing'); | ||
return false; | return false; |
Latest revision as of 08:38, 15 September 2014