- 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>
Sangwhan, 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. <html> <head> <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); ctx.fillStyle="white"; ctx.fillRect(0,0,640,960); } function draw(x, y, color) { ctx.fillStyle = color; ctx.fillRect (x-25, y-25, 150, 150); } function touchMove(ev) { if (!ev) var ev = event; ev.preventDefault(); /* * 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.fillStyle="white"; ctx.fillRect(0,0,640,960); // clear the canvas } </script> </head> <body onload="init()"> <canvas id="mycanvas" width="640" height="960"></canvas> </body> </html> Thanks Tran -----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 Sangwhan, 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. Thanks Tran -----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