Skip to content

Commit

Permalink
Implement scroll multiplier litegraph.js/Comfy-Org#78
Browse files Browse the repository at this point in the history
- Adds ability to increase/decrease scroll speed
- Removes requirement for monkey patch
  • Loading branch information
webfiltered committed Aug 20, 2024
1 parent f3ab9cf commit eeb250a
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/extensions/core/invertMenuScrolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,15 @@ const id = 'Comfy.InvertMenuScrolling'
app.registerExtension({
name: id,
init() {
const ctxMenu = LiteGraph.ContextMenu
const replace = () => {
// @ts-expect-error
LiteGraph.ContextMenu = function (values, options) {
options = options || {}
if (options.scroll_speed) {
options.scroll_speed *= -1
} else {
options.scroll_speed = -0.1
}
return ctxMenu.call(this, values, options)
}
LiteGraph.ContextMenu.prototype = ctxMenu.prototype
}
app.ui.settings.addSetting({
id,
category: ['Comfy', 'Graph', 'InvertMenuScrolling'],
name: 'Invert Context Menu Scrolling',
type: 'boolean',
defaultValue: false,
onChange(value) {
if (value) {
replace()
} else {
LiteGraph.ContextMenu = ctxMenu
}
// @ts-expect-error Error will self-correct when decl maps are auto-generated.
LiteGraph.CONTEXT_MENU_SCROLL_MULTIPLIER = value ? -1 : 1
}
})
}
Expand Down

0 comments on commit eeb250a

Please sign in to comment.