taye / interact.js

JavaScript drag and drop, resizing and multi-touch gestures with inertia and snapping for modern browsers (and also IE9+)

Home Page:http://interactjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: Cannot read properties of undefined (reading 'pageX') with gesturable and inertia

stalb opened this issue · comments

If I have a gesturable with inertia enabled, after some interactions gesturable actions stop working with:
Uncaught TypeError: Cannot read properties of undefined (reading 'pageX') error.

Expected behavior

Gesturable interactions should work without error when inertia is enabled.

Actual behavior

After several interactions gesturable interactions stop working on Chrome with the following error:
Uncaught TypeError: Cannot read properties of undefined (reading 'pageX')

Chrome stack trace:

pointerUtils.ts:184 Uncaught TypeError: Cannot read properties of undefined (reading 'pageX')
    at X.touchDistance (pointerUtils.ts:184:44)
    at yt (plugin.ts:145:36)
    at t.value (scope.ts:137:25)
    at e.scopeFire [as _scopeFire] (interactions.ts:105:48)
    at s.value (Interaction.ts:613:10)
    at s.value (Interaction.ts:380:10)
    at t.value (plugin.ts:247:19)
    at plugin.ts:192:33
    at plugin.ts:209:9
X.touchDistance @ pointerUtils.ts:184
yt @ plugin.ts:145
value @ scope.ts:137
e.scopeFire @ interactions.ts:105
value @ Interaction.ts:613
value @ Interaction.ts:380
value @ plugin.ts:247
(anonymous) @ plugin.ts:192
(anonymous) @ plugin.ts:209
requestAnimationFrame (async)
request @ raf.ts:41
value @ plugin.ts:207
value @ plugin.ts:192
value @ plugin.ts:129
interactions:before-action-end @ plugin.ts:333
value @ scope.ts:137
e.scopeFire @ interactions.ts:105
value @ Interaction.ts:605
value @ Interaction.ts:442
value @ Interaction.ts:405
(anonymous) @ interactions.ts:212

With firefox the error message is different, but the stack trace is similar

System configuration

interact.js version: 1.10.17
Browser name and version: Chrome 110.0.5481.104 (64 bits) / Firefox 110.0 (64 bits)
Operating System: windows 10

Minimal example to reproduce the problem:

looks like #251 and #457

The bug seems to have been introduced with version v1.8.5.

Same problem on last version 1.10.21, I tried to search in the sources, but I couldn't identify the cause.
Test on Chrome v119 and Firefox v119

Here's an example:
https://codepen.io/Vincent_mgd/pen/gOqepqV

As a workaround you can remove inertia. for gesturables.
In my app, the added value of inertia on gesturables was low.

Thank you, that's what I did.
But for my project, I wanted to use the inertia plugin.

I searched a bit:
during a gesturable event (dual touch), updateGestureProps() in plugin.ts receives a pointers with only a single touch, and so touchDistance() which is then called in pointerUtils.ts falls on an undefined in touches[1]