Browse Source

Move mouse wheel handler from window to canvas element in HTML

Similar to https://github.com/godotengine/godot/pull/36557

At least in chrome, the following error is printed for each mouse wheel
rotation:
[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See https://www.chromestatus.com/features/6662647093133312

This PR moves the handler to the canvas and thereby fixes the error.

Tested on: Chrome and Firefox (MacOS), Firefox, Chrome(Android), Safari (IPad + MacOS)

(cherry picked from commit b1e8ac7b0876db22cfabc87c6a26911e0f632759)
Christoph Schröder 5 years ago
parent
commit
d70cb49eef
1 changed files with 1 additions and 1 deletions
  1. 1 1
      platform/javascript/os_javascript.cpp

+ 1 - 1
platform/javascript/os_javascript.cpp

@@ -1011,7 +1011,7 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
 	SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, mousemove, mousemove_callback)
 	SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, mousemove, mousemove_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, mousedown, mouse_button_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, mousedown, mouse_button_callback)
 	SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, mouseup, mouse_button_callback)
 	SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, mouseup, mouse_button_callback)
-	SET_EM_CALLBACK(EMSCRIPTEN_EVENT_TARGET_WINDOW, wheel, wheel_callback)
+	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, wheel, wheel_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchstart, touch_press_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchstart, touch_press_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchmove, touchmove_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchmove, touchmove_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchend, touch_press_callback)
 	SET_EM_CALLBACK(GODOT_CANVAS_SELECTOR, touchend, touch_press_callback)