Skip to content
Advertisement

How to programmatically trigger a D3 drag event?

So i have some data binded with drag event listeners :

JavaScript

Now I want to call this onDrag function on a certain node programmatically. I do know the same is possible with standard events by doing

JavaScript

Is there any way to do so ? Thanks.

Advertisement

Answer

Save the callback (the one you pass into the drag handler) in a variable and then call this variable in your other context.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement