"git@developer.sourcefind.cn:sugon_wxj/megatron-lm.git" did not exist on "2d76d0650fde2b901f3c3f6bce7eac01bdc173d3"
invertMenuScrolling.js 805 Bytes
Newer Older
1
import { app } from "../../scripts/app.js";
pythongosssss's avatar
pythongosssss committed
2
3
4
5
6
7
8

// Inverts the scrolling of context menus

const id = "Comfy.InvertMenuScrolling";
app.registerExtension({
	name: id,
	init() {
pythongosssss's avatar
pythongosssss committed
9
		const ctxMenu = LiteGraph.ContextMenu;
pythongosssss's avatar
pythongosssss committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
		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;
				}
			},
		});
	},
});