- From: Matt Brubeck <mbrubeck@mozilla.com>
- Date: Fri, 22 Mar 2013 15:04:53 -0700
- To: Jacob Rossi <Jacob.Rossi@microsoft.com>, Konstantinov Sergey <twirl@yandex-team.ru>, "public-pointer-events@w3.org" <public-pointer-events@w3.org>
On 3/22/2013 2:33 PM, Jacob Rossi wrote: > var pointerList = []; //Array off all active pointers, indexed by pointer ID, that has all the latest info about each > > window.addEventListener("pointerdown", addPointer, true); > window.addEventListener("pointermove", addPointer, true); > window.addEventListener("pointerup", remPointer, true); > window.addEventListener("pointercancel", remPointer, true); > > function updatePointer(e) { pointerList[e.pointerId] = e; } > function remPointer(e) { delete pointerList[e.pointerId]; } I wouldn't recommend this exact code: Since pointerId can be an arbitrary integer, looping through this array could take a very long time (for example if the UA decided to use pointerIds starting at 1,000,000). And getting the number of pointers is *not* as simple as pointerList.length. However, if you replace the Array with an ES6 Map object, then the basic approach should work fine.
Received on Friday, 22 March 2013 22:05:19 UTC