mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2026-05-22 11:02:15 +08:00
Update contextmenu.js
This commit is contained in:
parent
8202643f82
commit
a2b2f3f95d
@ -12,14 +12,16 @@ function addMenuHandler(nodeType, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function addNode(name, nextTo, options) {
|
function addNode(name, nextTo, options) {
|
||||||
options = { select: true, shiftY: 0, shiftX: 0, before: false, ...(options || {}) };
|
console.log("name:", name);
|
||||||
|
console.log("nextTo:", nextTo);
|
||||||
|
options = { side: "left", select: true, shiftY: 0, shiftX: 0, ...(options || {}) };
|
||||||
const node = LiteGraph.createNode(name);
|
const node = LiteGraph.createNode(name);
|
||||||
app.graph.add(node);
|
app.graph.add(node);
|
||||||
node.pos = [
|
|
||||||
options.before ? nextTo.pos[0] - node.size[0] - 30 : nextTo.pos[0] + nextTo.size[0] + 30,
|
|
||||||
nextTo.pos[0] + options.shiftX,
|
|
||||||
nextTo.pos[1] + options.shiftY,
|
|
||||||
|
|
||||||
|
node.pos = [
|
||||||
|
options.side === "left" ? nextTo.pos[0] - (node.size[0] + options.offset): nextTo.pos[0] + nextTo.size[0] + options.offset,
|
||||||
|
|
||||||
|
nextTo.pos[1] + options.shiftY,
|
||||||
];
|
];
|
||||||
if (options.select) {
|
if (options.select) {
|
||||||
app.canvas.selectNode(node, false);
|
app.canvas.selectNode(node, false);
|
||||||
@ -35,12 +37,11 @@ app.registerExtension({
|
|||||||
options.unshift(
|
options.unshift(
|
||||||
{
|
{
|
||||||
content: "Add GetNode",
|
content: "Add GetNode",
|
||||||
callback: () => {addNode("GetNode", this, { shiftY: 0,shiftX: this.size[0] + 30 });}
|
callback: () => {addNode("GetNode", this, { side:"left", offset: 30});}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
content: "Add SetNode",
|
content: "Add SetNode",
|
||||||
callback: () => {
|
callback: () => {addNode("SetNode", this, { side:"right", offset: 30 });
|
||||||
addNode("SetNode", this);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user