diff --git a/packages/core/src/components/Edges/EdgeText.vue b/packages/core/src/components/Edges/EdgeText.vue index 8891196d..7a89975f 100644 --- a/packages/core/src/components/Edges/EdgeText.vue +++ b/packages/core/src/components/Edges/EdgeText.vue @@ -18,7 +18,13 @@ let box = $ref({ x: 0, y: 0, width: 0, height: 0 }) const el = $ref(null) -const getBox = () => { +const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`) + +onMounted(getBox) + +watch([() => x, () => y, $$(el), () => label], getBox) + +function getBox() { if (!el) return const nextBox = el.getBBox() @@ -27,12 +33,6 @@ const getBox = () => { box = nextBox } } - -onMounted(getBox) - -watch([() => x, () => y, $$(el), () => label], getBox) - -const transform = computed(() => `translate(${x - box.width / 2} ${y - box.height / 2})`) diff --git a/packages/core/src/container/EdgeRenderer/EdgeRenderer.vue b/packages/core/src/container/EdgeRenderer/EdgeRenderer.vue index b11824b7..3bbc0f4b 100644 --- a/packages/core/src/container/EdgeRenderer/EdgeRenderer.vue +++ b/packages/core/src/container/EdgeRenderer/EdgeRenderer.vue @@ -19,14 +19,9 @@ const { getEdges, getNodesInitialized, getEdgeTypes, - noPanClassName, elevateEdgesOnSelect, } = $(useVueFlow()) -const selectable = (s?: boolean) => (typeof s === 'undefined' ? elementsSelectable : s) -const updatable = (u?: EdgeUpdatable) => (typeof u === 'undefined' ? edgesUpdatable : u) -const focusable = (f?: boolean) => (typeof f === 'undefined' ? edgesFocusable : f) - const sourceNode = $( controlledComputed( () => connectionStartHandle?.nodeId, @@ -73,7 +68,11 @@ onBeforeUnmount(() => { stop?.() }) -const getType = (type?: string, template?: GraphEdge['template']) => { +const selectable = (edgeSelectable?: boolean) => (typeof edgeSelectable === 'undefined' ? elementsSelectable : edgeSelectable) +const updatable = (edgeUpdatable?: EdgeUpdatable) => (typeof edgeUpdatable === 'undefined' ? edgesUpdatable : edgeUpdatable) +const focusable = (edgeFocusable?: boolean) => (typeof edgeFocusable === 'undefined' ? edgesFocusable : edgeFocusable) + +function getType(type?: string, template?: GraphEdge['template']) { const name = type || 'default' let edgeType = template ?? getEdgeTypes[name] const instance = getCurrentInstance() @@ -96,11 +95,6 @@ const getType = (type?: string, template?: GraphEdge['template']) => { return slot } - -const getClass = (edge: GraphEdge) => { - const extraClass = edge.class instanceof Function ? edge.class(edge) : edge.class - return [noPanClassName, extraClass] -}