- From: Tran, Dzung D <dzung.d.tran@intel.com>
- Date: Wed, 10 Aug 2011 03:05:07 +0000
- To: Matt Brubeck <mbrubeck@mozilla.com>
- CC: Sangwhan Moon <smoon@opera.com>, "public-webevents@w3.org" <public-webevents@w3.org>
Matt, Thanks for the comments. Yes, I did this real quick and didn't bother to check for errors. It was meant to be an example to see if the group would want to use something like this in the spec or just stay simple and to the point. We definitely need to clean it up if we want it in the spec. I think for version 1, Sangwhan's examples are fine. Let just stay simple and get the spec out for LC. Thanks Tran -----Original Message----- From: Matt Brubeck [mailto:mbrubeck@mozilla.com] Sent: Tuesday, August 09, 2011 8:49 AM To: Tran, Dzung D Cc: Sangwhan Moon; public-webevents@w3.org Subject: Re: ACTION-57 done I like the idea of having a fairly complete example like this. Following are just some nit-picky comments about the code. > var color = ["red","blue"]; You'll get an exception if there are >2 touch points. > // canvas.addEventListener("touchstart", touchStart, false); > canvas.addEventListener("touchmove", touchMove, false) > canvas.addEventListener("mousemove", mouseMove, false); There's no mouseMove or touchStart function defined. (The touchStart line is commented out, but the mouseMove one is not.) > /* > * draw the square with different color for each touch > */ > for (i=0; i<ev.touches.length; i++) { > draw(oldX[i], oldY[i], "white"); // erase last position You should first erase all squares, then draw all squares. Otherwise you might erase part of a square after it's drawn, if it overlaps with another square. > draw(ev.changedTouches[i].pageX, ev.changedTouches[i].pageY, color[i]); This assumes that changedTouches.length == touches.length, and that the each touch will retain the same index in the list from one event to the next. Neither of these is guaranteed by the spec. > function touchCancel() { > ctx.fillStyle="white"; > ctx.fillRect(0,0,640,960); // clear the canvas > } This function is not actually called anywhere. It's also a little strange that you would do something like this on touchcancel but not touchend, since the spec leaves it mostly implementation-defined when touchcancel happens -- it won't be predictable from one device or browser to the next.
Received on Wednesday, 10 August 2011 03:05:52 UTC