Created
September 14, 2017 09:14
-
-
Save screeny05/aaa1e9b73d64affdcd272b0e8f4fd0ad to your computer and use it in GitHub Desktop.
Idle Throttle - Just like a regular throttle, except that it waits for idle or timeout
This file contains hidden or 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 idleThrottle = function(cb, timeout){ | |
var idleId; | |
return function(){ | |
if(idleId){ | |
cancelIdleCallback(idleId); | |
} | |
idleId = requestIdleCallback(cb, { timeout: timeout }); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment