diff --git a/src/handlers.js b/src/handlers.js index af7c152..b4289bf 100644 --- a/src/handlers.js +++ b/src/handlers.js @@ -234,19 +234,22 @@ class Handlers { // `pointermove` and `mousemove` event handler handlePointerMove(event) { + let events = []; if (this._captureCoalescedEvents && event.getCoalescedEvents) { - event.getCoalescedEvents().forEach((coalescedEvent) => { - this.handleSinglePointerMove(coalescedEvent); - }); - } else { - this.handleSinglePointerMove(event); + events = event.getCoalescedEvents(); + } + if (events.length === 0) { + events = [event]; } + events.forEach((coalescedEvent, index) => { + this.handleSinglePointerMove(coalescedEvent, index !== events.length - 1); + }); } - handleSinglePointerMove(event) { + handleSinglePointerMove(event, coalesced) { switch (event.pointerType) { case 'mouse': - this.handleMouseMove(event); + this.handleMouseMove(event, coalesced); break; case 'touch': this.push( @@ -255,6 +258,7 @@ class Handlers { event.pointerId, event.screenX, event.screenY, + coalesced ? 1 : 0, ); break; default: @@ -303,13 +307,14 @@ class Handlers { } // `mousemove` event handler - handleMouseMove(event) { + handleMouseMove(event, coalesced) { this.push( MOUSE_MOVE_MESSAGE_TYPE, TimeUtils.convertEventTimeToTs(event.timeStamp), event.screenX, event.screenY, event.buttons, + coalesced ? 1 : 0, ); } @@ -359,6 +364,7 @@ class Handlers { touch.identifier, touch.screenX, touch.screenY, + false, ); }); } diff --git a/test/trap.pointer-events.test.js b/test/trap.pointer-events.test.js index a43798b..57a5093 100644 --- a/test/trap.pointer-events.test.js +++ b/test/trap.pointer-events.test.js @@ -177,6 +177,7 @@ describe('browser with pointer events', () => { 1, 2, 0, + 1, ]); expect(moveEvents[1]) @@ -186,6 +187,7 @@ describe('browser with pointer events', () => { 3, 4, 0, + 0, ]); }); @@ -217,6 +219,7 @@ describe('browser with pointer events', () => { 3, 4, 0, + 0, ]); });