fix(createDropzone): add support for dragenter event on drag#216
fix(createDropzone): add support for dragenter event on drag#216
Conversation
This event can be used by callers to setup UI with classes or animations when the drag starts.
| element.addEventListener('dragover', dragEvent); | ||
| element.addEventListener('drop', dropEvent); | ||
| asperaSdk.globals.dropZonesCreated.set(elementSelector, [{event: 'dragover', callback: dragEvent}, {event: 'drop', callback: dropEvent}]); | ||
| registeredListeners.forEach(({event, callback: listener}) => { |
There was a problem hiding this comment.
Rather than register listeners by default for each drag drop event type, we can leverage the connectOptions argument, and default to false. I think this would be closer to how it worked in the Connect SDK. Additional events would be an opt-in behavior.
For example:
if (connectOptions?.dragEnter) {
// Register `dragenter` event listener...
}There was a problem hiding this comment.
Thanks mostly I was wondering if connectOptions was still expected to be respected looks like that's the case I can add the logic for all connectOptions options moving forward.
There was a problem hiding this comment.
Also, due to the name, my initial thinking was this is only something affecting connect, but let me know if we are okay with using those params, and I will update the code accordingly.
src/app/core.ts
Outdated
|
|
||
| const dragEnterEvent = (event: DragEvent) => { | ||
| event.preventDefault(); | ||
| callback({event, files: null as unknown as DataTransferResponse}); |
There was a problem hiding this comment.
Should we just change DataTransferResponse.files to be optional? Then callers would be forced to check first and only drop event would actually have the files.
| }; | ||
|
|
||
| const registeredListeners: {event: string; callback: (event: any) => void}[] = [ | ||
| {event: 'dragenter', callback: dragEnterEvent}, |
There was a problem hiding this comment.
Should we also add dragleave? Also not sure if casing matters here.
This event can be used by callers to setup UI with classes or animations when the drag starts. Signed-off-by: Crisoforo Gaspar <3921289+mitogh@users.noreply.github.com>
…spera-sdk-js into fix/add-support-dragenter-event
This event can be used by callers to set up UI with classes or animations when the drag starts, and aligns with Aspera Connect, allowing callers to listen for drag enter event.