-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
ondragstart: convert static example to live example #15318
ondragstart: convert static example to live example #15318
Conversation
fixes portion of mdn#11364
Preview URLsFlawsURL:
External URLsURL: No new external URLs (this comment was updated 2022-04-27 06:11:51.862194) |
@@ -16,7 +16,7 @@ A {{domxref("GlobalEventHandlers","global event handler")}} for the | |||
## Syntax | |||
|
|||
```js | |||
var dragstartHandler = targetElement.ondragstart; | |||
targetElement.ondragstart = dragstartHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a better model to copy would be this one: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick#syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @AnilSeervi but I would literally copy the structure, using value rather than return type - so it would look like this
Excellent! I'd fix up the syntax section but otherwise this is much better. |
Co-authored-by: Hamish Willee <[email protected]>
Select this element, drag it to the Drop Zone and then release the selection to move the element. | ||
</p> | ||
</div> | ||
<div id="target">Drop Zone</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<div id="target">Drop Zone</div> | |
<div id="destination">Drop Zone</div> |
As we are on an event page, the 'target' and 'event.target' can become source of confusion.
Also, in syntax section we used target.ondragstart
but in code we say source.ondragstart
. Are we calling draggable elements 'target' or 'source'? In the code we can not use target.ondragstart
cos we are calling destination "target" here.
|
||
// Set handlers for the source's drag - start/enter/leave/end events | ||
source.ondragstart = dragstart_handler; | ||
source.ondragenter = dragenter_handler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source.ondragenter = dragenter_handler; | |
target.ondragenter = dragenter_handler; |
I think these(also ondragleave) should be registered on drop target[ref]. On drag leave the target
element is not resetting to white color from lightblue. There is no need to indicate that the draggable is on source element itself.
@hamishwillee and @teoli2003, are we treating these pages as event pages or as property pages(cos they look like a property Which tags are applicable to this page or such pages?
|
@OnkarRuikar I think all of these should "eventually" be event pages. However as the fix was to an old-style property page, I commented on the fix in that context. We certainly shouldn't block the fix here on converting to something else. |
I agree. Sorry for the miscommunication. I asked this in context of updating all the pages to modern structure. Like it's being done in #15335 (Update Method pages to modern structure) PR series. Once we fix the structure it can be done in one go. Regarding this PR I think we need to put Also, there is a bug that the destination element doesn't change back to original color(from lightblue) when dragged item leaves the destination element. |
fwiw, I'm still working on event pages. Last week I finished Updates to the example sections are great, so I appreciate this PR. Structurally we agreed that |
Thanks all. @AnilSeervi So the direction to you is to look at this suggestion by Onkar #15318 (comment) starting with "Regarding this PR I think we need to put ondragenter and ondragleave handlers on the destination element(target) and ..." If/once that is OK we'll ignore any other issues and get this in. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the colors and events are applied correctly now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OnkarRuikar This looks good to me, but probably best if you review the changes you requested ....
@hamishwillee Looks good to me too. |
Thanks @AnilSeervi - much much better :-) |
Summary
ondragstart: convert static example to live example
Motivation
Open-source
Supporting details
Related issues
fixes portion of #11364
Metadata