mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
fix: multiple sub nodes
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
e.stopImmediatePropagation()
|
e.stopImmediatePropagation()
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
nodeChildren: ({ instance }) => getNodeChildrenStyle(instance)
|
nodeChildren: ({ instance }) => getNodeChildrenStyle(instance.node as RenderedTreeExplorerNode)
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<template #folder="{ node }">
|
<template #folder="{ node }">
|
||||||
@@ -120,8 +120,6 @@ const viewRows = computed(() =>
|
|||||||
const bufferRows = computed(() => Math.max(1, Math.floor(viewRows.value / 3)))
|
const bufferRows = computed(() => Math.max(1, Math.floor(viewRows.value / 3)))
|
||||||
const windowSize = computed(() => viewRows.value + bufferRows.value * 2)
|
const windowSize = computed(() => viewRows.value + bufferRows.value * 2)
|
||||||
|
|
||||||
// Compute window ranges for all nodes based on scroll position
|
|
||||||
// Each node's window is calculated relative to its children list
|
|
||||||
const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
||||||
if (!containerHeight.value || !renderedRoot.value.children) {
|
if (!containerHeight.value || !renderedRoot.value.children) {
|
||||||
return {}
|
return {}
|
||||||
@@ -131,8 +129,8 @@ const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
|||||||
const scrollTop = scrollY.value
|
const scrollTop = scrollY.value
|
||||||
const scrollBottom = scrollTop + containerHeight.value
|
const scrollBottom = scrollTop + containerHeight.value
|
||||||
|
|
||||||
// Calculate cumulative positions for nodes in the tree
|
|
||||||
const nodePositions = new Map<string, number>()
|
const nodePositions = new Map<string, number>()
|
||||||
|
const nodeEndPositions = new Map<string, number>()
|
||||||
let currentPos = 0
|
let currentPos = 0
|
||||||
|
|
||||||
const calculatePositions = (node: RenderedTreeExplorerNode): number => {
|
const calculatePositions = (node: RenderedTreeExplorerNode): number => {
|
||||||
@@ -146,6 +144,7 @@ const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nodeEndPositions.set(node.key, currentPos)
|
||||||
return currentPos
|
return currentPos
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +152,6 @@ const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
|||||||
currentPos = calculatePositions(child)
|
currentPos = calculatePositions(child)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute windows for each node based on scroll position
|
|
||||||
const computeNodeWindow = (node: RenderedTreeExplorerNode) => {
|
const computeNodeWindow = (node: RenderedTreeExplorerNode) => {
|
||||||
if (!node.children || node.leaf) return
|
if (!node.children || node.leaf) return
|
||||||
|
|
||||||
@@ -162,21 +160,21 @@ const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
|||||||
|
|
||||||
const nodeStart = nodePositions.get(node.key) ?? 0
|
const nodeStart = nodePositions.get(node.key) ?? 0
|
||||||
const childrenStart = nodeStart + DEFAULT_NODE_HEIGHT
|
const childrenStart = nodeStart + DEFAULT_NODE_HEIGHT
|
||||||
const childrenEnd =
|
|
||||||
childrenStart + node.children.length * DEFAULT_NODE_HEIGHT
|
|
||||||
|
|
||||||
// Check if this node's children are in the visible range
|
|
||||||
const isVisible =
|
|
||||||
childrenEnd >= scrollTop - bufferRows.value * DEFAULT_NODE_HEIGHT &&
|
|
||||||
childrenStart <= scrollBottom + bufferRows.value * DEFAULT_NODE_HEIGHT
|
|
||||||
|
|
||||||
const totalChildren = node.children.length
|
const totalChildren = node.children.length
|
||||||
|
|
||||||
if (isVisible && totalChildren > 0) {
|
if (totalChildren === 0) return
|
||||||
// Calculate which children should be visible based on scroll position
|
|
||||||
const relativeScrollTop = Math.max(0, scrollTop - childrenStart)
|
|
||||||
const relativeScrollBottom = Math.max(0, scrollBottom - childrenStart)
|
|
||||||
|
|
||||||
|
const childrenEnd = nodeEndPositions.get(node.key) ?? childrenStart
|
||||||
|
|
||||||
|
const relativeScrollTop = Math.max(0, scrollTop - childrenStart)
|
||||||
|
const relativeScrollBottom = Math.max(0, scrollBottom - childrenStart)
|
||||||
|
|
||||||
|
const bufferHeight = bufferRows.value * DEFAULT_NODE_HEIGHT
|
||||||
|
const childrenAreaVisible =
|
||||||
|
childrenStart <= scrollBottom + bufferHeight &&
|
||||||
|
childrenEnd >= scrollTop - bufferHeight
|
||||||
|
|
||||||
|
if (childrenAreaVisible) {
|
||||||
const fromRow = Math.max(
|
const fromRow = Math.max(
|
||||||
0,
|
0,
|
||||||
Math.floor(relativeScrollTop / DEFAULT_NODE_HEIGHT) - bufferRows.value
|
Math.floor(relativeScrollTop / DEFAULT_NODE_HEIGHT) - bufferRows.value
|
||||||
@@ -194,17 +192,15 @@ const parentWindowRanges = computed<Record<string, WindowRange>>(() => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Node is outside visible range, use minimal window
|
// Node is outside visible range, show initial window
|
||||||
ranges[node.key] = createInitialWindowRange(
|
ranges[node.key] = createInitialWindowRange(
|
||||||
totalChildren,
|
totalChildren,
|
||||||
windowSize.value
|
windowSize.value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively compute windows for children
|
for (const child of node.children) {
|
||||||
const range = ranges[node.key]
|
computeNodeWindow(child)
|
||||||
for (let i = range.start; i < range.end && i < node.children.length; i++) {
|
|
||||||
computeNodeWindow(node.children[i])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,8 +267,7 @@ const displayRoot = computed<RenderedTreeExplorerNode>(() => ({
|
|||||||
)
|
)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const getNodeChildrenStyle = (instance: any) => {
|
const getNodeChildrenStyle = (node: RenderedTreeExplorerNode) => {
|
||||||
const node = instance.node as RenderedTreeExplorerNode
|
|
||||||
if (!node?.children || node.leaf) {
|
if (!node?.children || node.leaf) {
|
||||||
return { class: 'virtual-node-children' }
|
return { class: 'virtual-node-children' }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user