Pixel-Precision Wheel Scroll

Add pixel-precision wheel scrolling capability using CTRL+SHIFT+Wheel for vertical scroll, and CTRL+ALT+Wheel for horizontal scroll, for any scrollable element which can be scrolled at pixel level.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Pixel-Precision Wheel Scroll
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.3
// @license      AGPL v3
// @author       jcunews
// @description  Add pixel-precision wheel scrolling capability using CTRL+SHIFT+Wheel for vertical scroll, and CTRL+ALT+Wheel for horizontal scroll, for any scrollable element which can be scrolled at pixel level.
// @match        *://*/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

addEventListener("wheel", (ev, ele) => {
  if (ev.ctrlKey) {
    ele = ev.target;
    while (ele && (ele.offsetWidth === ele.scrollWidth) && (ele.offsetHeight === ele.scrollHeight)) ele = ele.parentNode;
    ele = ele || window;
    if (ev.shiftKey && !ev.altKey) {
      ele.scrollBy(0, ev.deltaY > 0 ? 1 : -1);
      ev.stopPropagation();
      ev.preventDefault()
    } else if (ev.altKey && !ev.shiftKey) {
      ele.scrollBy(ev.deltaY > 0 ? 1 : -1, 0);;
      ev.stopPropagation();
      ev.preventDefault()
    }
  }
}, {capture: true, passive: false})