From bee9c18a31a27c76ae50377cda3ca990a9d9ac1b Mon Sep 17 00:00:00 2001 From: bymyself Date: Thu, 2 Jan 2025 12:57:05 -0700 Subject: [PATCH] Enhance context menu scrolling behavior (#414) --- public/css/litegraph.css | 10 ++++++++++ src/ContextMenu.ts | 13 ------------- src/interfaces.ts | 1 + 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/public/css/litegraph.css b/public/css/litegraph.css index ebaacaaa7e..0d5872ee91 100644 --- a/public/css/litegraph.css +++ b/public/css/litegraph.css @@ -24,6 +24,16 @@ box-shadow: 0 0 10px black !important; background-color: #2e2e2e !important; z-index: 10; + max-height: -webkit-fill-available; + overflow-y: auto; +} + +/* Enable scrolling overflow in Firefox */ +@supports not (max-height: -webkit-fill-available) { + .litegraph.litecontextmenu { + max-height: 80vh; + overflow-y: scroll; + } } .litegraph.litecontextmenu.dark { diff --git a/src/ContextMenu.ts b/src/ContextMenu.ts index 318a64156f..6dd5d54c8e 100644 --- a/src/ContextMenu.ts +++ b/src/ContextMenu.ts @@ -115,19 +115,6 @@ export class ContextMenu { true, ) - function on_mouse_wheel(e: WheelEvent) { - const pos = parseInt(root.style.top) - root.style.top = (pos + e.deltaY * options.scroll_speed).toFixed() + "px" - e.preventDefault() - return true - } - - if (!options.scroll_speed) { - options.scroll_speed = 0.1 - } - - root.addEventListener("wheel", on_mouse_wheel, true) - this.root = root // title diff --git a/src/interfaces.ts b/src/interfaces.ts index b260c63ebe..1696b9c788 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -269,6 +269,7 @@ export interface IContextMenuOptions extends IContextMenuBase { parentMenu?: ContextMenu event?: MouseEvent extra?: unknown + /** @deprecated Context menu scrolling is now controlled by the browser */ scroll_speed?: number left?: number top?: number