From ca59f0e1a443a2667c5c0579ae74fdb67a1c3dcb Mon Sep 17 00:00:00 2001 From: Joncom Date: Fri, 17 Sep 2021 04:05:20 +0100 Subject: [PATCH] Stop using non-standard, deprecated wheel events Replaces: https://developer.mozilla.org/en-US/docs/Web/API/MouseWheelEvent https://developer.mozilla.org/en-US/docs/Web/API/Element/DOMMouseScroll_event With: https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent --- lib/impact/input.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/impact/input.js b/lib/impact/input.js index 121c0777..928d8668 100644 --- a/lib/impact/input.js +++ b/lib/impact/input.js @@ -116,9 +116,7 @@ ig.Input = ig.Class.extend({ initMouse: function() { if( this.isUsingMouse ) { return; } this.isUsingMouse = true; - var mouseWheelBound = this.mousewheel.bind(this); - ig.system.canvas.addEventListener('mousewheel', mouseWheelBound, false ); - ig.system.canvas.addEventListener('DOMMouseScroll', mouseWheelBound, false ); + ig.system.canvas.addEventListener('wheel', this.mousewheel.bind(this), false ); ig.system.canvas.addEventListener('contextmenu', this.contextmenu.bind(this), false ); ig.system.canvas.addEventListener('mousedown', this.keydown.bind(this), false ); @@ -157,8 +155,7 @@ ig.Input = ig.Class.extend({ mousewheel: function( event ) { - var delta = event.wheelDelta ? event.wheelDelta : (event.detail * -1); - var code = delta > 0 ? ig.KEY.MWHEEL_UP : ig.KEY.MWHEEL_DOWN; + var code = event.deltaY < 0 ? ig.KEY.MWHEEL_UP : ig.KEY.MWHEEL_DOWN; var action = this.bindings[code]; if( action ) { this.actions[action] = true; @@ -319,4 +316,4 @@ ig.Input = ig.Class.extend({ } }); -}); \ No newline at end of file +});