logoalt Hacker News

adastra22 • yesterday at 10:43 PM • 5 replies • view on HN

Dumb question: why? It’s been a long time since I touched GUI code, but I thought it gave you a message with the URI to the file. How is this significantly different than file-open?


Replies

gavinray • yesterday at 11:53 PM

This was circa 2010 or so, and it was a web app. So pre-ES6 JavaScript, before React.

Nowadays you would just "npm install drag-and-drop" but back then you often had to hand-roll solutions.

If anyone can dig up an ancient library on GitHub for drag-and-drop back in those days, I'd imagine it would be several thousand lines long, not to mention the absolute nightmare that testing something like this with a proper framework and accompanying testing library.

➕ show 2 replies
sn0wleppard • today at 10:06 AM

Dragging UI items around on a page is very different problem to dragging an external file onto a page

ehnto • today at 1:46 AM

I built a drag and drop content CMS/website builder in native Javascript years ago. The browser APIs are really cumbersome. The other issue is more UX than technical, there are lots of questions to answer. What are you dragging, what is it hovering over actually, what is the intention once it's dropped etc.

hdjrudni • today at 6:05 AM

Drag-and-dropping a file directly on the HTML `<input type="file">` file picker works with no code/JS.

If you want to splash up the "drop here" thing it's a frickin nightmare. The events don't fire when they should (e.g. mouse leave doesn't fire so it gets stuck, or you get duplicate events or missing events) so you get a bunch of flicker unless you do a bunch of debouncing and fail safes to cover all the browser quirkiness. And this is the easy drop-a-file scenario.

Doing all the stuff shown in https://www.youtube.com/watch?v=l7v-UwpsEbk I'm not sure I'd even know where to begin.

mcculley • yesterday at 10:50 PM

There are more possible actions than opening files.