Created
June 20, 2019 10:01
-
-
Save fyulistian/bcfc4ba141c7554d303c493c3d335e6e to your computer and use it in GitHub Desktop.
Type event
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
// delay on typing | |
function delay(callback, ms) { | |
let timer = 0; | |
return function() { | |
let context = this, args = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(function () { | |
callback.apply(context, args); | |
}, ms || 0); | |
}; | |
} |
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
const TYPING_TIMER_LENGTH = 700; | |
const $inputSearch = $('#inputSearch'); | |
$inputSearch.keyup(delay(function (e) { | |
let val = this.value; | |
// doSimething | |
// # | |
}, TYPING_TIMER_LENGTH)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment