0

I have two events

cy.on('mousedown touchstart', 'node', function (event) {
  // start
});

cy.on('mouseover tapdragover', 'node', function (event) {
  // end
});

The problem is that the second event is almost immediately fired since the first event was fired when the mouse is being pressed on a node and the second is fired when the mouse is over a node.

Is it possible to debounce or defer the action? I know the syntax is cytoscape.js-specific, but I guess the regular possibilities of using debounce and defer apply.

I guess an easy solution would be to save a timestamp in the first event and check if endTime - startTime > threshold in the second event.

Jamgreen
  • 10,329
  • 29
  • 113
  • 224

1 Answers1

0

Yes, just use Lodash: cy.on('evt1 evt2 ...', _.debounce( handler ))

maxkfranz
  • 11,896
  • 1
  • 27
  • 36