ClickTrap.js 447 B

123456789101112131415161718192021
  1. var TRAP_PRIORITY = 5000;
  2. /**
  3. * Installs a click trap that prevents a ghost click following a dragging operation.
  4. *
  5. * @return {Function} a function to immediately remove the installed trap.
  6. */
  7. export function install(eventBus, eventName) {
  8. eventName = eventName || 'element.click';
  9. function trap() {
  10. return false;
  11. }
  12. eventBus.once(eventName, TRAP_PRIORITY, trap);
  13. return function() {
  14. eventBus.off(eventName, trap);
  15. };
  16. }