d3 / d3-drag

Drag and drop SVG, HTML or Canvas using mouse or touch input.

Home Page:https://d3js.org/d3-drag

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DragEvent missing event.currentTarget for arrow function node selection

ChrisHSandN opened this issue · comments

d3.drag().subject(), d3.drag().on() etc. used to be passed datum, i, nodes allowing the current node to be accessed from within an arrow function.

// v5
d3
  .drag()
  .subject((datum, i, nodes) => {
    d3.select(nodes[i]);
  })

Now it has swapped to only the DragEvent object there doesn't seem to be any way to access the node anymore without using this?

// v6
d3
  .drag()
  .subject((event) => {
    d3.select(???);
  })

d3.selection.on() has the event.currentTarget which would be useful/consitent for drag().*().

d3: v.6.2.0

Try event.sourceEvent.currentTarget.