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