Fixed touch input it will now serialize the touchlist (#4406)
* fixed branch * serializeTouchEvent fix
This commit is contained in:
1 parent
727752a965
commit
93147587b8
3 files changed
+26
-5
No files matched your search
@@ -222,9 +222,9 @@ function serializeTouchEvent(event: TouchEvent): SerializedEvent {
|
||||
ctrl_key: event.ctrlKey,
|
||||
meta_key: event.metaKey,
|
||||
shift_key: event.shiftKey,
|
||||
changed_touches: event.changedTouches,
|
||||
target_touches: event.targetTouches,
|
||||
touches: event.touches,
|
||||
changed_touches: serializeTouchList(event.changedTouches),
|
||||
target_touches: serializeTouchList(event.targetTouches),
|
||||
touches: serializeTouchList(event.touches),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -255,6 +255,27 @@ function serializePointerEvent(event: PointerEvent): SerializedEvent {
|
||||
};
|
||||
}
|
||||
|
||||
function serializeTouchList(touchList: TouchList) {
|
||||
const serializedTouches = [];
|
||||
for (let i = 0; i < touchList.length; i++) {
|
||||
const touch = touchList[i];
|
||||
serializedTouches.push({
|
||||
identifier: touch.identifier,
|
||||
client_x: touch.clientX,
|
||||
client_y: touch.clientY,
|
||||
page_x: touch.pageX,
|
||||
page_y: touch.pageY,
|
||||
screen_x: touch.screenX,
|
||||
screen_y: touch.screenY,
|
||||
radius_x: (touch as any).radiusX,
|
||||
radius_y: (touch as any).radiusY,
|
||||
rotation_angle: (touch as any).rotationAngle,
|
||||
force: (touch as any).force,
|
||||
});
|
||||
}
|
||||
return serializedTouches;
|
||||
}
|
||||
|
||||
function serializeMouseEvent(event: MouseEvent): SerializedEvent {
|
||||
return {
|
||||
alt_key: event.altKey,
|
||||
|
||||
Reference in new issue
Block a user