Skip to content

Commit

Permalink
drag().on("init")
Browse files Browse the repository at this point in the history
fixes #67
  • Loading branch information
Fil committed Jun 16, 2020
1 parent 1ed1898 commit d91f021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ The *typenames* is a string containing one or more *typename* separated by white
* `start` - after a new pointer becomes active (on mousedown or touchstart).
* `drag` - after an active pointer moves (on mousemove or touchmove).
* `end` - after an active pointer becomes inactive (on mouseup, touchend or touchcancel).
* `init` - when the drag behavior is applied.

See [*dispatch*.on](https://github.com/d3/d3-dispatch#dispatch_on) for more.

Expand Down
9 changes: 8 additions & 1 deletion src/drag.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function() {
subject = defaultSubject,
touchable = defaultTouchable,
gestures = {},
listeners = dispatch("start", "drag", "end"),
listeners = dispatch("start", "drag", "end", "init"),
active = 0,
mousedownx,
mousedowny,
Expand All @@ -45,6 +45,13 @@ export default function() {
.on("touchend.drag touchcancel.drag", touchended)
.style("touch-action", "none")
.style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
selection.each(function(d) {
var that = this;
listeners.call("init", that,
new DragEvent("init", { target: drag, dispatch: listeners }),
d
);
});
}

function mousedowned(event, d) {
Expand Down

0 comments on commit d91f021

Please sign in to comment.