Felipe Gomes has extended multitouch support in Firefox to reach into content space (i.e. us Web devs can use it!). Checking out the sexy demos in the video above will make you pine for the day (not long!) where all laptop screens support touch
We have three new DOM events (MozTouchDown, MozTouchMove and MozTouchRelease), which are similar to mouse events, except that they have a new attribute called streamId that can uniquely identify the same finger being tracked in a series of MozTouch events. The following snippet is the code for the first demo where we move independent <div>s under the X/Y position of each touch point.
PLAIN TEXT
JAVASCRIPT:
-
var assignedFingers = {};
-
var lastused = 0;
-
function touchMove(event) {
-
var divId;
-
if (lastused <= 4) return;
-
if (assignedFingers[event.streamId]) {
-
divId = assignedFingers[event.streamId];
-
} else {
-
divId = "trackingdiv" + (++lastused);
-
assignedFingers[event.streamId] = divId;
-
}
-
document.getElementById(divId).style.left = event.clientX + 'px';
-
document.getElementById(divId).style.top = event.clientY + 'px';
-
}
-
document.addEventListener("MozTouchMove", touchMove, false);
-
document.addEventListener("MozTouchRelease", function() { lastused--; },false);
You can check out code from all of the demos.