{"size": 3764, "ext": "js", "max_stars_repo_path": "dist/scrollspy.min.js", "max_stars_repo_name": "asthesky/scrollspy", "max_stars_repo_stars_event_min_datetime": "2017-08-08T15:55:46.000Z", "max_stars_repo_stars_event_max_datetime": "2017-08-08T15:55:46.000Z", "max_issues_repo_path": "dist/scrollspy.min.js", "max_issues_repo_name": "asthesky/scrollspy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dist/scrollspy.min.js", "max_forks_repo_name": "asthesky/scrollspy", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 537.7142857143, "max_line_length": 3670, "alphanum_fraction": 0.7003188098}
/**
* name: scrollspy
* version: 1.0.0
* author: asthesky
* time: 2017-08-02T06:30:12.796Z
*/
!function(t){var n=function(){return this}.call();"function"==typeof define?(define.amd&&define(["jquery"],t),define.cmd&&define("scrollspy",function(n,e,l){return t($)})):"object"==typeof exports?module.exports=t():n.Scrollspy=t(n.jQuery||n.$)}(function(t){var n=function(n){var e=this;e.config=t.extend({},e.defaults,n),e.initial.call(e)},e=n.prototype;return e.defaults={navEl:null,navListEl:null,navItemEl:null,currentCls:"current",contentEl:null,contentTxtCls:"data-txt",contentShiftCls:"data-shift",navTopH:0,renderNav:function(t){for(var n="",e=0;e<t.length;e++)n+='<a class="" href="#'+t[e].id+'">'+t[e].txt+"</a>";return n},fixedNav:function(t,n){switch(n){case 0:t.css({position:"static"});break;case 1:t.css({position:"fixed",display:"block"});break;case 2:t.css({display:"none"})}},scrollFn:{},enterFn:{},reachFn:{},loadFn:{}},e.initial=function(){var n=this,e=n.config;if(e.navEl=t(e.navEl),e.navListEl?e.navListEl=e.navEl.find(e.navListEl):e.navListEl=e.navEl,e.contentEl=t(e.contentEl),e.contentObj=[],e.contentEl.each(function(n,l){var o={};o.el=t(this),o.id=o.el.attr("id"),o.txt=o.el.attr(e.contentTxtCls),o.shift=parseInt(o.el.attr(e.contentShiftCls))||0,e.contentObj.push(o)}),e.isEnter="",e.isReach={},e.isLoad={},e.renderNav){var l=e.renderNav.call(n,e.contentObj);e.navListEl.html(l)}e.navItemEl?e.navItemEl=e.navListEl.find(e.navItemEl):e.navItemEl=e.navListEl.children(),n.scrollFlow(),n.scrollEvents()},e.scrollFlow=function(){var n=this,e=n.config;if(e.contentObj.length){var l=t(window).scrollTop(),o=t(document).height(),a=t(window).height(),i=o-a;t.each(e.contentObj,function(t,n){var l=n.el;n.offsetTop=l.offset().top-e.navTopH,n.fakeOffsetTop=n.offsetTop,n.height=l.height(),n.offsetBot=Math.round(n.offsetTop+n.height),n.shift&&(n.fakeOffsetTop=n.offsetTop+n.shift),n.offsetTop>=i&&(n.fakeOffsetTop=i)});var s=e.contentObj[0].offsetTop,c=e.contentObj[e.contentObj.length-1].offsetBot,r=(l>=s)+(l>=c);e.fixedNav.call(n,e.navEl,r),t.each(e.contentObj,function(o,i){var s,c,r;s=i.fakeOffsetTop||i.offsetTop,r=(c=e.contentObj[o+1])?c.fakeOffsetTop||c.offsetTop:i.offsetBot,r-=2,l>=s&&l<r&&(e.navItemEl.removeClass(e.currentCls),t(e.navItemEl[o]).addClass(e.currentCls),e.isEnter!==i.id&&(e.isEnter=i.id,e.enterFn[i.id]&&e.enterFn[i.id].call(n,i)),e.isReach[i.id]||(e.isReach[i.id]=!0,e.reachFn[i.id]&&e.reachFn[i.id].call(n,i))),(l<=s&&l+a>=s||l>=s&&l<r)&&(e.isLoad[i.id]||(e.isLoad[i.id]=!0,e.loadFn[i.id]&&e.loadFn[i.id].call(n,i))),e.scrollFn[i.id]&&e.scrollFn[i.id].call(n,i)})}},e.scrollEvents=function(){var n=this,e=n.config;n.scrollEvent=n.throttle(function(t){n.scrollFlow.call(n,t)},25),n.navClickEvent=function(n){var l=t(this);e.navItemEl.removeClass(e.currentCls),l.addClass(e.currentCls);for(var o,a=("a"==this.tagName.toLowerCase()?t(this):t(this).find("a")).attr("href"),i=0;i<e.contentObj.length;i++)if(e.contentObj[i].id==a.split("#")[1]){o=e.contentObj[i].fakeOffsetTop||e.contentObj[i].offsetTop;break}o||(o=t(a).offset().top-e.navTopH),t(window).scrollTop(o),n.preventDefault()},t(window).on("scroll",n.scrollEvent),e.navItemEl.on("click",n.navClickEvent)},e.destroy=function(n){var e=this,l=e.config;t(window).off("scroll",e.scrollEvent),l.navItemEl.on("click",e.navClickEvent),n&&n.call(this)},e.throttle=function(t,n,e){var l,o,a,i=null,s=0;e||(e={});var c=function(){s=!1===e.leading?0:+new Date,i=null,a=t.apply(l,o),i||(l=o=null)};return function(){var r=+new Date;s||!1!==e.leading||(s=r);var f=n-(r-s);return l=this,o=arguments,f<=0||f>n?(clearTimeout(i),i=null,s=r,a=t.apply(l,o),i||(l=o=null)):i||!1===e.trailing||(i=setTimeout(c,f)),a}},t.scrollspy=function(t){return new n(t)},function(t){return new n(t)}});