Closed broizter closed 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.
I understand! It's a minor gripe with another wise great project. Thanks for looking into it at least!
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.
That would only cover wheel scrolling, not clicking on scrollbars.
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.