W3C home > Mailing lists > Public > public-webevents@w3.org > July to September 2011

Re: ACTION-57 done

From: Matt Brubeck <mbrubeck@mozilla.com>
Date: Tue, 09 Aug 2011 08:48:38 -0700
Message-ID: <4E4156D6.3050707@mozilla.com>
To: "Tran, Dzung D" <dzung.d.tran@intel.com>
CC: Sangwhan Moon <smoon@opera.com>, "public-webevents@w3.org" <public-webevents@w3.org>
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 Tuesday, 9 August 2011 15:49:08 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:03:53 UTC