gestures.html revision 7c04a3c82e4bf4bc10412f5d4fa24329807cb5a1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Touch/Gesture Events</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0" />
<style>
#testNode, #testNode2 {
background-color: blue;
width:200px;
height:200px;
font-family:monospace;
font-size:7pt;
position:relative;
}
#testNode div {
white-space:nowrap;
}
#testNode.active {
background-color:red;
}
</style>
<script src="/build/yui/yui.js"></script>
</head>
<body>
<div id="testNode"></div>
<div id="testNode2"></div>
<script>
YUI({filter:"raw", combine:false}).use("event-gestures", function(Y) {
var div = Y.Node.one("#testNode"),
div2 = Y.Node.one("#testNode2");
var flickHandler = function(e) {
div.append("<div>flick, e:" + [e.flick.velocity, e.flick.distance, e.flick.button] + "</div>");
};
var moveStartHandler = function(e) {
var target = e.target;
target.set("innerHTML", "");
target.append("<div>gesturemovestart, page:" + [e.pageX, e.pageY, e.button] + "</div>");
};
var moveHandler = function(e) {
e.target.append("<div>gesturemove, page:" + [e.pageX, e.pageY, e.button] + "</div>");
};
var moveEndHandler = function(e) {
e.target.append("<div>gesturemoveend page:" + [e.pageX, e.pageY, e.button] + "</div>");
};
var flickCfg = {
minDistance:20,
minVelocity:0.3
};
var moveStartCfg = {
minDistance: 10,
minTime: 5000,
button:0
};
var moveStartCfg2 = {
minDistance: 10,
minTime: -1, // must move at least 10 pixels
button:0
};
div.on("flick", flickHandler, flickCfg);
div.on("gesturemovestart", moveStartHandler, moveStartCfg);
div.on("gesturemove", moveHandler);
div.on("gesturemoveend", moveEndHandler);
div2.on("gesturemovestart", moveStartHandler, moveStartCfg2);
div2.on("gesturemove", moveHandler);
div2.on("gesturemoveend", moveEndHandler);
div.addClass("active");
});
</script>
</body>
</html>