all files / diagram-js/lib/util/ ClickTrap.js

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