craft.js icon indicating copy to clipboard operation
craft.js copied to clipboard

feat: add events.draggedOver

Open ankri opened this issue 3 years ago • 6 comments

Hi there,

PR #186 is long overdue but I couldn't get it to run because of some stupid git merge conflicts. So here we go again.

Here is the old text: This PR adds draggedOver to the events. It's almost the same as #37 but targets the next branch and the new EventHandlers, which also gives us a cleaner API. (#37 will be obsolete - #186 will also be obsolete ).

Since the new EventHandlers introduced a Set as the store for the EventHandlers, we can now store not only the id of the node we are dragging over, but all of its ancestors, too.

I also updated the Basic example with two different examples on how to make use of the new API.

Closes #28 Closes #183

Supersedes #186 Supersedes #37

ankri avatar Feb 09 '22 15:02 ankri

✔️ Deploy Preview for craftjs ready!

🔨 Explore the source changes: a174c48e334d370fde591e5cbe4937b38cdf1e1e

🔍 Inspect the deploy log: https://app.netlify.com/sites/craftjs/deploys/6203dbb1a072fc0007fc3832

😎 Browse the preview: https://deploy-preview-374--craftjs.netlify.app

netlify[bot] avatar Feb 09 '22 15:02 netlify[bot]

Screenshot 2022-02-11 at 1 28 21 AM

I wonder how useful it is to know all the nodes that's currently being dragged over; or would it be more useful to just know which parent node is the drop indicator being positioned at (which seems like the intention of this PR?)

prevwong avatar Feb 10 '22 17:02 prevwong

I wonder how useful it is to know all the nodes that's currently being dragged over; or would it be more useful to just know which parent node is the drop indicator being positioned at (which seems like the intention of this PR?)

I see your point. On your screenshot, the mousepointer (albeit not visible) is hovering over the <Card /> element, which results in it being higlighted as draggedOver. However, because the drop indicator is positioned below the <Card />, the Card should not be probably highlighted.

I personally would expect the draggedOver behave as "Is drop indicator inside me (or inside some of my children)". If that passes, we should also rename it to something like "containsDropIndicator" or "isDropTarget", which is more descriptive of what actually happens, and it also avoids confusion with how the native dragOver event behaves.

lost-valley avatar Mar 30 '22 14:03 lost-valley

Assuming the goal is to highlight the container into which the dragged component will be dropped, then what do you think about this approach? In my simple test scenario it seems to work fine.

image

lost-valley avatar Mar 30 '22 21:03 lost-valley

Any updates on this?

longergrass avatar Jul 06 '22 01:07 longergrass

Would love to have this too!

mattvb91 avatar Aug 19 '22 14:08 mattvb91

Any progress to use the draggedOver?

geohuz avatar May 03 '23 09:05 geohuz

Closing due to no time available

ankri avatar Feb 19 '24 08:02 ankri