feat(edges): add pointerRadius prop to edges
This commit is contained in:
@@ -14,11 +14,12 @@ const BaseEdge: FunctionalComponent<BaseEdgeProps> = function ({
|
|||||||
labelBgBorderRadius,
|
labelBgBorderRadius,
|
||||||
labelBgPadding,
|
labelBgPadding,
|
||||||
labelBgStyle,
|
labelBgStyle,
|
||||||
labelShowBg,
|
labelShowBg = true,
|
||||||
labelStyle,
|
labelStyle,
|
||||||
markerStart,
|
markerStart,
|
||||||
markerEnd,
|
markerEnd,
|
||||||
style,
|
style,
|
||||||
|
pointerRadius = 2,
|
||||||
}) {
|
}) {
|
||||||
return [
|
return [
|
||||||
h('path', {
|
h('path', {
|
||||||
@@ -28,6 +29,15 @@ const BaseEdge: FunctionalComponent<BaseEdgeProps> = function ({
|
|||||||
'marker-end': markerEnd,
|
'marker-end': markerEnd,
|
||||||
'marker-start': markerStart,
|
'marker-start': markerStart,
|
||||||
}),
|
}),
|
||||||
|
pointerRadius
|
||||||
|
? h('path', {
|
||||||
|
'style': 'opacity: 0',
|
||||||
|
'd': path,
|
||||||
|
'class': 'vue-flow__edge-pointer',
|
||||||
|
'stroke': 'transparent',
|
||||||
|
'stroke-width': pointerRadius,
|
||||||
|
})
|
||||||
|
: null,
|
||||||
label
|
label
|
||||||
? h(EdgeText, {
|
? h(EdgeText, {
|
||||||
x: labelX,
|
x: labelX,
|
||||||
@@ -56,6 +66,7 @@ BaseEdge.props = [
|
|||||||
'markerStart',
|
'markerStart',
|
||||||
'markerEnd',
|
'markerEnd',
|
||||||
'style',
|
'style',
|
||||||
|
'pointerRadius',
|
||||||
]
|
]
|
||||||
BaseEdge.inheritAttrs = false
|
BaseEdge.inheritAttrs = false
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const BezierEdge: FunctionalComponent<EdgeProps> = function ({
|
|||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
style,
|
style,
|
||||||
|
pointerRadius,
|
||||||
}) {
|
}) {
|
||||||
const [path, labelX, labelY] = getBezierPath({
|
const [path, labelX, labelY] = getBezierPath({
|
||||||
sourceX,
|
sourceX,
|
||||||
@@ -44,6 +45,7 @@ const BezierEdge: FunctionalComponent<EdgeProps> = function ({
|
|||||||
style,
|
style,
|
||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
|
pointerRadius,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ BezierEdge.props = [
|
|||||||
'markerEnd',
|
'markerEnd',
|
||||||
'markerStart',
|
'markerStart',
|
||||||
'style',
|
'style',
|
||||||
|
'pointerRadius',
|
||||||
]
|
]
|
||||||
BezierEdge.inheritAttrs = false
|
BezierEdge.inheritAttrs = false
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ({
|
|||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
style,
|
style,
|
||||||
|
pointerRadius,
|
||||||
}) {
|
}) {
|
||||||
const [path, labelX, labelY] = getSimpleBezierPath({
|
const [path, labelX, labelY] = getSimpleBezierPath({
|
||||||
sourceX,
|
sourceX,
|
||||||
@@ -42,6 +43,7 @@ const SimpleBezierEdge: FunctionalComponent<EdgeProps> = function ({
|
|||||||
style,
|
style,
|
||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
|
pointerRadius,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +63,7 @@ SimpleBezierEdge.props = [
|
|||||||
'markerEnd',
|
'markerEnd',
|
||||||
'markerStart',
|
'markerStart',
|
||||||
'style',
|
'style',
|
||||||
|
'pointerRadius',
|
||||||
]
|
]
|
||||||
SimpleBezierEdge.inheritAttrs = false
|
SimpleBezierEdge.inheritAttrs = false
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({
|
|||||||
borderRadius,
|
borderRadius,
|
||||||
offset,
|
offset,
|
||||||
style,
|
style,
|
||||||
|
pointerRadius,
|
||||||
}) {
|
}) {
|
||||||
const [path, labelX, labelY] = getSmoothStepPath({
|
const [path, labelX, labelY] = getSmoothStepPath({
|
||||||
sourceX,
|
sourceX,
|
||||||
@@ -46,6 +47,7 @@ const SmoothStepEdge: FunctionalComponent<SmoothStepEdgeProps> = function ({
|
|||||||
style,
|
style,
|
||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
|
pointerRadius,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +69,7 @@ SmoothStepEdge.props = [
|
|||||||
'markerEnd',
|
'markerEnd',
|
||||||
'markerStart',
|
'markerStart',
|
||||||
'style',
|
'style',
|
||||||
|
'pointerRadius',
|
||||||
]
|
]
|
||||||
SmoothStepEdge.inheritAttrs = false
|
SmoothStepEdge.inheritAttrs = false
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ StepEdge.props = [
|
|||||||
'markerEnd',
|
'markerEnd',
|
||||||
'markerStart',
|
'markerStart',
|
||||||
'style',
|
'style',
|
||||||
|
'pointerRadius',
|
||||||
]
|
]
|
||||||
StepEdge.inheritAttrs = false
|
StepEdge.inheritAttrs = false
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const StraightEdge: FunctionalComponent<EdgeProps> = function ({
|
|||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
style,
|
style,
|
||||||
|
pointerRadius,
|
||||||
}) {
|
}) {
|
||||||
const [path, labelX, labelY] = getStraightPath({ sourceX, sourceY, targetX, targetY })
|
const [path, labelX, labelY] = getStraightPath({ sourceX, sourceY, targetX, targetY })
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ const StraightEdge: FunctionalComponent<EdgeProps> = function ({
|
|||||||
style,
|
style,
|
||||||
markerEnd,
|
markerEnd,
|
||||||
markerStart,
|
markerStart,
|
||||||
|
pointerRadius,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ StraightEdge.props = [
|
|||||||
'markerEnd',
|
'markerEnd',
|
||||||
'markerStart',
|
'markerStart',
|
||||||
'style',
|
'style',
|
||||||
|
'pointerRadius',
|
||||||
]
|
]
|
||||||
StraightEdge.inheritAttrs = false
|
StraightEdge.inheritAttrs = false
|
||||||
|
|
||||||
|
|||||||
@@ -190,6 +190,7 @@ const Wrapper = defineComponent({
|
|||||||
targetY,
|
targetY,
|
||||||
sourceHandleId: edge.sourceHandle,
|
sourceHandleId: edge.sourceHandle,
|
||||||
targetHandleId: edge.targetHandle,
|
targetHandleId: edge.targetHandle,
|
||||||
|
pointerRadius: edge.pointerRadius,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ export interface Edge<Data = ElementData, CustomEvents extends Record<string, Cu
|
|||||||
style?: Styles | StyleFunc<GraphEdge<Data, CustomEvents>>
|
style?: Styles | StyleFunc<GraphEdge<Data, CustomEvents>>
|
||||||
/** Is edge hidden */
|
/** Is edge hidden */
|
||||||
hidden?: boolean
|
hidden?: boolean
|
||||||
|
/** Radius of mouse event triggers (to ease selecting edges), defaults to 2 */
|
||||||
|
pointerRadius?: number
|
||||||
/** Overwrites current edge type */
|
/** Overwrites current edge type */
|
||||||
template?: EdgeComponent
|
template?: EdgeComponent
|
||||||
/** Additional data that is passed to your custom components */
|
/** Additional data that is passed to your custom components */
|
||||||
@@ -145,6 +147,7 @@ export interface EdgeProps<Data = ElementData, CustomEvents = {}> {
|
|||||||
markerStart?: string
|
markerStart?: string
|
||||||
markerEnd?: string
|
markerEnd?: string
|
||||||
curvature?: number
|
curvature?: number
|
||||||
|
pointerRadius?: number
|
||||||
data: Data
|
data: Data
|
||||||
/** contextual and custom events of edge */
|
/** contextual and custom events of edge */
|
||||||
events: EdgeEventsOn<CustomEvents>
|
events: EdgeEventsOn<CustomEvents>
|
||||||
@@ -180,6 +183,7 @@ export interface SmoothStepEdgeProps<Data = ElementData, CustomEvents = {}> exte
|
|||||||
markerEnd?: string
|
markerEnd?: string
|
||||||
borderRadius?: number
|
borderRadius?: number
|
||||||
offset?: number
|
offset?: number
|
||||||
|
pointerRadius?: number
|
||||||
data: Data
|
data: Data
|
||||||
/** contextual and custom events of edge */
|
/** contextual and custom events of edge */
|
||||||
events: EdgeEventsOn<CustomEvents>
|
events: EdgeEventsOn<CustomEvents>
|
||||||
@@ -198,4 +202,5 @@ export interface BaseEdgeProps {
|
|||||||
labelBgBorderRadius?: number
|
labelBgBorderRadius?: number
|
||||||
markerStart?: string
|
markerStart?: string
|
||||||
markerEnd?: string
|
markerEnd?: string
|
||||||
|
pointerRadius?: number
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ export const parseEdge = (edge: Edge, defaults?: Partial<GraphEdge>): GraphEdge
|
|||||||
data: shallowReactive(edge.data || defaults?.data || {}),
|
data: shallowReactive(edge.data || defaults?.data || {}),
|
||||||
events: shallowReactive(edge.events || defaults?.events || {}),
|
events: shallowReactive(edge.events || defaults?.events || {}),
|
||||||
label: (edge.label && !isString(edge.label) ? markRaw(edge.label) : edge.label) || defaults?.label,
|
label: (edge.label && !isString(edge.label) ? markRaw(edge.label) : edge.label) || defaults?.label,
|
||||||
|
pointerRadius: edge.pointerRadius || defaults?.pointerRadius || 2,
|
||||||
} as GraphEdge)
|
} as GraphEdge)
|
||||||
: defaults
|
: defaults
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user