3 ms·
one of the gripes about the specification was the fact that you had to turn off default behaviour of some events. While I agree that this might sound strange a
by pilif 17y ago
one of the gripes about the specification was the fact that you had to turn off default behaviour of some events.
While I agree that this might sound strange at first, if the default behaviour was to allow drag per default, how exactly would you select content in a webpage?
There needs to be some kind of toggle to enable or disable the beginning of a dragging operation. While there is this attribute in Mozilla (and a CSS style in Safari), right now, the formalized way to enable dragging is to disable the default operation (which is starting the text selection process).
I don't think this is such a problem.
Maybe I'll come back later and comment on other parts of this rant.
- tolmasky 17y agoIf only it were that easy. As it turns out, default behavior is sometimes to drag (as when you have already selected text). In my experiments this business of preventing default became quite frustrating, as sometimes you want to stop drags but not selection, or vice versa, but end up stopping both. The correct way to do this is to allow the programmer to start a drag. As it stands, it is impossible to do things such as only allow vertical drags and not horizontal drags since the API is completely declarative and takes place on an element-by-element basis.
- daleharvey 17y agoit seems sensible that "text selection" is default behaviour which is overridden when you add a drag event, as opposed to having to manually disable things. I wish the text selection tools were more powerful in css/js as well, its reasonably problematic to make text unselectable.
- pilif 17y agothat was exactly my point. If these events had "permit the drag & drop operation" as their default action, selecting text would be impossible.
- daleharvey 17y agothats a different point, being able to drag something (currently disabling text select events) doesnt mean text isnt selectable, if you drag over and entire page the text is still selected. its especially annoying if you have to support shift + arrow keyboard shortcuts.
- pilif 17y agoif the default action of these drag & drop events was to enable drag & drop, then you would not be able to select anything on the page (using the mouse that is), because, wherever you push the button down and move the mouse, you will initiate a drag operation and not a select operation. This is why drag & drop is disabled by default and the method in which it is disabled is by making the events fire but have their default action to not allow drag & drop which then leads to the selection action being used.
- wvenable 17y agoIsn't this solved by the "draggable" attribute? Why work at the events-level at all for this.
- pilif 17y agofrom an architecture standpoint, the solution using events is actually cleaner: Instead of having a flag that toggles some events default action, you have override the event default action where you need it changed. If you need the attribute (or even a class="draggable" to achieve your goal without changing the standard), you can use libraries like jQuery. What I'm saying is: * I disagree with the author of the articles assumption that the default event action is wrongly set. If it was the other way around, selection of page elements would not be possible. * The events is what we have in the standard. I would probably prefer the flag aswell, but from a architecture standpoint, using the events is probably much easier to implement. * If I want to have that attribute, I can easily add it to my sites script code using one or two lines of jQuery-code.
- gamache 17y agoThe gripe is not that default behavior exists. The gripe is that, once you have made an element draggable, you need to override a few seemingly-unrelated default behaviors in order to implement the most obvious form of drag-and-drop. Or, more precisely: you need to turn off not one, but two "drag" defaults in order to react to "drop" events.