-
Notifications
You must be signed in to change notification settings - Fork 7
Improve drag and drop to work better inside incremental dom components #3
Comments
Hi [edited]people[/edited], I am using this repo right know, and found that I need to resolve some of these problems, so I will be working on this library for a couple of days 😄 |
Well, I have being trying to plan a rewrite, specially for "Drag and drop needs to receive both drag sources and drop targets in the same place, but they may be rendered by different components.". I have had a look at react-dnd documentation, and these are the main differences with metal-drag-drop:
And, in order to not break everything, this is my proposal:
This could be a template using this behaviour: {template .render}
{call DragDropContext}
<section>
<h1>Here you can drop squares</h1>
{call DropTarget}
{param type: 'square' /}
<div class="my-drop-target"></div>
{/call}
</section>
<section>
<h1>Here you can drop circles</h1>
{call DropTarget}
{param type: 'circle' /}
<div class="my-other-drop-target"></div>
{/call}
</section>
{call .otherTemplateOrComponent}{/call}
{/call}
{/template}
{template .otherTemplateOrComponent}
{foreach $squareOrCircle in $squaresOrCircles}
{call DragSource}
<div class="{$squareOrCircle}"></div>
{/call}
{/foreach}
{/template} With this implementation we can separate the drag process from the elements themselves, and the also can keep DragSources and DropTargets in different parts the DOM tree. There are some problems that I found at the moment of thinking about the API:
So... tell me how it looks please :) /cc @Robert-Frampton |
TLDR: please forget about this for the moment I have spoken with @jbalsas and I think we should leave this batch of changes to the future: it would imply a big rewrite of the library, and with some small patches I could get a similar behaviour (or at least the behaviour I need to implement with metal 😄) I am creating a small example of the interface I want to implement in order to show the issues I am experimenting. |
Hey @p2kmgcl Any update on the example you planned making? It would definitely be helpful. Also, given that we don't want to do a full rewrite at this time, I'm not sure what patches are possible to address the issue of incremental dom interfering with drag elements. It might just come down to writing your components in such a way that the drag elements never get updated by incremental dom, but maybe your example will help clear things up. |
Hi @Robert-Frampton, I opened another issue which the specific behaviour that I need (and there's a code sample too): #7 @pavel-savinov is also working with metal-drag-drop and added another issue a some days ago: #6 |
This drag and drop module works really well on its own, but it's hard to configure it to work well inside incremental dom components. That's because it was created before we decided to use incremental dom in the first place, and so its architecture wasn't ready for it. Some examples of current problems:
I believe that we should rewrite a good part of metal-drag-drop, having it be a component so that it can do its changes on the right elements via incremental dom as well. A good example of an api that achieves that is react-dnd.
This will probably need to be a major version, since the api would change a lot.
The text was updated successfully, but these errors were encountered: