Skip to content

Commit

Permalink
Example mouse listener on document body instead of canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
xeolabs committed Apr 22, 2013
1 parent 45e2b58 commit a7a01a1
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions examples/libs/example-support-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ function mouseOrbitUtility(scene) {
var yaw = 0;
var pitch = 0;

var canvas = scene.getCanvas();

function mouseDown(event) {
lastX = event.clientX;
lastY = event.clientY;
Expand Down Expand Up @@ -64,20 +62,20 @@ function mouseOrbitUtility(scene) {
}
}

canvas.addEventListener('mousedown', mouseDown, true);
canvas.addEventListener('mousemove', mouseMove, true);
canvas.addEventListener('mouseup', mouseUp, true);
canvas.addEventListener('touchstart', touchStart, true);
canvas.addEventListener('touchmove', touchMove, true);
canvas.addEventListener('touchend', touchEnd, true);
document.body.addEventListener('mousedown', mouseDown, true);
document.body.addEventListener('mousemove', mouseMove, true);
document.body.addEventListener('mouseup', mouseUp, true);
document.body.addEventListener('touchstart', touchStart, true);
document.body.addEventListener('touchmove', touchMove, true);
document.body.addEventListener('touchend', touchEnd, true);
}


function mousePanLookatUtility(scene) {

// Get handles to scene nodes

var lookatNode = scene.getNode("lookat");
var lookatNode = scene.getNode("lookat");

// Pan with mouse drags

Expand Down Expand Up @@ -132,15 +130,15 @@ function mousePanLookatUtility(scene) {
lastY = posY;

lookatNode.set({
eye: { x: xeye, y: yeye }
eye:{ x:xeye, y:yeye }
});
}
}

canvas.addEventListener('mousedown', mouseDown, true);
canvas.addEventListener('mousemove', mouseMove, true);
canvas.addEventListener('mouseup', mouseUp, true);
canvas.addEventListener('touchstart', touchStart, true);
canvas.addEventListener('touchmove', touchMove, true);
canvas.addEventListener('touchend', touchEnd, true);
document.body.addEventListener('mousedown', mouseDown, true);
document.body.addEventListener('mousemove', mouseMove, true);
document.body.addEventListener('mouseup', mouseUp, true);
document.body.addEventListener('touchstart', touchStart, true);
document.body.addEventListener('touchmove', touchMove, true);
document.body.addEventListener('touchend', touchEnd, true);
}

0 comments on commit a7a01a1

Please sign in to comment.