ComfyUI/web/extensions/core/invertMenuScrolling.js

37 lines
800 B
JavaScript
Raw Normal View History

2023-03-08 20:04:22 +00:00
import { app } from "/scripts/app.js";
// Inverts the scrolling of context menus
const id = "Comfy.InvertMenuScrolling";
app.registerExtension({
name: id,
init() {
2023-04-02 18:03:34 +00:00
const ctxMenu = LiteGraph.ContextMenu;
2023-03-08 20:04:22 +00:00
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;
}
},
});
},
});