summaryrefslogtreecommitdiff
path: root/_includes/scripts/lib/scroll-to.js
blob: e5a0ea24e9f9f4da299d4eb363bf68160ce0e8cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
(function() {
  var SOURCES = window.TEXT_VARIABLES.sources;
  window.Lazyload.js(SOURCES.jquery, function() {
    function scrollToAnchor(anchor, duration, callback) {
      var $root = this;
      $root.animate({ scrollTop: $(anchor).position().top }, duration, function() {
        window.history.replaceState(null, '', window.location.href.split('#')[0] + anchor);
        callback && callback();
      });
    }
    $.fn.scrollToAnchor = scrollToAnchor;
  });
})();