Template:Team:KIT-Kyoto/Scroll

From 2014.igem.org

(Difference between revisions)
 
(11 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 = $(".sentence").eq(i).offset().top;
+
var p = $(".scroll").eq(i).offset().top;
-
              p -= 100;
+
              p -= 70;
-
$('html,body').animate({ scrollTop: p }, 'fast');
+
$('html,body').animate({ scrollTop: p }, 500, 'swing');
return false;
return false;
-
});
+
});      
-
 
+
              var top = $('#page-top'); 
-
$(".btn_top").click(function () {
+
              top.hide();
-
$('html,body').animate({ scrollTop: 0 }, 'fast');
+
              $(window).scroll(function () {
-
return false;
+
                if ($(this).scrollTop() > 150) {top.fadeIn();}
-
});
+
               else {top.fadeOut();}
-
       
+
       });
-
        $('a[href^=#]').click(function() {
+
               top.click(function () {
-
              var speed = 400;//スクロール速度(ミリ秒)
+
                $('body,html').animate({scrollTop: 0 }, 500, 'swing');
-
              var href = $(this).attr("href");
+
               return false;
-
              var target =  $(href == "#" || href == "" ? 'html' : href);
+
       });
-
              $("html, body").animate({scrollTop: target.offset().top}, speed, 'swing');
+
-
              return false;
+
-
        });
+
-
 
+
});
});
</script>
</script>

Latest revision as of 08:38, 15 September 2014