From e9509d16961ac4a15c9b9407dbe9b1102db56883 Mon Sep 17 00:00:00 2001 From: Viktor Kovacs Date: Sun, 9 May 2021 15:38:32 +0200 Subject: [PATCH] Use wheel event instead of deprecated DOMMouseScroll and mousewheel. --- source/viewer/navigation.js | 11 +-- tools/sandbox/embed_iframe_scroll.html | 22 ++++++ .../sandbox/embed_selfhost_single_scroll.html | 73 +++++++++++++++++++ 3 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 tools/sandbox/embed_iframe_scroll.html create mode 100644 tools/sandbox/embed_selfhost_single_scroll.html diff --git a/source/viewer/navigation.js b/source/viewer/navigation.js index 1c23886..00a92c7 100644 --- a/source/viewer/navigation.js +++ b/source/viewer/navigation.js @@ -248,8 +248,7 @@ OV.Navigation = class if (this.canvas.addEventListener) { this.canvas.addEventListener ('mousedown', this.OnMouseDown.bind (this)); - this.canvas.addEventListener ('DOMMouseScroll', this.OnMouseWheel.bind (this)); - this.canvas.addEventListener ('mousewheel', this.OnMouseWheel.bind (this)); + this.canvas.addEventListener ('wheel', this.OnMouseWheel.bind (this)); this.canvas.addEventListener ('touchstart', this.OnTouchStart.bind (this)); this.canvas.addEventListener ('touchmove', this.OnTouchMove.bind (this)); this.canvas.addEventListener ('touchend', this.OnTouchEnd.bind (this)); @@ -460,13 +459,7 @@ OV.Navigation = class ev.preventDefault (); let params = ev || window.event; - let delta = 0; - if (params.detail) { - delta = -params.detail; - } else if (params.wheelDelta) { - delta = params.wheelDelta / 40; - } - + let delta = -params.deltaY / 40; let ratio = 0.1; if (delta < 0) { ratio = ratio * -1.0; diff --git a/tools/sandbox/embed_iframe_scroll.html b/tools/sandbox/embed_iframe_scroll.html new file mode 100644 index 0000000..9be075a --- /dev/null +++ b/tools/sandbox/embed_iframe_scroll.html @@ -0,0 +1,22 @@ + + + + + + + + + Online 3D Viewer + + + +
+ +
+ + + diff --git a/tools/sandbox/embed_selfhost_single_scroll.html b/tools/sandbox/embed_selfhost_single_scroll.html new file mode 100644 index 0000000..ba3bdb0 --- /dev/null +++ b/tools/sandbox/embed_selfhost_single_scroll.html @@ -0,0 +1,73 @@ + + + + + + + + Online 3D Viewer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + +