diff options
author | Maxim Devaev <[email protected]> | 2023-04-25 04:53:02 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-04-25 04:53:08 +0300 |
commit | b8b0ad2874baa7f5e12a211886bf77d1cc5e8a0e (patch) | |
tree | 646b2edb7313d4e51b606cb18bd3064c65f59836 /web | |
parent | cbf0a8b8f24c44733d57d97094075383da4381d3 (diff) |
option for cumulative scrolling mode
Diffstat (limited to 'web')
-rw-r--r-- | web/kvm/index.html | 9 | ||||
-rw-r--r-- | web/kvm/navbar-system.pug | 2 | ||||
-rw-r--r-- | web/share/js/kvm/mouse.js | 28 |
3 files changed, 26 insertions, 13 deletions
diff --git a/web/kvm/index.html b/web/kvm/index.html index 10c47d44..e76b7c63 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -295,6 +295,15 @@ </td> </tr> <tr> + <td>Cumulative scrolling:</td> + <td align="right"> + <div class="switch-box"> + <input type="checkbox" id="hid-mouse-cumulative-scrolling-switch"> + <label for="hid-mouse-cumulative-scrolling-switch"><span class="switch-inner"></span><span class="switch"></span></label> + </div> + </td> + </tr> + <tr> <td>Scroll rate:</td> <td class="value-slider"> <input class="slider" type="range" id="hid-mouse-scroll-slider"> diff --git a/web/kvm/navbar-system.pug b/web/kvm/navbar-system.pug index 717b4cf8..e1054bd5 100644 --- a/web/kvm/navbar-system.pug +++ b/web/kvm/navbar-system.pug @@ -85,6 +85,8 @@ li(id="system-dropdown" class="right") tr +menu_switch_notable("hid-mouse-reverse-scrolling-switch", "Reverse scrolling", true, false) tr + +menu_switch_notable("hid-mouse-cumulative-scrolling-switch", "Cumulative scrolling", true, false) + tr td Scroll rate: td(class="value-slider") #[input(type="range" id="hid-mouse-scroll-slider" class="slider")] td(id="hid-mouse-scroll-value" class="value-number") diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index 31d6dfbe..6a72f5b9 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -68,9 +68,12 @@ export function Mouse(__getGeometry, __recordWsEvent) { $("stream-box").ontouchend = (event) => __streamTouchEndHandler(event); tools.storage.bindSimpleSwitch($("hid-mouse-squash-switch"), "hid.mouse.squash", true); - tools.storage.bindSimpleSwitch($("hid-mouse-reverse-scrolling-switch"), "hid.mouse.reverse_scrolling", false); tools.slider.setParams($("hid-mouse-sens-slider"), 0.1, 1.9, 0.1, tools.storage.get("hid.mouse.sens", 1.0), __updateRelativeSens); tools.slider.setParams($("hid-mouse-rate-slider"), 10, 100, 10, tools.storage.get("hid.mouse.rate", 100), __updateRate); // set __timer + + tools.storage.bindSimpleSwitch($("hid-mouse-reverse-scrolling-switch"), "hid.mouse.reverse_scrolling", false); + let cumulative_scrolling = !(tools.browser.is_firefox && !tools.browser.is_mac); + tools.storage.bindSimpleSwitch($("hid-mouse-cumulative-scrolling-switch"), "hid.mouse.cumulative_scrolling", cumulative_scrolling); tools.slider.setParams($("hid-mouse-scroll-slider"), 1, 100, 1, tools.storage.get("hid.mouse.scroll_rate", 5), __updateScrollRate); }; @@ -116,7 +119,7 @@ export function Mouse(__getGeometry, __recordWsEvent) { }; var __updateScrollRate = function(value) { - $("hid-mouse-scroll-value").innerHTML = value + " #"; + $("hid-mouse-scroll-value").innerHTML = value; tools.storage.set("hid.mouse.scroll_rate", value); __scroll_rate = value; }; @@ -258,33 +261,32 @@ export function Mouse(__getGeometry, __recordWsEvent) { event.preventDefault(); - let rate = -__scroll_rate; if (!__absolute && !__isRelativeCaptured()) { return; } let delta = {"x": 0, "y": 0}; - if (tools.browser.is_firefox && !tools.browser.is_mac) { - if (event.deltaX !== 0) { - delta.x = event.deltaX / Math.abs(event.deltaX) * (rate); - } - if (event.deltaY !== 0) { - delta.y = event.deltaY / Math.abs(event.deltaY) * (rate); - } - } else { + if ($("hid-mouse-cumulative-scrolling-switch").checked) { let factor = (tools.browser.is_mac ? 5 : 1); __scroll_delta.x += event.deltaX * factor; // Horizontal scrolling if (Math.abs(__scroll_delta.x) >= 100) { - delta.x = __scroll_delta.x / Math.abs(__scroll_delta.x) * (rate); + delta.x = __scroll_delta.x / Math.abs(__scroll_delta.x) * (-__scroll_rate); __scroll_delta.x = 0; } __scroll_delta.y += event.deltaY * factor; // Vertical scrolling if (Math.abs(__scroll_delta.y) >= 100) { - delta.y = __scroll_delta.y / Math.abs(__scroll_delta.y) * (rate); + delta.y = __scroll_delta.y / Math.abs(__scroll_delta.y) * (-__scroll_rate); __scroll_delta.y = 0; } + } else { + if (event.deltaX !== 0) { + delta.x = event.deltaX / Math.abs(event.deltaX) * (-__scroll_rate); + } + if (event.deltaY !== 0) { + delta.y = event.deltaY / Math.abs(event.deltaY) * (-__scroll_rate); + } } __sendScroll(delta); |