Draggable svg elements

I installed

on my SVG and am trying capture the x & y coordinate of the moved element to be output to the console, can this even be done?

Sure it can. console.log the element’s x and y position, at the end of the drag, before you tell the code to forget what element you’re dragging around.

1 Like

I uploaded the example and tried to see if I can get the x/y coordinates of the elements if I drag them, am I on the right track here?


Well, what happens in the console when you move something?

when I drag an element, it shows

start X: 993
start Y: 74
end X: 1018
end Y: 124

But isnt that some other coordinates (page?) and arent I looking for ones inside the viewbox of the SVG

viewBox="0 0 30 20"

so shouldnt the x & ys be within that space?

did you try to put it into var?

Hi @lurtnowski, did you have a look at the section about getting the coordinates in the article from your OP?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.