mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
Fix canvas initialization and sizing bugs
- Add image loading validation before sending canvas data to server Prevents 'Failed to get confirmation' error when images haven't finished loading after workflow reload. Waits 100ms and checks if all layer images are complete before rendering output. - Improve layer loading error handling in CanvasState Better logging when layers fail to load from IndexedDB. Allows empty canvas as valid state instead of failing. - Add ResizeObserver for canvas container Fixes bug where canvas only shows in top half of node. Watches container size changes and triggers re-render to ensure canvas dimensions are correctly calculated after DOM layout.
This commit is contained in:
@@ -884,6 +884,12 @@ async function createCanvasWidget(node, widget, app) {
|
||||
if (controlsElement) {
|
||||
resizeObserver.observe(controlsElement);
|
||||
}
|
||||
// Watch the canvas container itself to detect size changes and fix canvas dimensions
|
||||
const canvasContainerResizeObserver = new ResizeObserver(() => {
|
||||
// Force re-read of canvas dimensions on next render
|
||||
canvas.render();
|
||||
});
|
||||
canvasContainerResizeObserver.observe(canvasContainer);
|
||||
canvas.canvas.addEventListener('focus', () => {
|
||||
canvasContainer.classList.add('has-focus');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user