Skip to content

Commit

Permalink
Enhance context menu scrolling behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-byrne committed Jan 2, 2025
1 parent b308a81 commit 8cac7ff
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
10 changes: 10 additions & 0 deletions public/css/litegraph.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions src/ContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8cac7ff

Please sign in to comment.