aw_support
11/6/2019 - 8:49 PM

Smooth Scroll Sticky

//smooth scroll 
jQuery(function() {
  var height = jQuery(".sticky-container").outerHeight();
 
  jQuery('a[href*="#"]:not([href="#"])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
      var target = jQuery(this.hash);
      target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        jQuery('html, body').animate({
          scrollTop: target.offset().top - height
        }, 1000);
        return false;
      }
    }
  });
 
  if(window.location.hash) {
      // smooth scroll to the anchor id
      jQuery('html, body').animate({
        scrollTop: jQuery(window.location.hash).offset().top - height
    }, 1000);
  }
});