This repository was archived by the owner on Jun 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathscrollspy.min.js
More file actions
17 lines (17 loc) · 1.9 KB
/
Copy pathscrollspy.min.js
File metadata and controls
17 lines (17 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
https://raw.github.com/thesmart/jquery-scrollspy/master/LICENSE
@see https://github.com/thesmart
@version 0.1.2
https://raw.github.com/jashkenas/underscore/master/LICENSE
@type {function}
@return {number}
https://raw.github.com/jashkenas/underscore/master/LICENSE
@param {function} func
@param {number} wait
@param {Object=} options
@returns {Function}
*/
(function(a){function x(b,d,n,f){var q=a();a.each(r,function(a,g){var c=g.offset().top,e=g.offset().left,l=e+g.width(),m=c+g.height();e>d||l<f||c>n||m<b||q.push(g)});return q}function y(){++h;var b=c.scrollTop(),d=c.scrollLeft(),n=d+c.width(),f=b+c.height(),b=x(b+e.top,n+e.right,f+e.bottom,d+e.left);a.each(b,function(b,a){"number"!=typeof a.data("scrollSpy:ticks")&&a.triggerHandler("scrollSpy:enter");a.data("scrollSpy:ticks",h)});a.each(t,function(b,a){var d=a.data("scrollSpy:ticks");"number"==typeof d&&
d!==h&&(a.triggerHandler("scrollSpy:exit"),a.data("scrollSpy:ticks",null))});t=b}function z(){c.trigger("scrollSpy:winSize")}function u(a,d,c){var f,e,p,g=null,k=0;c||(c={});var h=function(){k=!1===c.leading?0:v();g=null;p=a.apply(f,e);f=e=null};return function(){var l=v();k||!1!==c.leading||(k=l);var m=d-(l-k);f=this;e=arguments;0>=m?(clearTimeout(g),g=null,k=l,p=a.apply(f,e),f=e=null):g||!1===c.trailing||(g=setTimeout(h,m));return p}}var c=a(window),r=[],t=[],w=!1,h=0,e={top:0,right:0,bottom:0,
left:0},v=Date.now||function(){return(new Date).getTime()};a.scrollSpy=function(b,d){b=a(b);b.each(function(b,c){r.push(a(c))});d=d||{throttle:100};e.top=d.offsetTop||0;e.right=d.offsetRight||0;e.bottom=d.offsetBottom||0;e.left=d.offsetLeft||0;var h=u(y,d.throttle||100),f=function(){a(document).ready(h)};w||(c.on("scroll",f),c.on("resize",f),w=!0);setTimeout(f,0);return b};a.winSizeSpy=function(b){a.winSizeSpy=function(){return c};b=b||{throttle:100};return c.on("resize",u(z,b.throttle||100))};a.fn.scrollSpy=
function(b){return a.scrollSpy(a(this),b)}})(jQuery);