W3C home > Mailing lists > Public > public-pointer-events@w3.org > January to March 2013

RE: Last Call comments

From: Jacob Rossi <Jacob.Rossi@microsoft.com>
Date: Fri, 22 Mar 2013 22:21:53 +0000
To: Matt Brubeck <mbrubeck@mozilla.com>, Konstantinov Sergey <twirl@yandex-team.ru>, "public-pointer-events@w3.org" <public-pointer-events@w3.org>
Message-ID: <3c419251b20244e79fa3dfce750cf783@BY2PR03MB028.namprd03.prod.outlook.com>
On Fri, Mar 22, 2013 at 3:04 PM, Matt Brubeck <mbrubeck@mozilla.com> wrote:
> 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.

Fair point. In lieu of interoperable ES6 Maps, you can work use for-in iteration. If you want the count of pointers, then that could be maintained fairly easy since you have explicit add/delete points.
Received on Friday, 22 March 2013 22:24:10 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:20:24 UTC