diff --git a/browser_tests/interaction.spec.ts b/browser_tests/interaction.spec.ts index c2e7803db..b5583736a 100644 --- a/browser_tests/interaction.spec.ts +++ b/browser_tests/interaction.spec.ts @@ -19,8 +19,7 @@ test.describe('Node Interaction', () => { await expect(comfyPage.canvas).toHaveScreenshot('selected-node2.png') }) - // Flaky. See https://github.com/comfyanonymous/ComfyUI/issues/3866 - test.skip('Can drag node', async ({ comfyPage }) => { + test('Can drag node', async ({ comfyPage }) => { await comfyPage.dragNode2() await expect(comfyPage.canvas).toHaveScreenshot('dragged-node1.png') }) diff --git a/browser_tests/interaction.spec.ts-snapshots/dragged-node1-chromium-linux.png b/browser_tests/interaction.spec.ts-snapshots/dragged-node1-chromium-linux.png index 84022e700..b0a698dea 100644 Binary files a/browser_tests/interaction.spec.ts-snapshots/dragged-node1-chromium-linux.png and b/browser_tests/interaction.spec.ts-snapshots/dragged-node1-chromium-linux.png differ diff --git a/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-moved-chromium-linux.png b/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-moved-chromium-linux.png index 5f9441f33..26e77ea3b 100644 Binary files a/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-moved-chromium-linux.png and b/browser_tests/rightClickMenu.spec.ts-snapshots/right-click-unpinned-node-moved-chromium-linux.png differ diff --git a/src/scripts/domWidget.ts b/src/scripts/domWidget.ts index 622df00e8..0c918752e 100644 --- a/src/scripts/domWidget.ts +++ b/src/scripts/domWidget.ts @@ -39,7 +39,11 @@ function intersect(a: Rect, b: Rect): Vector4 | null { else return null } -function getClipPath(node: LGraphNode, element: HTMLElement): string { +function getClipPath( + node: LGraphNode, + element: HTMLElement, + canvasRect: DOMRect +): string { const selectedNode: LGraphNode = Object.values( app.canvas.selected_nodes )[0] as LGraphNode @@ -51,8 +55,8 @@ function getClipPath(node: LGraphNode, element: HTMLElement): string { const bounding = selectedNode.getBounding() const intersection = intersect( { - x: elRect.x / scale, - y: elRect.y / scale, + x: elRect.x / scale - canvasRect.left, + y: elRect.y / scale - canvasRect.top, width: elRect.width / scale, height: elRect.height / scale }, @@ -72,9 +76,8 @@ function getClipPath(node: LGraphNode, element: HTMLElement): string { return '' } - const widgetRect = element.getBoundingClientRect() - const clipX = elRect.left + intersection[0] - widgetRect.x / scale + 'px' - const clipY = elRect.top + intersection[1] - widgetRect.y / scale + 'px' + const clipX = canvasRect.left + intersection[0] - elRect.x / scale + 'px' + const clipY = canvasRect.top + intersection[1] - elRect.y / scale + 'px' const clipWidth = intersection[2] + 'px' const clipHeight = intersection[3] + 'px' const path = `polygon(0% 0%, 0% 100%, ${clipX} 100%, ${clipX} ${clipY}, calc(${clipX} + ${clipWidth}) ${clipY}, calc(${clipX} + ${clipWidth}) calc(${clipY} + ${clipHeight}), ${clipX} calc(${clipY} + ${clipHeight}), ${clipX} 100%, 100% 100%, 100% 0%)` @@ -356,7 +359,7 @@ LGraphNode.prototype.addDOMWidget = function ( }) if (enableDomClipping) { - element.style.clipPath = getClipPath(node, element) + element.style.clipPath = getClipPath(node, element, elRect) element.style.willChange = 'clip-path' }