Working with mouse and touch events is one of the biggest challenges for me in making interactive web apps. The availability of pointer events helps a lot, but I still pretty quickly end up with a mess of conditionals that are hard to reason about. I'm working on some new strategies and abstractions to help with this.
PointerOne, PointerTwo, PointerThree
The pointer event API provides events for pointerDown
, pointerMove
, and pointerUp
. Using the pointerId
provided you can link those events together into a continuous Pointer object that contains the whole lifecycle. I put this together into a SubPointer
class.