dio-v
8/23/2015 - 8:14 AM

debounce (voor functie NA delay uit) Anders dan throttle, die de functie direct uitvoert.

debounce (voor functie NA delay uit) Anders dan throttle, die de functie direct uitvoert.

function debounce(fn, delay) {
  var timer = null;
  return function () {
    var context = this, args = arguments;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  };
}