-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsmoothScroll.min.js
More file actions
1 lines (1 loc) · 902 Bytes
/
smoothScroll.min.js
File metadata and controls
1 lines (1 loc) · 902 Bytes
1
var smooth_scroll=function(){var a,b,c,d,e,f,g=function(a,b){return b.indexOf(a)>-1},h=function(){c>0&&e+c>d&&(c=d-e,clearInterval(a)),c<0&&e+c<d&&(c=d-e,clearInterval(a)),window.scrollBy(0,c),e+=c,c=1.1*c},i=function(f){void 0===a&&null===a||clearInterval(a),d=f.offsetTop-b,e=window.scrollY,a=setInterval(h.bind(f),10),c=1,e>d&&(c*=-1)},j=function(a){a.preventDefault();anchor_href=this.getAttribute("href"),element_id=anchor_href.slice(1,anchor_href.length);var c=document.getElementById(element_id);i(c)},k=function(a){void 0!==a&&null!==a&&(void 0!==a.header_id&&null!==a.header_id&&(b=document.getElementById(a.header_id).getBoundingClientRect().height),f=a.ignore_links||[]);for(var c=document.querySelectorAll("a[href^='#']"),d=0;d<c.length;d++){link=c[d];var e=link.getAttribute("href");"#"===e||g(e.slice(1,e.length),f)||link.addEventListener("click",j.bind(link))}b=b||0};return{init:k}}();