react-sigma icon indicating copy to clipboard operation
react-sigma copied to clipboard

onDoubleClick eventHandler to add more interactive actions

Open michaelbdavid opened this issue 2 years ago • 2 comments

I'd like to add onDoubleClick eventhandler does this exist?

michaelbdavid avatar Oct 12 '22 17:10 michaelbdavid

Hi there!

Yes, the double click event exists; here are two possible implementations: (from MDN).

addEventListener('dblclick', (event) => {});
ondblclick = (event) => { };

And here some docs: https://developer.mozilla.org/en-US/docs/Web/API/Element/dblclick_event https://caniuse.com/mdn-api_element_dblclick_event

Hope this helps!

undefined-box avatar Oct 13 '22 17:10 undefined-box

Thanks for the reply. I guess I'm a newb here is there away to add double click handler when clicking on the nodes? I basically want to override the current behavior of zooming in if a node is dblclicked.

Tried to do something like:

×
←→1 of 2 errors on the page
TypeError: _sigma$current.addEventListener is not a function
(anonymous function)
  64 | const onDblClick = (event: any) => {
  65 |     console.log('dblclick', event);
  66 | };
> 67 | sigma.current?.addEventListener('dblclick', onDblClick);
     | ^  68 | 
  69 | return () => {
  70 |     sigma.current?.removeEventListener('dblclick', onDblClick);

also tried sigma.current.bind('dblclick', onDblClick) as well

where sigma.current is a ref on the Sigma component. and no joy...

Any thoughts?

michaelbdavid avatar Oct 26 '22 15:10 michaelbdavid