Skip to content

Instantly share code, notes, and snippets.

@A
Last active September 21, 2015 14:06
Show Gist options
  • Save A/b56b2d7310bc0b7df563 to your computer and use it in GitHub Desktop.
Save A/b56b2d7310bc0b7df563 to your computer and use it in GitHub Desktop.

Revisions

  1. A revised this gist Sep 21, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion input-debounce-test.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,6 @@ function Test(str, offset) {
    if (i >= str.length) return;
    var e = $.Event('input', { keyCode: str.charCodeAt(i) });
    var val = $search.val();

    $search
    .val(val + str[i])
    .trigger(e)
  2. A created this gist Sep 21, 2015.
    22 changes: 22 additions & 0 deletions input-debounce-test.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    new Test('Hello World', 200); // try to change offset


    function Test(str, offset) {
    var i = 0;
    var $search = $('.sel-search-input');
    $search.val('').focus();
    (function next() {
    setTimeout(function() {
    if (i >= str.length) return;
    var e = $.Event('input', { keyCode: str.charCodeAt(i) });
    var val = $search.val();

    $search
    .val(val + str[i])
    .trigger(e)
    ;
    i++;
    next();
    }, offset);
    })();
    }