Browse Source

Add Firefox detection of mouse wheel. Fixes #15.

Bentley James Oakes 7 years ago
parent
commit
cedfebba84
2 changed files with 23 additions and 8 deletions
  1. 6 1
      client/compile_utils.js
  2. 17 7
      client/geometry_utils.js

+ 6 - 1
client/compile_utils.js

@@ -309,7 +309,8 @@ CompileUtils = function(){
 								BehaviorManager.handleUserEvent(__EVENT_MIDDLE_RELEASE_ICON,event);
 						}
 					};
-				icon.node.onmousewheel = 
+
+				let shiftWheelFunction =
 					function(event)
 					{
 						if( event.shiftKey )
@@ -318,6 +319,10 @@ CompileUtils = function(){
 							return false;
 						}
 					};
+
+				icon.node.onmousewheel = shiftWheelFunction;
+				icon.node.onwheel = shiftWheelFunction;
+
 				/*icon.node.onmouseover = 
 					function(event)
 					{

+ 17 - 7
client/geometry_utils.js

@@ -305,13 +305,23 @@ GeometryUtils = function(){
 					var img = $('<img>');
 					img.attr('class', 'geometry_ctrl');
 					img.attr('src', 'client/media/'+x+'.png');
-					img.get(0).onmousewheel = 
-						function(event)	
-						{
-							var dir = event.wheelDelta;
-							GeometryUtils.previewSelectionTransformation(x,dir);
-							return false;
-						};
+
+					let wheelFunc = function(event)
+					{
+						let dir = null;
+						if (event.wheelDelta){
+							dir = event.wheelDelta;
+						}else if (event.deltaY){
+							dir = event.deltaY;
+						}
+						GeometryUtils.previewSelectionTransformation(x,dir);
+						return false;
+					};
+
+					//detect mouse wheel on all browsers
+					img.get(0).onmousewheel = wheelFunc;
+					img.get(0).onwheel = wheelFunc;
+
 					geometryControlsOverlay.append(img);
 				});
 			var img = $('<img>');