codefrau / SqueakJS

A Squeak Smalltalk VM in Javascript
https://squeak.js.org
MIT License
364 stars 75 forks source link

Repair touch event interpretation on Android Firefox. #134

Closed tonyg closed 3 months ago

tonyg commented 2 years ago

This PR fixes a bug using squeak.js.org with current Firefox (98) on Android: when using touch events to simulate mouse interaction, the mouse ends up at 0@0 and never moves away.

Android Firefox (98, probably earlier too) is able to use offsetX/offsetY in mouse events, despite not having "AppleWebKit" in its user agent string. This patch first tries checking for "AppleWebKit", as before, but if it is not found, delays a decision until later, when the event is checked for an actual offsetX field.

codefrau commented 2 years ago

Thank you!

Maybe nowadays we can simply use offsetX/Y without checking? This code is ancient.

tonyg commented 2 years ago

I think we could profitably remove the userAgent check - per https://caniuse.com/mdn-api_mouseevent_offsetx all current browsers support offsetX, but firefox 38 (hah) was released in 2015 (hah!) which isn't that (?) long ago so how about