Smooth Scroll

ページ内移動をアニメーション化

詳しい導入事例は導入方法を参照してください。

  • DEMO

使い方

ヘッダー固定などでスクロール位置を調整したい場合は+-$('body,html').animate-+の前に調整分の数値をプラスする。

  • Script
$bd.on('click', "a[href ^= '#']", function(){

  let href = $(this).attr('href');
  let target = $(href == '#' || href == '' ? 'html' : href);
  let position = target.offset().top;
  $('body,html').animate({
    scrollTop: position
  }, 300, 'swing');
  return false;
});
やっほー