mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 16:20:08 +01:00
feat(views/board): set up scroll via mouse wheel
This commit is contained in:
18
apps/client/src/widgets/widget_utils.ts
Normal file
18
apps/client/src/widgets/widget_utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import utils from "../services/utils.js";
|
||||
|
||||
/**
|
||||
* Enables scrolling of a container horizontally using the mouse wheel, instead of having to use the scrollbar or keep Shift pressed.
|
||||
*
|
||||
* @param $container the jQuery-wrapped container element to enable horizontal scrolling for.
|
||||
*/
|
||||
export function setupHorizontalScrollViaWheel($container: JQuery<HTMLElement>) {
|
||||
$container.on("wheel", (event) => {
|
||||
const wheelEvent = event.originalEvent as WheelEvent;
|
||||
if (utils.isCtrlKey(event) || event.altKey || event.shiftKey) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
event.currentTarget.scrollLeft += wheelEvent.deltaY + wheelEvent.deltaX;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user