Explorar o código

Controls: Remove preventDefault() from mouse handlers. (#21935)

Michael Herzog %!s(int64=4) %!d(string=hai) anos
pai
achega
f4569ee87a

+ 2 - 11
examples/js/controls/DragControls.js

@@ -81,8 +81,6 @@
 
 
 			function onPointerMove( event ) {
 			function onPointerMove( event ) {
 
 
-				event.preventDefault();
-
 				switch ( event.pointerType ) {
 				switch ( event.pointerType ) {
 
 
 					case 'mouse':
 					case 'mouse':
@@ -173,8 +171,6 @@
 
 
 			function onPointerDown( event ) {
 			function onPointerDown( event ) {
 
 
-				event.preventDefault();
-
 				switch ( event.pointerType ) {
 				switch ( event.pointerType ) {
 
 
 					case 'mouse':
 					case 'mouse':
@@ -187,9 +183,8 @@
 
 
 			}
 			}
 
 
-			function onMouseDown( event ) {
+			function onMouseDown() {
 
 
-				event.preventDefault();
 				_intersections.length = 0;
 				_intersections.length = 0;
 
 
 				_raycaster.setFromCamera( _mouse, _camera );
 				_raycaster.setFromCamera( _mouse, _camera );
@@ -220,8 +215,6 @@
 
 
 			function onPointerCancel( event ) {
 			function onPointerCancel( event ) {
 
 
-				event.preventDefault();
-
 				switch ( event.pointerType ) {
 				switch ( event.pointerType ) {
 
 
 					case 'mouse':
 					case 'mouse':
@@ -234,9 +227,7 @@
 
 
 			}
 			}
 
 
-			function onMouseCancel( event ) {
-
-				event.preventDefault();
+			function onMouseCancel() {
 
 
 				if ( _selected ) {
 				if ( _selected ) {
 
 

+ 0 - 5
examples/js/controls/FirstPersonControls.js

@@ -72,8 +72,6 @@
 
 
 				}
 				}
 
 
-				event.preventDefault();
-
 				if ( this.activeLook ) {
 				if ( this.activeLook ) {
 
 
 					switch ( event.button ) {
 					switch ( event.button ) {
@@ -96,8 +94,6 @@
 
 
 			this.onMouseUp = function ( event ) {
 			this.onMouseUp = function ( event ) {
 
 
-				event.preventDefault();
-
 				if ( this.activeLook ) {
 				if ( this.activeLook ) {
 
 
 					switch ( event.button ) {
 					switch ( event.button ) {
@@ -136,7 +132,6 @@
 
 
 			this.onKeyDown = function ( event ) {
 			this.onKeyDown = function ( event ) {
 
 
-				//event.preventDefault();
 				switch ( event.code ) {
 				switch ( event.code ) {
 
 
 					case 'ArrowUp':
 					case 'ArrowUp':

+ 1 - 12
examples/js/controls/FlyControls.js

@@ -55,8 +55,7 @@
 
 
 					return;
 					return;
 
 
-				} //event.preventDefault();
-
+				}
 
 
 				switch ( event.code ) {
 				switch ( event.code ) {
 
 
@@ -186,14 +185,6 @@
 
 
 			this.mousedown = function ( event ) {
 			this.mousedown = function ( event ) {
 
 
-				if ( this.domElement !== document ) {
-
-					this.domElement.focus();
-
-				}
-
-				event.preventDefault();
-
 				if ( this.dragToLook ) {
 				if ( this.dragToLook ) {
 
 
 					this.mouseStatus ++;
 					this.mouseStatus ++;
@@ -235,8 +226,6 @@
 
 
 			this.mouseup = function ( event ) {
 			this.mouseup = function ( event ) {
 
 
-				event.preventDefault();
-
 				if ( this.dragToLook ) {
 				if ( this.dragToLook ) {
 
 
 					this.mouseStatus --;
 					this.mouseStatus --;

+ 0 - 6
examples/js/controls/OrbitControls.js

@@ -741,11 +741,6 @@
 
 
 			function onMouseDown( event ) {
 			function onMouseDown( event ) {
 
 
-				// Prevent the browser from scrolling.
-				event.preventDefault(); // Manually set the focus since calling preventDefault above
-				// prevents the browser from setting it automatically.
-
-				scope.domElement.focus ? scope.domElement.focus() : window.focus();
 				let mouseAction;
 				let mouseAction;
 
 
 				switch ( event.button ) {
 				switch ( event.button ) {
@@ -827,7 +822,6 @@
 			function onMouseMove( event ) {
 			function onMouseMove( event ) {
 
 
 				if ( scope.enabled === false ) return;
 				if ( scope.enabled === false ) return;
-				event.preventDefault();
 
 
 				switch ( state ) {
 				switch ( state ) {
 
 

+ 1 - 5
examples/js/controls/TrackballControls.js

@@ -462,8 +462,6 @@
 
 
 			function onMouseDown( event ) {
 			function onMouseDown( event ) {
 
 
-				event.preventDefault();
-
 				if ( _state === STATE.NONE ) {
 				if ( _state === STATE.NONE ) {
 
 
 					switch ( event.button ) {
 					switch ( event.button ) {
@@ -518,7 +516,6 @@
 			function onMouseMove( event ) {
 			function onMouseMove( event ) {
 
 
 				if ( scope.enabled === false ) return;
 				if ( scope.enabled === false ) return;
-				event.preventDefault();
 				const state = _keyState !== STATE.NONE ? _keyState : _state;
 				const state = _keyState !== STATE.NONE ? _keyState : _state;
 
 
 				if ( state === STATE.ROTATE && ! scope.noRotate ) {
 				if ( state === STATE.ROTATE && ! scope.noRotate ) {
@@ -539,10 +536,9 @@
 
 
 			}
 			}
 
 
-			function onMouseUp( event ) {
+			function onMouseUp() {
 
 
 				if ( scope.enabled === false ) return;
 				if ( scope.enabled === false ) return;
-				event.preventDefault();
 				_state = STATE.NONE;
 				_state = STATE.NONE;
 				scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
 				scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
 				scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );
 				scope.domElement.ownerDocument.removeEventListener( 'pointerup', onPointerUp );

+ 2 - 12
examples/jsm/controls/DragControls.js

@@ -70,8 +70,6 @@ class DragControls extends EventDispatcher {
 
 
 		function onPointerMove( event ) {
 		function onPointerMove( event ) {
 
 
-			event.preventDefault();
-
 			switch ( event.pointerType ) {
 			switch ( event.pointerType ) {
 
 
 				case 'mouse':
 				case 'mouse':
@@ -154,8 +152,6 @@ class DragControls extends EventDispatcher {
 
 
 		function onPointerDown( event ) {
 		function onPointerDown( event ) {
 
 
-			event.preventDefault();
-
 			switch ( event.pointerType ) {
 			switch ( event.pointerType ) {
 
 
 				case 'mouse':
 				case 'mouse':
@@ -169,9 +165,7 @@ class DragControls extends EventDispatcher {
 
 
 		}
 		}
 
 
-		function onMouseDown( event ) {
-
-			event.preventDefault();
+		function onMouseDown() {
 
 
 			_intersections.length = 0;
 			_intersections.length = 0;
 
 
@@ -200,8 +194,6 @@ class DragControls extends EventDispatcher {
 
 
 		function onPointerCancel( event ) {
 		function onPointerCancel( event ) {
 
 
-			event.preventDefault();
-
 			switch ( event.pointerType ) {
 			switch ( event.pointerType ) {
 
 
 				case 'mouse':
 				case 'mouse':
@@ -215,9 +207,7 @@ class DragControls extends EventDispatcher {
 
 
 		}
 		}
 
 
-		function onMouseCancel( event ) {
-
-			event.preventDefault();
+		function onMouseCancel() {
 
 
 			if ( _selected ) {
 			if ( _selected ) {
 
 

+ 0 - 6
examples/jsm/controls/FirstPersonControls.js

@@ -91,8 +91,6 @@ class FirstPersonControls {
 
 
 			}
 			}
 
 
-			event.preventDefault();
-
 			if ( this.activeLook ) {
 			if ( this.activeLook ) {
 
 
 				switch ( event.button ) {
 				switch ( event.button ) {
@@ -110,8 +108,6 @@ class FirstPersonControls {
 
 
 		this.onMouseUp = function ( event ) {
 		this.onMouseUp = function ( event ) {
 
 
-			event.preventDefault();
-
 			if ( this.activeLook ) {
 			if ( this.activeLook ) {
 
 
 				switch ( event.button ) {
 				switch ( event.button ) {
@@ -145,8 +141,6 @@ class FirstPersonControls {
 
 
 		this.onKeyDown = function ( event ) {
 		this.onKeyDown = function ( event ) {
 
 
-			//event.preventDefault();
-
 			switch ( event.code ) {
 			switch ( event.code ) {
 
 
 				case 'ArrowUp':
 				case 'ArrowUp':

+ 0 - 12
examples/jsm/controls/FlyControls.js

@@ -57,8 +57,6 @@ class FlyControls extends EventDispatcher {
 
 
 			}
 			}
 
 
-			//event.preventDefault();
-
 			switch ( event.code ) {
 			switch ( event.code ) {
 
 
 				case 'ShiftLeft':
 				case 'ShiftLeft':
@@ -123,14 +121,6 @@ class FlyControls extends EventDispatcher {
 
 
 		this.mousedown = function ( event ) {
 		this.mousedown = function ( event ) {
 
 
-			if ( this.domElement !== document ) {
-
-				this.domElement.focus();
-
-			}
-
-			event.preventDefault();
-
 			if ( this.dragToLook ) {
 			if ( this.dragToLook ) {
 
 
 				this.mouseStatus ++;
 				this.mouseStatus ++;
@@ -169,8 +159,6 @@ class FlyControls extends EventDispatcher {
 
 
 		this.mouseup = function ( event ) {
 		this.mouseup = function ( event ) {
 
 
-			event.preventDefault();
-
 			if ( this.dragToLook ) {
 			if ( this.dragToLook ) {
 
 
 				this.mouseStatus --;
 				this.mouseStatus --;

+ 0 - 10
examples/jsm/controls/OrbitControls.js

@@ -841,14 +841,6 @@ class OrbitControls extends EventDispatcher {
 
 
 		function onMouseDown( event ) {
 		function onMouseDown( event ) {
 
 
-			// Prevent the browser from scrolling.
-			event.preventDefault();
-
-			// Manually set the focus since calling preventDefault above
-			// prevents the browser from setting it automatically.
-
-			scope.domElement.focus ? scope.domElement.focus() : window.focus();
-
 			let mouseAction;
 			let mouseAction;
 
 
 			switch ( event.button ) {
 			switch ( event.button ) {
@@ -951,8 +943,6 @@ class OrbitControls extends EventDispatcher {
 
 
 			if ( scope.enabled === false ) return;
 			if ( scope.enabled === false ) return;
 
 
-			event.preventDefault();
-
 			switch ( state ) {
 			switch ( state ) {
 
 
 				case STATE.ROTATE:
 				case STATE.ROTATE:

+ 1 - 7
examples/jsm/controls/TrackballControls.js

@@ -491,8 +491,6 @@ class TrackballControls extends EventDispatcher {
 
 
 		function onMouseDown( event ) {
 		function onMouseDown( event ) {
 
 
-			event.preventDefault();
-
 			if ( _state === STATE.NONE ) {
 			if ( _state === STATE.NONE ) {
 
 
 				switch ( event.button ) {
 				switch ( event.button ) {
@@ -546,8 +544,6 @@ class TrackballControls extends EventDispatcher {
 
 
 			if ( scope.enabled === false ) return;
 			if ( scope.enabled === false ) return;
 
 
-			event.preventDefault();
-
 			const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
 			const state = ( _keyState !== STATE.NONE ) ? _keyState : _state;
 
 
 			if ( state === STATE.ROTATE && ! scope.noRotate ) {
 			if ( state === STATE.ROTATE && ! scope.noRotate ) {
@@ -567,12 +563,10 @@ class TrackballControls extends EventDispatcher {
 
 
 		}
 		}
 
 
-		function onMouseUp( event ) {
+		function onMouseUp() {
 
 
 			if ( scope.enabled === false ) return;
 			if ( scope.enabled === false ) return;
 
 
-			event.preventDefault();
-
 			_state = STATE.NONE;
 			_state = STATE.NONE;
 
 
 			scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );
 			scope.domElement.ownerDocument.removeEventListener( 'pointermove', onPointerMove );