[Webkit-unassigned] [Bug 220194] `PointerEvent.movementX` always 0
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sun Dec 26 01:04:07 PST 2021
https://bugs.webkit.org/show_bug.cgi?id=220194
Lucas Garron <lgarron at chromium.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lgarron at chromium.org
--- Comment #4 from Lucas Garron <lgarron at chromium.org> ---
I'm also running into this issue: `movementX` and `movementY` are not populated on `pointermove` events, regardless of whether they are due to mouse, touch, or Apple Pencil.
When the source is a mouse (on macOS), the values are `0`, because the property access chains up to the `MouseEvent` prototype.
Here's a moderately useful repro:
Hosted: https://garron.net/temp/safari-movementX/
Source:
```html
<div id="log" style="background: #90B8DF; width: 90%; height: 90%">(Waiting for data.)</div>
<script>
window.addEventListener("load", () => {
document.body.addEventListener("pointermove", (e) => {
console.log(e);
document.querySelector("#log").textContent = `{movementX: ${e.movementX}, movementY: ${e.movementY}} at ${Math.round(performance.now()) / 1000}sec`
})
})
</script>
```
As far as I can tell, this is a bit tricky/expensive to polyfill:
- Select the correct X/Y coordinates to track per touch.
- I believe `screenX/screenY` are best, except `screenY` is `undefined` on i[Pad]OS when the event is also used for vertical scrolling‽
- Track the last seen coordinates per `pointerId`.
- Compensate for bugs like `undefined` values, like described above.
- Evict old cached coordinates so we don't end up with an unbounded growing cache and don't accidentally track a "movement" across mouse clicks (which seem to always have the same `pointerId`).
- Attach listeners for `pointerup`, and `pointercancel` and hope that catches every cache eviction event‽ (Does that also need to include `pointerleave` and `pointerout`? That would cause issues for the app I'm currently working on.) Track timestamps and discard touches that are sufficiently old?
By contrast, `movementX` and `movementY` are much more ergonomic and I'd really appreciate being able to use them.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211226/9bf4cb78/attachment-0001.htm>
More information about the webkit-unassigned
mailing list