2

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Steven Lu
  • 41,389
  • 58
  • 210
  • 364
  • It appears that the `Touch`es (the elements inside the `changedTouches` and `touches` lists) are directly updated and it may be reasonable to say that once any of them change, all of them would already have been updated from the data from hardware. As I log all the `touchmove` events the `Touch` objects inside the lists all contain the same (final location) position data... – Steven Lu Jan 06 '13 at 23:02
  • That would be the reasonable way to implement the browser: When your touch sensor provides the updated array of touch positions and IDs, fill up the `Touch` objects and then issue out the `touchmove` events. It wouldn't make any sense to set the `Touch` objects in an interleaved fashion while issuing the `touchmove`s. – Steven Lu Jan 07 '13 at 00:41

0 Answers0