mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
fix: use node.pos/size instead of getBounding for positioning
getBounding returns stale data for freshly created nodes since updateArea only runs at the start of each render frame. Use node.pos and node.size directly which are set immediately by createNode.
This commit is contained in:
@@ -207,7 +207,7 @@ describe('ComfyApp', () => {
|
||||
it('should position batch node to the right of first node', () => {
|
||||
const mockNode1 = createMockNode({
|
||||
pos: [100, 200],
|
||||
getBounding: vi.fn(() => new Float64Array([100, 200, 300, 400]))
|
||||
size: [300, 400]
|
||||
})
|
||||
const mockBatchNode = createMockNode({ pos: [0, 0] })
|
||||
|
||||
@@ -219,8 +219,8 @@ describe('ComfyApp', () => {
|
||||
it('should stack multiple image nodes vertically', () => {
|
||||
const mockNode1 = createMockNode({
|
||||
pos: [100, 200],
|
||||
type: 'LoadImage',
|
||||
getBounding: vi.fn(() => new Float64Array([100, 200, 300, 400]))
|
||||
size: [300, 400],
|
||||
type: 'LoadImage'
|
||||
})
|
||||
const mockNode2 = createMockNode({ pos: [0, 0], type: 'LoadImage' })
|
||||
const mockNode3 = createMockNode({ pos: [0, 0], type: 'LoadImage' })
|
||||
@@ -235,7 +235,8 @@ describe('ComfyApp', () => {
|
||||
|
||||
it('should call graph change once for all nodes', () => {
|
||||
const mockNode1 = createMockNode({
|
||||
getBounding: vi.fn(() => new Float64Array([100, 200, 300, 400]))
|
||||
pos: [100, 200],
|
||||
size: [300, 400]
|
||||
})
|
||||
const mockBatchNode = createMockNode()
|
||||
|
||||
|
||||
@@ -1782,8 +1782,9 @@ export class ComfyApp {
|
||||
}
|
||||
|
||||
positionBatchNodes(nodes: LGraphNode[], batchNode: LGraphNode): void {
|
||||
const [x, y, width] = nodes[0].getBounding()
|
||||
batchNode.pos = [x + width + 100, y + 30]
|
||||
const [x, y] = nodes[0].pos
|
||||
const nodeWidth = nodes[0].size[0]
|
||||
batchNode.pos = [x + nodeWidth + 100, y + 30]
|
||||
|
||||
// Retrieving Node Height is inconsistent
|
||||
let height = 0
|
||||
|
||||
Reference in New Issue
Block a user