Yuhao
Yuhao

Reputation: 1610

A list of event types that d3js supports

I am using d3.js to create a data vis tool. I read in d3 documentation that event listener can be registered using selection.on(type[, listener[, capture]]) API. As it is documented here:

https://github.com/mbostock/d3/wiki/Selections#wiki-on

However, I cannot find a list of event types that d3 supports. Now I know there are 'click' event, 'mouseover' event and 'mouseout' event. What else does it support?

Thanks a lot.

Upvotes: 5

Views: 9031

Answers (1)

AmeliaBR
AmeliaBR

Reputation: 27544

D3 supports any Javascript event in the on method -- including custom events created by other code.

The MDN Event Reference is a good list of types of events that will be created by the browser.

Pay attention to which types of DOM objects can respond to which types of events, though. The element within the d3 selection has to receive the event for the D3 on method to be able to react to it.

Also be aware that for some complex types of user interaction, like dragging, it is easier to use a d3 behavior object, which monitors multiple system events, both mouse movements and touch screen movements, and creates custom events that you can then react to.

Upvotes: 9

Related Questions