javascript - navbar fixed Position offset scroll and smooth scroll -


i'm having problem, have 2 js scripts doesn't work together.

the first 1 makes "scroll id" offset matches height of fixed navbar on top of browser.

the second 1 making scroll smooth travels, doesn't instantly go target id. problem can't merge them together.

scroll offset:

$(document).ready(function () {      $(".first-scroller").on('click', 'a', function (event) {          event.preventdefault();         var o = $($(this).attr("href")).offset();         var st = o.top - $("#fixedbar").outerheight(true);         window.scrollto(0, st);     }); }); 

smooth scroll:

$('a[href*=#]:not([href=#])').click(function () {      if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {          var target = $(this.hash);         target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');          if (target.length) {              $('html,body').animate({                 scrolltop: target.offset().top             }, 1000);              return false;         }     } }); 


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -