Created
February 28, 2017 19:06
-
-
Save Acconut/3edd7fde6b5fa5231fd2eb8e08fb167c 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
// with leading = true and trailing = false | |
function throttle(func, wait) { | |
func(); | |
setTimeout(function() { | |
throttle(func, wait); | |
}, wait); | |
} | |
// with leading = false and trailing = true | |
function throttle(func, wait) { | |
setTimeout(function() { | |
func(); | |
throttle(func, wait); | |
}, wait); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment