summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-08-15 10:43:57 +0300
committerDevaev Maxim <[email protected]>2020-08-15 10:43:57 +0300
commit8dbbb0b066e15b4c50a9c1f2efba003c7a1bf04a (patch)
treeac6a524db10dd420be4c15aadb8938ed7886e458
parent130c33b5395f72e7eadaa669f76f6e7071b2f157 (diff)
fixed mouse wheel in firefox and on mac
-rw-r--r--web/share/js/kvm/mouse.js30
1 files changed, 21 insertions, 9 deletions
diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js
index 9ac1fd0c..6fb69781 100644
--- a/web/share/js/kvm/mouse.js
+++ b/web/share/js/kvm/mouse.js
@@ -171,22 +171,34 @@ export function Mouse(record_callback) {
var __streamWheelHandler = function(event) {
// https://learn.javascript.ru/mousewheel
+ // https://stackoverflow.com/a/24595588
if (event.preventDefault) {
event.preventDefault();
}
let delta = {x: 0, y: 0};
- __wheel_delta.x += event.deltaX; // Horizontal scrolling
- if (Math.abs(__wheel_delta.x) >= 100) {
- delta.x = __wheel_delta.x / Math.abs(__wheel_delta.x) * (-5);
- __wheel_delta.x = 0;
- }
+ if (tools.browser.is_firefox && !tools.browser.is_mac) {
+ if (event.deltaX !== 0) {
+ delta.x = event.deltaX / Math.abs(event.deltaX) * (-5);
+ }
+ if (event.deltaY !== 0) {
+ delta.y = event.deltaY / Math.abs(event.deltaY) * (-5);
+ }
+ } else {
+ let factor = (tools.browser.is_mac ? 5 : 1);
- __wheel_delta.y += event.deltaY; // Vertical scrolling
- if (Math.abs(__wheel_delta.y) >= 100) {
- delta.y = __wheel_delta.y / Math.abs(__wheel_delta.y) * (-5);
- __wheel_delta.y = 0;
+ __wheel_delta.x += event.deltaX * factor; // Horizontal scrolling
+ if (Math.abs(__wheel_delta.x) >= 100) {
+ delta.x = __wheel_delta.x / Math.abs(__wheel_delta.x) * (-5);
+ __wheel_delta.x = 0;
+ }
+
+ __wheel_delta.y += event.deltaY * factor; // Vertical scrolling
+ if (Math.abs(__wheel_delta.y) >= 100) {
+ delta.y = __wheel_delta.y / Math.abs(__wheel_delta.y) * (-5);
+ __wheel_delta.y = 0;
+ }
}
if (delta.x || delta.y) {