Files
MajoorWaldi-ComfyUI-Majoor-…/js/features/panel/panelRuntimeRefs.js
T
MajoorWaldi 2fa41a0e76 feat: add useGridState and useVirtualGrid composables for asset management
- Implemented useGridState to manage grid state, including asset selection and loading states.
- Created useVirtualGrid to centralize virtualization helpers for improved performance.
- Added createVueApp for isolated Vue 3 + Pinia application instances.
- Introduced Vite configuration for building the ComfyUI-Majoor-AssetsManager with external dependencies.
2026-04-03 11:04:55 +02:00

38 lines
959 B
JavaScript

let activeGridContainer = null;
function isLiveElement(element) {
if (!element) return false;
if (typeof element?.isConnected === "boolean") return element.isConnected;
return true;
}
function findGridInDom() {
try {
const grid =
document.getElementById("mjr-assets-grid") || document.querySelector(".mjr-grid");
if (isLiveElement(grid)) return grid;
} catch (e) {
console.debug?.(e);
}
return null;
}
export function setActiveGridContainer(container) {
activeGridContainer = container || null;
return activeGridContainer;
}
export function clearActiveGridContainer(container = null) {
if (!container || activeGridContainer === container) {
activeGridContainer = null;
}
}
export function getActiveGridContainer() {
if (isLiveElement(activeGridContainer)) {
return activeGridContainer;
}
activeGridContainer = null;
return findGridInDom();
}