openscopeproject / TrguiNG

Remote GUI for Transmission torrent daemon
GNU Affero General Public License v3.0
279 stars 33 forks source link

Feature request: Option to disable "smooth scrolling" #149

Closed broizter closed 6 months ago

broizter commented 6 months ago

This is the first option I disable whenever installing Firefox since I'm personally not a fan of "smooth scrolling". Would be awesome if there was a toggle to disable it. See screenshot from Firefox for an example.

img

qu1ck commented 6 months ago

Looks like this is not supported by webview on most platforms and not supported by Tauri. Not something I can work around either.

broizter commented 6 months ago

I understand! It's a minor gripe with another wise great project. Thanks for looking into it at least!

jpovixwm commented 6 months ago

Apparently this could work:

const getScrollParent = (node) => {
    const isElement = node instanceof HTMLElement;
    const overflowY = isElement && window.getComputedStyle(node).overflowY;
    const isScrollable = overflowY !== "visible" && overflowY !== "hidden";

    if (!node) {
        return null;
    } else if (isScrollable && node.scrollHeight >= node.clientHeight) {
        return node;
    }

    return getScrollParent(node.parentNode) || document.body;
};

window.addEventListener(
    "wheel",
    (e) => {
        e.preventDefault();
        getScrollParent(e.target)?.scrollBy({
            top: e.deltaY,
            left: e.deltaX,
            behavior: "instant",
        });
    },
    { passive: false },
);

I took the getScrollParent implementation from https://gist.github.com/twxia/bb20843c495a49644be6ea3804c0d775 Note that this POC assumes WheelEvent.deltaMode is WheelEvent.DOM_DELTA_PIXEL. This StackOverflow question has some ideas for handling different deltaModes.

So overall it's not very elegant, but seems doable.

qu1ck commented 6 months ago

That would only cover wheel scrolling, not clicking on scrollbars.