Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/browser/scrollable/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ export class Gesture extends Disposable {
const evt = this._newGestureEvent(EventType.CHANGE);
evt.translationX = deltaPosX;
evt.translationY = deltaPosY;
// Carry the extrapolated position on inertia frames. Real touchmove
// CHANGE events (_handleTouchMove) always stamp coordinates and
// consumers like the mouse-report wheel path read event.clientX/clientY.
// Without these, momentum frames yield NaN coordinates (undefined
// arithmetic), which ends up serialized into mouse reports.
evt.pageX = x + deltaPosX;
evt.pageY = y + deltaPosY;
evt.clientX = x + deltaPosX - targetWindow.scrollX;
evt.clientY = y + deltaPosY - targetWindow.scrollY;
dispatchTo.forEach(d => d.dispatchEvent(evt));

if (!stopped) {
Expand Down
9 changes: 9 additions & 0 deletions src/browser/services/MouseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,15 @@ export class MouseService implements IMouseService {
return;
}

// Wheel reports carry the cell the "wheel" happened over, so a gesture
// event without usable coordinates must not be reported: NaN passes
// through getMouseReportCoords' clamping untouched and ends up serialized
// into the report sequence (e.g. `CSI < 64 ; NaN ; NaN M`), which the
// application then reads as garbage input.
if (!isFinite(e.clientX) || !isFinite(e.clientY)) {
return;
}

this._touchScrollAccumulator -= e.translationY;
const lines = Math.trunc(this._touchScrollAccumulator / cellHeight);
if (lines === 0) {
Expand Down