Skip to content
This repository
Browse code

Add deltaX/Y to touch events as well (pointermove/drag)

  • Loading branch information...
commit 5042e78bacc978b52102e0896590dc765293679b 1 parent daaac99
David Aurelio davidaurelio authored

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. +7 0 src/renderer/svg/svg_event_handlers.js
7 src/renderer/svg/svg_event_handlers.js
@@ -85,6 +85,8 @@ define([
85 85 case 'touchmove':
86 86 event.diffX = clientX - touchData.startX;
87 87 event.diffY = clientY - touchData.startY;
  88 + event.deltaX = clientX - touchData.lastX;
  89 + event.deltaY = clientY - touchData.lastY;
88 90 touchData.touchMoveHappened = true;
89 91 event = cloneBasicEvent(event);
90 92 event.type = prefix + 'drag';
@@ -107,6 +109,7 @@ define([
107 109 event.type = 'click';
108 110 this.emit('userevent', event, targetId);
109 111 }
  112 + break;
110 113 }
111 114 },
112 115
@@ -136,6 +139,10 @@ define([
136 139 if (i === 0) {
137 140 this.handleSingleTouch(touch, singleTouchData, false);
138 141 }
  142 +
  143 + // set lastX/Y at the very end -- touches might be handled to handleSingleTouch multiple times
  144 + singleTouchData.lastX = touch.clientX;
  145 + singleTouchData.lastY = touch.clientY;
139 146 }
140 147 }
141 148

0 comments on commit 5042e78

Please sign in to comment.
Something went wrong with that request. Please try again.