Closed kerem0comert closed 1 month ago
It's a simplified example. I would not use event.dataTransfer.setData
but use a store / local state for that. I will move this issue to the web repo to remind us that we need to ~add a note to~ update the dnd examples ~about this~.
You would not use on:dragstart
for the SvelteFlow
component, but for the things you want to drag to the SvelteFlow
componemt (where on:drop
is implemented).
Alright, then I will implement it using a store.
You would not use on:dragstart for the SvelteFlow component, but for the things you want to drag to the SvelteFlow componemt (where on:drop is implemented).
I don't understand exactly what you mean here, though. I am using it at the same level as on:drop
, on my SvelteFlow
component. My expectation is that whenever I start dragging a node from my palette (that is outside my SvelteFlow
component), as soon as that node enters the area of the SvelteFlow
component the on:dragstart
event would fire. As soon as the user drops the node into the component on:drop
would get fired (and in fact on:drop
does work this way). Is my understanding of on:dragstart
not correct, could you elaborate?
on:dragstart
is used for the draggable element (side bar node) and not for the drop zone (SvelteFlow pane).
Right, now I see what you mean. Thanks!
closed by #466
Please describe the feature that you want to propose
I have implemented a Palette of different nodes using the provided example in Drag and Drop and this works well.
The crucial bit in this structure is of course the
type
data set withconst type = event.dataTransfer.setData('application/svelteflow', nodeType);
fromSidebar.svelte
and read withconst type = event.dataTransfer.getData('application/svelteflow');
inFlow.svelte
which lets us deduce the type of the node currently being dragged and dropped.However, I also need access to this
type
variable eitheron:dragstart
or while the drag is being made (on:dragover
), and either is ok for me.The problem is:
on:dragover
: Whileevent.dataTransfer.dropEffect = 'move
is available, and I can see that thetype
data should also be available, as when I debug in theonDragOver
event, I see theevent
object available as:but still
event.dataTransfer.getData(application/svelteflow)
returns empty string (''
).My understanding is that this data not being available in the
on:dragover
event is an intentional result of theDnD
specification. Is this correct, or is there a way to make this data available in this event?on:dragstart
: While it is also enough for me to be able to receive thistype
dataon:dragstart
, this event just does not fire for me, in SvelteFlow version:0.1.14
. MyFlow
component looks as follows, and all the other events that I defined there fire, apart fromon:dragstart
I assume events like
on:nodedragstart
do not help either, as they are fired when a given node is dragged from within the canvas, rather than a drag start from an outside Palette.