Created
August 9, 2014 15:39
-
-
Save banderson623/be6a15bc9147ebc520a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var throttle = function(timeOutInMs,funct){ | |
var timer = 0; | |
return function(){ | |
var context = this; | |
// no op timer running | |
if (timer !== 0){return;} | |
var doIt = function(){ | |
funct.apply(context); | |
timer = 0; | |
}; | |
timer = setTimeout(doIt, timeOutInMs); | |
}; | |
}; | |
var throttledValue = throttle(250,function(){ | |
console.log("value " + $(this).val()); | |
}); | |
$("#average-temp-range").on("change", throttledValue); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment