6

I have a canvas with a background picture. I would like to have objects (buttons or divs) that can move over the canvas.

I have found the perfect solution with interact.js. The first example on the page (called Dragging) is exactly what I'd like to achieve. Get the position over the canvas and if the object is moved outside, it goes back inside automatically.

However, I'm already using dragula to sort items and would like to keep only one library for drag and drop functions. Adding another library would add more complexity to my webapp.

Is it "easy" to achieve that with dragula? If yes, how?

A code example is needed in order to understand how.

yurzui
  • 171,085
  • 24
  • 365
  • 354
ncohen
  • 6,184
  • 19
  • 61
  • 112

1 Answers1

2

I had a similar requirement, where the left side items, turned into a sticky note on the right side. These sticky notes needed to be moved around.

After much thought, I devised a very simple solution. I created 4 seperate dropzones on the right side, which basically allows the notes to be moved around.

This ensures sorting as well as dragging functionality.

Reference video: https://youtu.be/_jsM1kn6nBk

user3382203
  • 171
  • 1
  • 4
  • 24