Permalink
Browse files

Make sure to cancel the default action for camera controls.

From reading http://www.quirksmode.org/js/dragdrop.html, returning false will
only work in Internet Explorer.  We'll just assume we're in a W3C compliant
browser and call preventDefault(), but we return false additionally anyway.

Thanks to Mr. Doob for the report and suggestion.
  • Loading branch information...
1 parent cde4fa8 commit b06d9d02641759819be5020028bbd32d5be8315a @deanm committed Jun 12, 2010
Showing with 24 additions and 12 deletions.
  1. +24 −12 demos/demo_utils.js
View
@@ -119,14 +119,23 @@ DemoUtils = (function() {
state.is_clicking = true;
state.last_x = rel.x;
state.last_y = rel.y
+ // Event was handled, don't take default action.
+ e.preventDefault();
+ return false;
}, false);
canvas.addEventListener('mouseup', function(e) {
state.is_clicking = false;
+ // Event was handled, don't take default action.
+ e.preventDefault();
+ return false;
}, false);
canvas.addEventListener('mouseout', function(e) {
state.is_clicking = false;
+ // Event was handled, don't take default action.
+ e.preventDefault();
+ return false;
}, false);
canvas.addEventListener('mousemove', function(e) {
@@ -142,20 +151,23 @@ DemoUtils = (function() {
// We need one event to get calibrated.
if (state.first_event) {
state.first_event = false;
- return;
+ } else {
+ var info = {
+ is_clicking: state.is_clicking,
+ canvas_x: state.last_x,
+ canvas_y: state.last_y,
+ delta_x: delta_x,
+ delta_y: delta_y,
+ shift: e.shiftKey,
+ ctrl: e.ctrlKey
+ };
+
+ listener(info);
}
- var info = {
- is_clicking: state.is_clicking,
- canvas_x: state.last_x,
- canvas_y: state.last_y,
- delta_x: delta_x,
- delta_y: delta_y,
- shift: e.shiftKey,
- ctrl: e.ctrlKey
- };
-
- listener(info);
+ // Event was handled, don't take default action.
+ e.preventDefault();
+ return false;
}, false);
}

0 comments on commit b06d9d0

Please sign in to comment.