Touch compatibility mouse events (mousemove before click)
touchmouse-eventsmobilejavascriptvideo-player
A tap on a touchscreen fires compatibility mouse events after the touch events, and mousemove arrives before click. Any UI that reveals something on mousemove and toggles it on click will open and close in the same tap, which reads as "tapping does nothing".
The event order
Recorded on Android Chrome for one tap:
pointerdown, touchstart, pointerup, touchend,
mousemove, <- reveal handler fires here
mousedown, mouseup, click <- toggle handler finds it open and closes it
mouseleave also fires spuriously after a tap.
The fix: timestamp touches
Guard mouse handlers by time since the last touch, not by matchMedia('(hover: none)'), so a touchscreen laptop gets whichever input it was actually used with last:
var lastTouch = 0;
['touchstart', 'touchend'].forEach(function (ev) {
el.addEventListener(ev, function () { lastTouch = Date.now(); },
{ passive: true, capture: true });
});
function realMouse() { return Date.now() - lastTouch > 700; }
el.addEventListener('mousemove', function () { if (realMouse()) show(); });
el.addEventListener('mouseleave', function () { if (realMouse()) hide(); });
Example: the videos player
On videos.jhampton.io (2026-08-15) tapping the picture never brought the controls up. Taps near the bottom seemed to work, by accident: mousemove opened the bar, so the following click landed on the duration text inside the bar, which the toggle ignores. Justin's report, "not just at the bottom near where they are", described the accident exactly.
How it was found
Reading the code, the wiring looked right (the click handler even had a touch branch). What found it was instrumentation: a MutationObserver on the element's class plus capture-phase listeners on every pointer, touch and mouse event showed the class going vp to vp show-ui to vp inside one tap. Instrument early. Headless tests only reproduce this if they dispatch real touch events (Input.dispatchTouchEvent), not element.click().