Html程序  |  36行  |  744 B

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tap Settings Page</title>
<script>
var pageReady = false;
var startX;
var startY;
var movementOccurred = false;
var clickCount = 0;

function onLoad() {
    document.addEventListener('mousedown', mouseDown, false);
    document.addEventListener('mouseup', mouseUp, false);
    pageReady = true;
}

function mouseUp(e) {
    var deltaX = e.pageX - startX;
    var deltaY = e.pageY - startY;
    movementOccurred = ((deltaX != 0) || (deltaY != 0));
    clickCount = clickCount + 1;
    console.log(movementOccurred, deltaX, deltaY, clickCount)
}

function mouseDown(e) {
    startX = e.pageX;
    startY = e.pageY;
}
</script>
</head>
<body onload="onLoad()">
</body>
</html>