Template:Team:KIT-Kyoto/Scroll
From 2014.igem.org
(Difference between revisions)
(7 intermediate revisions not shown) | |||
Line 3: | Line 3: | ||
$(function() { | $(function() { | ||
$(".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 }, | + | $('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); | + | $('body,html').animate({scrollTop: 0 }, 500, 'swing'); |
return false; | return false; | ||
}); | }); |
Latest revision as of 08:38, 15 September 2014