4 ms·
This is from 5 years ago.
by onion2k 12y ago
This is from 5 years ago.
- striking 12y agoUpdated the title to reflect that, thanks. Really makes you wonder though; why hasn't HTML5 Drag and Drop been simplified yet? I personally have no idea what to do, besides adding JQuery.
- dubcanada 12y agoIt has been, lots of things have been added since 2009 to fix most of his problems.
- striking 12y agoI wasn't aware of this. Do you have any reading material I could look at (as I'm attempting to implement DnD in an app of my own right now)?
- jvickers 12y agoI've done some drag and drop programming, but not using the HTML5 API. I may have read that article quite a few years ago, but another problem was that HTML5 was not considered ready for use all those years ago. Recently (well, within the past year or so) I have found clients' requirements have been far less strict in terms of supporting older browsers, so I have been making use of more HTML5 features. I still have not used HTML5 drag-and-drop. The basics of drag-and-drop only take a few lines to implement, but it's important to do extensive testing to find the edge cases. I found (one year ago) there were problems with jQuery UI that stopped me from making full use of it. I wound up using it for the basic dragging - it would reliably tell me mouse move events, clicks, buttons, and the mouse position, but because the droppables system would miss some events I implemented the logic surrounding detecting where the item was being dragged. Basically, whenever the item got moved, a whole bunch of calculations would run to see what object it's positioned over or near, and it's position within whatever object it's over. If you want to do drag-and-drop programming in the browser, I recommend you write some code that allows you to pick up a DIV and drop it elsewhere on the screen. It's not trivial to do the first time, but once you understand the patterns it becomes so much easier. The techniques are useful for other similar things, like creating resize handles.
- striking 12y agoDo you have any code samples I could look at for reference? I'm quite new to the whole HTML/CSS thing, and I work best learning by example.
- jvickers 12y agoIf I did write a code sample and replied here, would you get to see it? I don't think there is a way to send messages on Hacker News, and I don't yet know if you'll get alerted to replies to old posts.
- aikah 12y agowhat he says is still valid,the spec hasnt changed,is broken even or recent browsers such as Chrome ,is complicated and confusing.It's another exemple of half baked spec written by people that are never going to use it,just like app cache. Frankly HTML5 is a disaster(and no , things like WebWorkers or WebSockets are not part of the HTML5 spec before anyone jumps on me). It's just hard to build something robust on weak foundations,but that's lot of client side developpers, making these things work even though specs are just not helping.
- shacharz 12y agoYou're right, but that's the reason I think all browsers have developer channels. So that developers who actually user those API's will test them, report bugs or even stir the specs towards something useful. I know that's the case at least with WebRTC.
- thristian 12y agoI don't think it's fair to blame the HTML5 drag and drop API entirely on WHATWG; my understanding is that it was originally specced years ago as the sanest useful subset of IE6's drag and drop API. It may not be the prettiest thing ever, but it's prettier than how it started out.
- panzi 12y agoSubset? Isn't it more like a super set? IE6 (and above) has no files array that can be read with a FileReader and it only supports the types "Text" and "URL", no support for proper mime types.
- thristian 12y agoI think this is what I was remembering: http://ln.hixie.ch/?start=1115899732&count=1 http://ln.hixie.ch/?start=1115899732&count=1 ...which is to say, IE6 supported more event types and more configurable behaviour than HTML5 supports, but some of those extra features were just too weird, or outright crashed IE, so they didn't make it into the spec.