From 6b1f782d33d3e945340d43f374199a38c478e932 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 11 Jan 2022 19:00:25 +0100 Subject: [PATCH] canvas: expose additional touch event informations (`radiusX`, `radiusY`, `rotationAngle` and iOS-only `altitudeAngle`, `azimuthAngle` and `touchType`) --- CHANGELOG.md | 2 ++ resources/docs/docs/widgets/canvas.md | 3 +++ src/client/events/utils.js | 10 ++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be849195..544607fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - widgets - renamed `script` to `onValue`, `draw` to `onDraw`, `touch` to `onTouch` - added `onCreate` script property to all widgets + - canvas: expose additional touch event informations (`radiusX`, `radiusY`, `rotationAngle` and iOS-only `altitudeAngle`, `azimuthAngle` and `touchType`) + ## 1.13.2 diff --git a/resources/docs/docs/widgets/canvas.md b/resources/docs/docs/widgets/canvas.md index a1e3af20..abcf21d5 100644 --- a/resources/docs/docs/widgets/canvas.md +++ b/resources/docs/docs/widgets/canvas.md @@ -45,6 +45,9 @@ This script has access to the same variables and functions as the `script` prope - `pointerId`: unique identifier used to differenciate fingers in multitouch situation - `altKey`, `ctrlKey`, `shiftKey`: keyboard modifier states - `force`: amount of pressure applied to the touch surface between `0` and `1` (see [Touch.force](https://developer.mozilla.org/en-US/docs/Web/API/Touch/force)). Equals `0` if the API is not supported or if no pressure information is found. + - `radiusX`, `radiusY`, `rotationAngle`: see [Touch.rotationAngle](https://developer.mozilla.org/en-US/docs/Web/API/Touch/rotationAngle) + - (iOS only) `altitudeAngle`, `azimuthAngle`: see [Touch.altitudeAngle](https://w3c.github.io/touch-events/#dom-touch-altitudeangle) + - (iOS only) `touchType`: "direct" or "stylus" !!! note "Extra html elements" diff --git a/src/client/events/utils.js b/src/client/events/utils.js index 35d4355c..d8cb5eba 100644 --- a/src/client/events/utils.js +++ b/src/client/events/utils.js @@ -29,8 +29,14 @@ module.exports = { traversingStack: e.traversingStack, multitouch: e.multitouch, isTouch: e instanceof Touch, - force: e.webkitForce || e.force || 0 - + force: e.webkitForce || e.force || 0, + radiusX: e.radiusX, + radiusY: e.radiusY, + rotationAngle: e.rotationAngle, + // iOS only + altitudeAngle: e.altitudeAngle, + azimuthAngle: e.azimuthAngle, + touchType: e.touchType } },