As I determined in this topic, the touchmove
event is liable to be sent in batches depending on the combination of elements being touched.
If I have three fingers each touching a different element, but I still want to be able to process the motion of all three fingers together (for example to define an interaction on a common parent of these 3 elements), I would basically have to consolidate the data coming out of the touch events which are likely to be issued in "clumps" of three touchmove
events for each device input sample.
While a simple workaround is to just "make one big covering element" and handle it the usual way, I intend to go after the holy grail of wrapping complex manipulations on complex DOM structures in a simple-to-deploy piece of code.
As such it is clear that I want to either use the data out of touches
list within the last-inbound touchmove
, or collect the contents of changedTouches
of each touchmove
. I have currently been writing a routine which tracks the identifiers of touches and once it sees one repeated it will know at that point that we're looking at the first touchmove
out of the next group (the next input tick).
This is clearly sub-optimal because I have now introduced an up to 16ms delay on processing the input.
I did come up with something that could work: If the events are sent in in the order that the touch identifiers
are in, then when I am processing the changedTouches
list which ends with the touch corresponding to the highest-numbered identifier
created (and I know this from the touchstart
event), then that would be sufficient to indicate that I have received through the touchmoves
so far all of the info for the current timestep from the hardware.
Update: What I have implemented is a variable that tracks one of the fingers and once it sees that finger in a touchmove
changedTouches
, it goes and runs a loop that processes all values in touches
. This completely fails to provide the correct information. The one touch that it checks against might not move, and in that case no changedTouches
is produced for it.
What other things could I do?