From 4ed39cf03847f85b80eb9bdb566615bea9e2a862 Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Wed, 8 Mar 2023 20:04:22 +0000 Subject: [PATCH] Added invert scrolling setting --- web/extensions/core/invertMenuScrolling.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 web/extensions/core/invertMenuScrolling.js diff --git a/web/extensions/core/invertMenuScrolling.js b/web/extensions/core/invertMenuScrolling.js new file mode 100644 index 0000000..34523d5 --- /dev/null +++ b/web/extensions/core/invertMenuScrolling.js @@ -0,0 +1,36 @@ +import { app } from "/scripts/app.js"; + +// Inverts the scrolling of context menus + +const id = "Comfy.InvertMenuScrolling"; +const ctxMenu = LiteGraph.ContextMenu; +app.registerExtension({ + name: id, + init() { + const replace = () => { + 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, + name: "Invert Menu Scrolling", + type: "boolean", + defaultValue: false, + onChange(value) { + if (value) { + replace(); + } else { + LiteGraph.ContextMenu = ctxMenu; + } + }, + }); + }, +});