mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 23:29:02 +02:00
chore(react/collections/table): bring back wheel scroll
This commit is contained in:
parent
05973672e4
commit
d367cf9972
@ -13,6 +13,7 @@ import branchService from "../../../services/branches";
|
|||||||
import { openColumnContextMenu, openNoteContextMenu } from "./context_menu";
|
import { openColumnContextMenu, openNoteContextMenu } from "./context_menu";
|
||||||
import { ContextMenuEvent } from "../../../menus/context_menu";
|
import { ContextMenuEvent } from "../../../menus/context_menu";
|
||||||
import { createContext } from "preact";
|
import { createContext } from "preact";
|
||||||
|
import { onWheelHorizontalScroll } from "../../widget_utils";
|
||||||
|
|
||||||
export interface BoardViewData {
|
export interface BoardViewData {
|
||||||
columns?: BoardColumnData[];
|
columns?: BoardColumnData[];
|
||||||
@ -79,7 +80,6 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
|
|||||||
|
|
||||||
saveConfig(newViewConfig);
|
saveConfig(newViewConfig);
|
||||||
setColumns(newColumns);
|
setColumns(newColumns);
|
||||||
console.log("New columns are ", newColumns);
|
|
||||||
setDraggedColumn(null);
|
setDraggedColumn(null);
|
||||||
setColumnDropPosition(null);
|
setColumnDropPosition(null);
|
||||||
}, [columns, viewConfig, saveConfig]);
|
}, [columns, viewConfig, saveConfig]);
|
||||||
@ -136,7 +136,10 @@ export default function BoardView({ note: parentNote, noteIds, viewConfig, saveC
|
|||||||
}, [draggedColumn, columnDropPosition, handleColumnDrop]);
|
}, [draggedColumn, columnDropPosition, handleColumnDrop]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="board-view">
|
<div
|
||||||
|
className="board-view"
|
||||||
|
onWheel={onWheelHorizontalScroll}
|
||||||
|
>
|
||||||
<BoardViewContext.Provider value={boardViewContext}>
|
<BoardViewContext.Provider value={boardViewContext}>
|
||||||
<div
|
<div
|
||||||
className="board-view-container"
|
className="board-view-container"
|
||||||
|
@ -24,7 +24,6 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
super(args, "board");
|
super(args, "board");
|
||||||
|
|
||||||
this.$root = $(TPL);
|
this.$root = $(TPL);
|
||||||
setupHorizontalScrollViaWheel(this.$root);
|
|
||||||
this.$container = this.$root.find(".board-view-container");
|
this.$container = this.$root.find(".board-view-container");
|
||||||
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
||||||
this.persistentData = {
|
this.persistentData = {
|
||||||
|
@ -7,12 +7,15 @@ import utils from "../services/utils.js";
|
|||||||
*/
|
*/
|
||||||
export function setupHorizontalScrollViaWheel($container: JQuery<HTMLElement>) {
|
export function setupHorizontalScrollViaWheel($container: JQuery<HTMLElement>) {
|
||||||
$container.on("wheel", (event) => {
|
$container.on("wheel", (event) => {
|
||||||
const wheelEvent = event.originalEvent as WheelEvent;
|
onWheelHorizontalScroll(event.originalEvent as WheelEvent);
|
||||||
if (utils.isCtrlKey(event) || event.altKey || event.shiftKey) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopImmediatePropagation();
|
|
||||||
event.currentTarget.scrollLeft += wheelEvent.deltaY + wheelEvent.deltaX;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function onWheelHorizontalScroll(event: WheelEvent) {
|
||||||
|
if (!event.currentTarget || utils.isCtrlKey(event) || event.altKey || event.shiftKey) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
(event.currentTarget as HTMLElement).scrollLeft += event.deltaY + event.deltaX;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user