Reputation: 3607
I am using D3.js to drag SVG elements, using concept of D3.js drag. drag is working fine but I want to call a function on dragend. How to do that?
Here is jsFiddle Link. I simply want to call a function on dragend.
Should I try
var drop = d3.behavior.drag()
.on("dragend", function () { alert(); });
Upvotes: 3
Views: 4730
Reputation: 3386
Quick mention if anyone still needs something like this, d3.behaviour
was deprecated as well as dragend
. If you still need the functionality it should look something like this:
d3.drag().on("end", (_event, dimension) => {
console.log("alert ended for : " dimension)
})
(for more informations: https://github.com/d3/d3/blob/master/CHANGES.md#dragging-d3-drag)
Upvotes: 0
Reputation: 61026
You seemed to be trying to do some kind of nested dragging or something, the following should work:
var drag1 = d3.behavior.drag()
.on("drag", dragmove)
.on("dragend", function () { alert("drag ended"); });
Full example: http://jsfiddle.net/xnjGD/
Upvotes: 8