d3 / d3-drag

Drag and drop SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-drag
ISC License
333 stars 61 forks source link

DragEvent missing event.currentTarget for arrow function node selection #77

Closed ChrisHSandN closed 4 years ago

ChrisHSandN commented 4 years ago

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

mbostock commented 4 years ago

Try event.sourceEvent.currentTarget.