Skip to content
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

Inconsistency in dragover event timing information #36689

Open
AlnisS opened this issue Nov 7, 2024 · 0 comments
Open

Inconsistency in dragover event timing information #36689

AlnisS opened this issue Nov 7, 2024 · 0 comments
Labels
Content:WebAPI Web API docs goal: consistency (Experimental label) Issues about inconsistent/conflicting/contradictory content. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@AlnisS
Copy link

AlnisS commented Nov 7, 2024

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/DragEvent

What specific section or headline is this issue about?

Event Types | dragover

What information was incorrect, unhelpful, or incomplete?

In the DragEvent page, the ondragover event timing is written as "50 ms [or sometimes 1-5 ms]":
https://developer.mozilla.org/en-US/docs/Web/API/DragEvent

dragover
This event is fired continuously when an element or text selection is being dragged and the mouse pointer is over a valid drop target (every 50 ms WHEN mouse is not moving ELSE much faster between 5 ms (slow movement) and 1ms (fast movement) approximately. This firing pattern is different than mouseover ).

In the dragover event page, the timing is written as "every few hundred milliseconds":
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dragover_event

The dragover event is fired when an element or text selection is being dragged over a valid drop target (every few hundred milliseconds).

In the HTML Drag and Drop API page, the timing is written as "every few hundred milliseconds":
https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API#drag_events

dragover
...a dragged item is being dragged over a valid drop target, every few hundred milliseconds.

In the whatwg dragover event specification, the event loop is specified to run "every 350ms (±200ms)" with step 3. in the loop being the dragover event firing:
https://html.spec.whatwg.org/multipage/dnd.html#event-dnd-dragover

User agents must, as soon as the drag operation is initiated and every 350ms (±200ms) thereafter for as long as the drag operation is ongoing, queue a task to perform the following steps in sequence:
...
3. If the current target element is a DOM element, then fire a DND event named dragover at this current target element.

This information seems to have been introduced in commit "initial en-us content checkin" in 2020:
https://github.com/mdn/content/blame/5bc689d5fe026fd0cd5e45f50222a07426d04a09/files/en-us/web/api/dragevent/index.md#L45

What did you expect to see?

Same timing information across MDN pages and whatwg spec, or if there is a difference between typical implementations and the whatwg spec, a note about that in the MDN pages.

Do you have any supporting links, references, or citations?

See "What information was incorrect, unhelpful, or incomplete?" section above for inline links to references.

Do you have anything more you want to share?

I did a quick test with the following code (Chrome, Safari, Firefox on macOS; Chrome, Firefox on Linux), and saw values in the range 0...50, with the exception of Firefox on Linux where the event does not fire if the mouse is stationary (this seems like a bug).

let lastDragTime = 0;
document.ondragover = ((e) => {
  console.log(performance.now() - lastDragTime);
  lastDragTime = performance.now();
});

This seems to match closest with the statement "every 50 ms WHEN mouse is not moving ELSE much faster between 5 ms (slow movement) and 1ms (fast movement) approximately" found in https://developer.mozilla.org/en-US/docs/Web/API/DragEvent

Based on this test information, I think it would make most sense to update the information in the dragover event page to match the note in the DragEvent page, and to add an additional note that typical browser timing behavior is different from the spec. However, I would really like some extra eyes on whether I read the spec correctly, since I could be interpreting it wrong.

Thank you!

MDN metadata

Page report details
@AlnisS AlnisS added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Nov 7, 2024
@github-actions github-actions bot added the Content:WebAPI Web API docs label Nov 7, 2024
@caugner caugner added the goal: consistency (Experimental label) Issues about inconsistent/conflicting/contradictory content. label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs goal: consistency (Experimental label) Issues about inconsistent/conflicting/contradictory content. needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

No branches or pull requests

2 participants