public/libraries.js
function onScroll() {
		// unique tick id
		++ticks;

		// viewport rectangle
		var top = jWindow.scrollTop(),
			left = jWindow.scrollLeft(),
			right = left + jWindow.width(),
			bottom = top + jWindow.height();

		// determine which elements are in view
//        + 60 accounts for fixed nav
		var intersections = findElements(top+offset.top + 200, right+offset.right, bottom+offset.bottom, left+offset.left);
		$.each(intersections, function(i, element) {

			var lastTick = element.data('scrollSpy:ticks');
			if (typeof lastTick != 'number') {
				// entered into view
				element.triggerHandler('scrollSpy:enter');
			}

			// update tick id
			element.data('scrollSpy:ticks', ticks);
		});

		// determine which elements are no longer in view
		$.each(elementsInView, function(i, element) {
			var lastTick = element.data('scrollSpy:ticks');
			if (typeof lastTick == 'number' && lastTick !== ticks) {
				// exited from view
				element.triggerHandler('scrollSpy:exit');
				element.data('scrollSpy:ticks', null);
			}
		});

		// remember elements in view for next tick
		elementsInView = intersections;
	}
function onScroll() {
		// unique tick id
		++ticks;

		// viewport rectangle
		var top = jWindow.scrollTop(),
			left = jWindow.scrollLeft(),
			right = left + jWindow.width(),
			bottom = top + jWindow.height();

		// determine which elements are in view
//        + 60 accounts for fixed nav
		var intersections = findElements(top+offset.top + 200, right+offset.right, bottom+offset.bottom, left+offset.left);
		$.each(intersections, function(i, element) {

			var lastTick = element.data('scrollSpy:ticks');
			if (typeof lastTick != 'number') {
				// entered into view
				element.triggerHandler('scrollSpy:enter');
			}

			// update tick id
			element.data('scrollSpy:ticks', ticks);
		});

		// determine which elements are no longer in view
		$.each(elementsInView, function(i, element) {
			var lastTick = element.data('scrollSpy:ticks');
			if (typeof lastTick == 'number' && lastTick !== ticks) {
				// exited from view
				element.triggerHandler('scrollSpy:exit');
				element.data('scrollSpy:ticks', null);
			}
		});

		// remember elements in view for next tick
		elementsInView = intersections;
	}
function onScroll ( ) { // unique tick id ++ ticks ; // viewport rectangle var top = jWindow . scrollTop ( ) , left = jWindow . scrollLeft ( ) , right = left + jWindow . width ( ) , bottom = top + jWindow . height ( ) ; // determine which elements are in view //        + 60 accounts for fixed nav var intersections = findElements ( top + offset . top + 200 , right + offset . right , bottom + offset . bottom , left + offset . left ) ; $ . each ( intersections , function ( i , element ) { var lastTick = element . data ( 'scrollSpy:ticks' ) ; if ( typeof lastTick != 'number' ) { // entered into view element . triggerHandler ( 'scrollSpy:enter' ) ; } // update tick id element . data ( 'scrollSpy:ticks' , ticks ) ; } ) ; // determine which elements are no longer in view $ . each ( elementsInView , function ( i , element ) { var lastTick = element . data ( 'scrollSpy:ticks' ) ; if ( typeof lastTick == 'number' && lastTick !== ticks ) { // exited from view element . triggerHandler ( 'scrollSpy:exit' ) ; element . data ( 'scrollSpy:ticks' , null ) ; } } ) ; // remember elements in view for next tick elementsInView = intersections ; }
Called when the user scrolls the window
Called when the user scrolls the window