canvas: attempt to poll touch azimuth, altitude and force on iOS that otherwise don't trigger onTouch as expected

This commit is contained in:
jean-emmanuel 2022-10-15 16:27:11 +02:00
parent 796ee2fdc6
commit 7765fb066a
2 changed files with 59 additions and 2 deletions

View file

@ -1,4 +1,6 @@
const Touch = window.Touch || class Touch {}
const iOS = require('../ui/ios')
// const cssTransformCoords = require('./transform-coords')
@ -6,7 +8,7 @@ module.exports = {
fix: function(e) {
return {
var ev = {
target: e.target,
firstTarget: null,
@ -38,6 +40,20 @@ module.exports = {
azimuthAngle: e.azimuthAngle,
touchType: e.touchType
}
if (iOS) {
// iOS-specific event properties
ev.touchType = e.touchType
// iOS-pollable event properties
for (var p of ['altitudeAngle', 'azimuthAngle', 'force']) {
Object.defineProperty(ev, p, {
enumerable: true,
value: ()=>e[p]
})
}
}
return ev
},
normalizeDragEvent: function(event, previousEvent) {