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

RE: ACTION-57 done

From: Tran, Dzung D <dzung.d.tran@intel.com>
Date: Fri, 5 Aug 2011 22:22:08 +0000
To: Sangwhan Moon <smoon@opera.com>
CC: "public-webevents@w3.org" <public-webevents@w3.org>
Message-ID: <84BCA539DD96614691177EDA3CE4FF0513742364@ORSMSX101.amr.corp.intel.com>

What do you think about this code examples for touchmove events? I tested with the iPhone and it seems to work. It uses Safari's webkit syntax which can easily convert to our spec's syntax. I can also create an example with this code as the base for rotation.

<script type="application/javascript">

var canvas;
var ctx;
var color = ["red","blue"];
var oldX = [0,0];
var oldY = [0,0];

function init() {
	canvas = document.getElementById("mycanvas");
	ctx = canvas.getContext("2d");
//	canvas.addEventListener("touchstart", touchStart, false);
	canvas.addEventListener("touchmove", touchMove, false)
	canvas.addEventListener("mousemove", mouseMove, false);

function draw(x, y, color) {
	ctx.fillStyle = color;
	ctx.fillRect (x-25, y-25, 150, 150);

function touchMove(ev) {
	if (!ev) var ev = event;
	* 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
		draw(ev.changedTouches[i].pageX, ev.changedTouches[i].pageY, color[i]);
		oldX[i] = ev.changedTouches[i].pageX;	// save position
		oldY[i] = ev.changedTouches[i].pageY;

function touchCancel() {
	ctx.fillRect(0,0,640,960);	// clear the canvas

<body onload="init()">
	<canvas id="mycanvas" width="640" height="960"></canvas>


-----Original Message-----
From: public-webevents-request@w3.org [mailto:public-webevents-request@w3.org] On Behalf Of Tran, Dzung D
Sent: Wednesday, August 03, 2011 8:02 PM
To: Sangwhan Moon
Cc: public-webevents@w3.org
Subject: RE: ACTION-57 done


These code examples looks fine. Yes, I was thinking the same with examples for the use of Touch objects. I will wait for your email on blocking issues.


-----Original Message-----
From: Sangwhan Moon [mailto:smoon@opera.com] 
Sent: Wednesday, August 03, 2011 6:14 AM
To: Tran, Dzung D
Cc: public-webevents@w3.org
Subject: Re: ACTION-57 done

Dzung, you are welcome to come up with something better - I sure think that there is plenty of room for improvement.

I haven't actually asserted against any of the Touch objects and approached in a bit more primitive approach (lengths) due to other blocking issues - details to follow on a upcoming mail.

On 2011. Aug (8). 03, at 8:07 PM, Arthur Barstow wrote:

> Thanks Sangwhan. I closed action-57 and will leave its issue-18 open for a bit as a reminder that you and/or others are welcome to create patches for additional examples.
> FYI, Dzung Tran mentioned he may be able to contribute an example.
> On 8/3/11 6:21 AM, ext Sangwhan Moon wrote:
>> Sorry for the long delay - I've addressed a proposal for ISSUE-18 and pushed it to the repo.
>> Probably needs some clean-up. (or making more minimal examples, not sure which direction is better)

Best regards,

Sangwhan Moon
Opera Software ASA | Skype: innodb1
Received on Friday, 5 August 2011 22:46:41 UTC

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