fix: warnings when NaN values are passed to svg transformations
Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -44,15 +44,16 @@ const nodeClassNameFunc = props.nodeClassName instanceof Function ? props.nodeCl
|
|||||||
|
|
||||||
const shapeRendering: ShapeRendering = typeof window === 'undefined' || !!window.chrome ? 'crispEdges' : 'geometricPrecision'
|
const shapeRendering: ShapeRendering = typeof window === 'undefined' || !!window.chrome ? 'crispEdges' : 'geometricPrecision'
|
||||||
|
|
||||||
|
const nodes = computed(() => store.nodes.filter((node) => !node.isHidden))
|
||||||
|
const bb = computed(() => getRectOfNodes(nodes.value))
|
||||||
|
const viewBB = computed(() => ({
|
||||||
|
x: -store.transform[0] / store.transform[2],
|
||||||
|
y: -store.transform[1] / store.transform[2],
|
||||||
|
width: store.dimensions.width / store.transform[2],
|
||||||
|
height: store.dimensions.height / store.transform[2],
|
||||||
|
}))
|
||||||
const viewBox = computed(() => {
|
const viewBox = computed(() => {
|
||||||
const bb = getRectOfNodes(store.nodes)
|
const boundingRect = store.nodes && store.nodes.length ? getBoundsofRects(bb.value, viewBB.value) : viewBB.value
|
||||||
const viewBB = {
|
|
||||||
x: -store.transform[0] / store.transform[2],
|
|
||||||
y: -store.transform[1] / store.transform[2],
|
|
||||||
width: store.dimensions.width / store.transform[2],
|
|
||||||
height: store.dimensions.height / store.transform[2],
|
|
||||||
}
|
|
||||||
const boundingRect = store.nodes && store.nodes.length ? getBoundsofRects(bb, viewBB) : viewBB
|
|
||||||
const scaledWidth = boundingRect.width / elementWidth
|
const scaledWidth = boundingRect.width / elementWidth
|
||||||
const scaledHeight = boundingRect.height / elementHeight
|
const scaledHeight = boundingRect.height / elementHeight
|
||||||
const viewScale = Math.max(scaledWidth, scaledHeight)
|
const viewScale = Math.max(scaledWidth, scaledHeight)
|
||||||
@@ -60,7 +61,6 @@ const viewBox = computed(() => {
|
|||||||
const viewHeight = viewScale * elementHeight
|
const viewHeight = viewScale * elementHeight
|
||||||
const offset = 5 * viewScale
|
const offset = 5 * viewScale
|
||||||
return {
|
return {
|
||||||
viewBB,
|
|
||||||
offset,
|
offset,
|
||||||
x: boundingRect.x - (viewWidth - boundingRect.width) / 2 - offset,
|
x: boundingRect.x - (viewWidth - boundingRect.width) / 2 - offset,
|
||||||
y: boundingRect.y - (viewHeight - boundingRect.height) / 2 - offset,
|
y: boundingRect.y - (viewHeight - boundingRect.height) / 2 - offset,
|
||||||
@@ -69,13 +69,25 @@ const viewBox = computed(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const nodes = computed(() => store.nodes.filter((node) => !node.isHidden))
|
const d = computed(() => {
|
||||||
|
if (viewBox.value.x && viewBox.value.y)
|
||||||
|
return `
|
||||||
|
M${viewBox.value.x - viewBox.value.offset},${viewBox.value.y - viewBox.value.offset}
|
||||||
|
h${viewBox.value.width + viewBox.value.offset * 2}
|
||||||
|
v${viewBox.value.height + viewBox.value.offset * 2}
|
||||||
|
h${-viewBox.value.width - viewBox.value.offset * 2}z
|
||||||
|
M${viewBB.value.x},${viewBB.value.y}
|
||||||
|
h${viewBB.value.width}
|
||||||
|
v${viewBB.value.height}
|
||||||
|
h${-viewBB.value.width}z`
|
||||||
|
else return ''
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<svg
|
<svg
|
||||||
:width="elementWidth"
|
:width="elementWidth"
|
||||||
:height="elementHeight"
|
:height="elementHeight"
|
||||||
:viewBox="`${viewBox.x} ${viewBox.y} ${viewBox.width} ${viewBox.height}`"
|
:viewBox="`${viewBox.x || 0} ${viewBox.y || 0} ${viewBox.width || 0} ${viewBox.height || 0}`"
|
||||||
class="vue-flow__minimap"
|
class="vue-flow__minimap"
|
||||||
>
|
>
|
||||||
<slot name="mini-map-nodes" :nodes="nodes" :view-box="viewBox">
|
<slot name="mini-map-nodes" :nodes="nodes" :view-box="viewBox">
|
||||||
@@ -95,15 +107,6 @@ const nodes = computed(() => store.nodes.filter((node) => !node.isHidden))
|
|||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</slot>
|
</slot>
|
||||||
<path
|
<path class="vue-flow__minimap-mask" :d="d" :fill="props.maskColor" fill-rule="evenodd" />
|
||||||
class="vue-flow__minimap-mask"
|
|
||||||
:d="`
|
|
||||||
M${viewBox.x - viewBox.offset},${viewBox.y - viewBox.offset}h${viewBox.width + viewBox.offset * 2}
|
|
||||||
v${viewBox.height + viewBox.offset * 2}
|
|
||||||
h${-viewBox.width - viewBox.offset * 2}z
|
|
||||||
M${viewBox.viewBB.x},${viewBox.viewBB.y}h${viewBox.viewBB.width}v${viewBox.viewBB.height}h${-viewBox.viewBB.width}z`"
|
|
||||||
:fill="props.maskColor"
|
|
||||||
fill-rule="evenodd"
|
|
||||||
/>
|
|
||||||
</svg>
|
</svg>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -48,11 +48,13 @@ const centered = computed(() =>
|
|||||||
...props,
|
...props,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const path = computed(() =>
|
const path = computed(() => {
|
||||||
getBezierPath({
|
if (props.sourceX && props.sourceY)
|
||||||
...props,
|
return getBezierPath({
|
||||||
}),
|
...props,
|
||||||
)
|
})
|
||||||
|
else return ''
|
||||||
|
})
|
||||||
|
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -23,10 +23,21 @@ interface EdgeAnchorProps extends HTMLAttributes {
|
|||||||
|
|
||||||
const props = withDefaults(defineProps<EdgeAnchorProps>(), {
|
const props = withDefaults(defineProps<EdgeAnchorProps>(), {
|
||||||
radius: 10,
|
radius: 10,
|
||||||
|
centerX: 0,
|
||||||
|
centerY: 0,
|
||||||
|
position: Position.Top,
|
||||||
})
|
})
|
||||||
|
|
||||||
const cx = computed(() => shiftX(props.centerX, props.radius, props.position))
|
const cx = computed(() => {
|
||||||
const cy = computed(() => shiftY(props.centerY, props.radius, props.position))
|
const val = shiftX(props.centerX, props.radius, props.position)
|
||||||
|
if (isNaN(val)) return 0
|
||||||
|
else return val
|
||||||
|
})
|
||||||
|
const cy = computed(() => {
|
||||||
|
const val = shiftY(props.centerY, props.radius, props.position)
|
||||||
|
if (isNaN(val)) return 0
|
||||||
|
else return val
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<circle class="vue-flow__edgeupdater" :cx="cx" :cy="cy" :r="props.radius" stroke="transparent" fill="transparent" />
|
<circle class="vue-flow__edgeupdater" :cx="cx" :cy="cy" :r="props.radius" stroke="transparent" fill="transparent" />
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const props = withDefaults(defineProps<EdgeTextProps>(), {
|
|||||||
|
|
||||||
const edgeRef = templateRef<SVGTextElement>('edge-text', null)
|
const edgeRef = templateRef<SVGTextElement>('edge-text', null)
|
||||||
const { width, height, x, y } = useElementBounding(edgeRef)
|
const { width, height, x, y } = useElementBounding(edgeRef)
|
||||||
const transform = computed(() => `translate(${props.x - width.value / 2} ${props.y - height.value / 2})`)
|
const transform = computed(() => `translate(${props.x - width.value / 2 || 0} ${props.y - height.value / 2 || 0})`)
|
||||||
const bgPadding = computed(() => [props.labelBgPadding[0], props.labelBgPadding[1]])
|
const bgPadding = computed(() => [props.labelBgPadding[0], props.labelBgPadding[1]])
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -50,11 +50,14 @@ const centered = computed(() =>
|
|||||||
...props,
|
...props,
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const path = computed(() =>
|
|
||||||
getSmoothStepPath({
|
const path = computed(() => {
|
||||||
...props,
|
if (props.sourceX && props.sourceY)
|
||||||
}),
|
return getSmoothStepPath({
|
||||||
)
|
...props,
|
||||||
|
})
|
||||||
|
else return ''
|
||||||
|
})
|
||||||
|
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -52,21 +52,19 @@ const centerX = computed(() => {
|
|||||||
const xOffset = Math.abs(props.targetX - props.sourceX) / 2
|
const xOffset = Math.abs(props.targetX - props.sourceX) / 2
|
||||||
return props.targetX < props.sourceX ? props.targetX + xOffset : props.targetX - xOffset
|
return props.targetX < props.sourceX ? props.targetX + xOffset : props.targetX - xOffset
|
||||||
})
|
})
|
||||||
const path = computed(() =>
|
|
||||||
getBezierPath({
|
const path = computed(() => {
|
||||||
...props,
|
if (props.sourceX && props.sourceY)
|
||||||
}),
|
return getBezierPath({
|
||||||
)
|
...props,
|
||||||
|
})
|
||||||
|
else return ''
|
||||||
|
})
|
||||||
|
|
||||||
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
const markerEnd = computed(() => getMarkerEnd(props.arrowHeadType, props.markerEndId))
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<path
|
<path :style="props.style" class="vue-flow__edge-path" :d="path" :marker-end="markerEnd" />
|
||||||
:style="props.style"
|
|
||||||
class="vue-flow__edge-path"
|
|
||||||
:d="`M ${props.sourceX},${props.sourceY}L ${props.targetX},${props.targetY}`"
|
|
||||||
:marker-end="markerEnd"
|
|
||||||
/>
|
|
||||||
<EdgeText
|
<EdgeText
|
||||||
v-if="props.label"
|
v-if="props.label"
|
||||||
:x="centerX"
|
:x="centerX"
|
||||||
|
|||||||
Reference in New Issue
Block a user