User:Kmsxkuse/common.js

// Modified from http://www.javascriptkit.com/javatutors/detect-user-scroll-amount.shtml

var winHeight, docHeight, trackLength, throttleScroll; var calledCount = 1;

function getMeasurements{ winHeight = $(window).height; docHeight = $(document).height; trackLength = docHeight - winHeight; $('#t1').html(winHeight); $('#t2').html(docHeight); $('#t3').html(calledCount++); }

function amountScrolled{ var scrollTop = $(window).scrollTop; var pctScrolled = Math.floor(scrollTop/trackLength * 100); $('#testID').html(pctScrolled + '% scrolled'); }

$(function{	getMeasurements; 	amountScrolled; });

$($(window).on("resize", function{ getMeasurements; })); $($(window).on("scroll", function{ clearTimeout(throttleScroll); throttleScroll = setTimeout(function{ amountScrolled; }, 10); }));