-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support for file drag & drop events #2346
base: master
Are you sure you want to change the base?
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8f13a9a:
|
Would it also be possible to implement other drop events like |
@haywirez is there a test or a sandbox somewhere? and if it's really as easy as adding the events, what speaks against adding them all like @FarazzShaikh said? also, how are meshes marked as draggable? on the dom isn't is something like |
@drcmda definitely not ready for merging yet, this needs more work & investigation... This PR is not about draggable meshes - it's for when you drag files onto the canvas from a file explorer / outside the browser. I'm trying to enable tracking intersections for the drop target meshes e.g. highlighting them or accepting or rejecting dragged files whether they are dropped onto a particular mesh. In case of dragging from outside the browser, pointer events do not fire as the window is not in focus. The only event which does is From MDN:
|
IMO this PR should not be trying to replicate the abilities of something like |
(note to self...) We will definitely need an There's a lot of work to be done in packages/fiber/src/core/events.ts#L404 |
1b7f27c
to
8d7f5da
Compare
OK this seems to work now but please double check for any obvious misses. Added a test + an example: I opted to name the handler props still WIP: handling |
8d7f5da
to
d8cd48f
Compare
d8cd48f
to
975c698
Compare
Amaze! If the "ESC to cancle" is implimented on the regular HTML drop events then i think we should impliment it here too. Else best to leave it in userland. |
6bc986c
to
f42b7c7
Compare
Apart from the usual canvas dragenter & dragleave, this commits adds special handlers: onDragOverEnter, onDragOverLeave & onDragOverMissed. These are fired when dragover events intersect with objects in a scene or miss all of them, similar to how onPointerMissed already works. onDrop and onDropMissed are other additions. These can come handy when working on editor UIs etc. that need to attribute different drag & drop actions to different objects.
f42b7c7
to
ec958d9
Compare
hey @haywirez what's the state, is it out of draft stage? can we merge? |
It's missing a fancier example (right now it only logs to console on drag & drop events). but as i recall it's rather done. could rebase + merge if you think that's ok enough. can prepare a fancy demo later 😝 |
yes please, the demo isn't so important, it could be something very lame. dressing up a cube with a texture -> done. |
Note: this is a WIP, the test is failing for some reason.
This PR is about dragging files onto the canvas from a file explorer / outside the browser. I'm trying to enable tracking intersections for the drop target meshes e.g. highlighting them or accepting or rejecting dragged files whether they are dropped onto a particular mesh. In case of dragging from outside the browser, pointer events do not fire as the window is not in focus. The only event which does is
dragover
, which nevertheless should have the necessary x/y coordinates.