Reputation: 33
Is it possible to create drag and drop events on SVG Paths using Javascript?
I am making a simple map where the areas are svg paths and I would like to run a code when I drop a draggable marker into the areas.
Upvotes: 3
Views: 335
Reputation: 1337
Yes, but if I were you would find something that does the job for you. Something like d3 drag behavior https://github.com/mbostock/d3/wiki/Drag-Behavior
If you don't want to learn a new technology, then you will have to listen on mousedown, mousemove, mouseup. On mousedown you set a global flag that tells mousemove that there is a drag interaction, and that tells mouseup that drag interaction is finished.
Upvotes: 2