examples/dropdown/dist/index.js
function addEventOnce(element, eventName, eventListener) {
  var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;

  var timeout = 0;
  return addEvent(element, eventName, function (e) {
    clearTimeout(timeout);
    timeout = setTimeout(function () {
      eventListener(e);
    }, delay);
  });
}
function addEventOnce(element, eventName, eventListener) {
  var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 500;

  var timeout = 0;
  return addEvent(element, eventName, function (e) {
    clearTimeout(timeout);
    timeout = setTimeout(function () {
      eventListener(e);
    }, delay);
  });
}
function addEventOnce ( element , eventName , eventListener ) { var delay = arguments . length > 3 && arguments [ 3 ] !== undefined ? arguments [ 3 ] : 500 ; var timeout = 0 ; return addEvent ( element , eventName , function ( e ) { clearTimeout ( timeout ) ; timeout = setTimeout ( function ( ) { eventListener ( e ) ; } , delay ) ; } ) ; }
Call event listener only once after "delay" ms
Useful for scroll, keydown and other events
when the actions must be done only once
when user stopped typing or scrolling for example

@param {HTMLElement} element
@param {String} eventName
@param {Function} eventListener
@param {Number} delay
@returns {Number}
Call event listener only once after delay ms Useful for scroll keydown and other events when the actions must be done only once when user stopped typing or scrolling for example