This commit is contained in:
justumen
2025-03-19 17:36:25 +01:00
parent 44d69e8907
commit 39dfb0220a
76 changed files with 3207 additions and 955 deletions

View File

@@ -1,44 +1,44 @@
import { app } from "../../../scripts/app.js";
// import { app } from "../../../scripts/app.js";
app.registerExtension({
name: "Bjornulf.ImageNoteLoadImage",
async nodeCreated(node) {
// Ensure the node is of the specific class
if (node.comfyClass !== "Bjornulf_ImageNoteLoadImage") return;
console.log("node created");
// app.registerExtension({
// name: "Bjornulf.ImageNoteLoadImage",
// async nodeCreated(node) {
// // Ensure the node is of the specific class
// if (node.comfyClass !== "Bjornulf_ImageNoteLoadImage") return;
// console.log("node created");
// Store the initial node size
let prevSize = [...node.size];
let stableCount = 0;
const minStableFrames = 3; // Number of frames the size must remain stable
// // Store the initial node size
// let prevSize = [...node.size];
// let stableCount = 0;
// const minStableFrames = 3; // Number of frames the size must remain stable
// Function to check if the node's size has stabilized
const checkSizeStable = () => {
if (node.size[0] === prevSize[0] && node.size[1] === prevSize[1]) {
stableCount++;
if (stableCount >= minStableFrames) {
// Size has been stable, simulate a resize to trigger layout update
const originalSize = [...node.size];
node.setSize([originalSize[0] + 1, originalSize[1]]); // Slightly increase width
setTimeout(() => {
node.setSize(originalSize); // Revert to original size
app.graph.setDirtyCanvas(true, true); // Trigger canvas redraw
}, 0);
} else {
// Size is stable but not for enough frames yet, check again
requestAnimationFrame(checkSizeStable);
}
} else {
// Size changed, reset counter and update prevSize
prevSize = [...node.size];
stableCount = 0;
requestAnimationFrame(checkSizeStable);
}
};
// // Function to check if the node's size has stabilized
// const checkSizeStable = () => {
// if (node.size[0] === prevSize[0] && node.size[1] === prevSize[1]) {
// stableCount++;
// if (stableCount >= minStableFrames) {
// // Size has been stable, simulate a resize to trigger layout update
// const originalSize = [...node.size];
// node.setSize([originalSize[0] + 1, originalSize[1]]); // Slightly increase width
// setTimeout(() => {
// node.setSize(originalSize); // Revert to original size
// app.graph.setDirtyCanvas(true, true); // Trigger canvas redraw
// }, 0);
// } else {
// // Size is stable but not for enough frames yet, check again
// requestAnimationFrame(checkSizeStable);
// }
// } else {
// // Size changed, reset counter and update prevSize
// prevSize = [...node.size];
// stableCount = 0;
// requestAnimationFrame(checkSizeStable);
// }
// };
// Start checking after a short delay to allow node initialization
setTimeout(() => {
requestAnimationFrame(checkSizeStable);
}, 5000);
}
});
// // Start checking after a short delay to allow node initialization
// setTimeout(() => {
// requestAnimationFrame(checkSizeStable);
// }, 5000);
// }
// });