I am trying to build an Angular (v17) application which lets the user to move around with drag and drop HTML elements, even between multiple browser tabs. Similarly to what neo.mjs is capable of (here is a demo: https://www.youtube.com/watch?v=-L43hntj3jk).
I am currently using Material cdDrag, and thinking of writing a custom Angular shared web worker for this but it will be quite difficult if even possible.
Is there an easier way, or even a 3rd party package with which I could achieve this? Or could I somehow implement neo.mjs into my Angular application?
The project has to be Angular (client request).
2
Answers
It’s not that complicated. In this example I have a draggable
<li>
element and an iframe (the iframe is just to show that you can drag from one document to another). In the parent document, ondragstart
I set data on the dataTransfer object to the HTML code being dragged (the<li>
element). In the iframe there are handlers for bothdragover
anddrop
. When you drop the<li>
the HTML will be added to the<ul>
in the iframe. Below is the HTML for the iframe.You can try to open the iframe document (the data URI string) in a separate tab, and test if you can drag the
<li>
from the example here to that tab.Iframe document:
by using this third party package we are able to do drag and drop in between the tabs
we could intiate the drag drop and dragend
interact.service.ts
drag-drop.component.ts