feat(core): add type to edge updater anchor class
Signed-off-by: braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ interface Props extends HTMLAttributes {
|
|||||||
centerX: number
|
centerX: number
|
||||||
centerY: number
|
centerY: number
|
||||||
radius?: number
|
radius?: number
|
||||||
|
type: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function shiftX(x: number, shift: number, position: Position): number {
|
function shiftX(x: number, shift: number, position: Position): number {
|
||||||
@@ -20,32 +21,24 @@ function shiftY(y: number, shift: number, position: Position): number {
|
|||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
|
|
||||||
const EdgeAnchor: FunctionalComponent<Props> = function ({ radius = 10, centerX = 0, centerY = 0, position = Position.Top }) {
|
const EdgeAnchor: FunctionalComponent<Props> = function ({
|
||||||
const cx = () => {
|
radius = 10,
|
||||||
const val = shiftX(centerX, radius, position)
|
centerX = 0,
|
||||||
|
centerY = 0,
|
||||||
if (isNaN(val)) return 0
|
position = Position.Top,
|
||||||
else return val
|
type,
|
||||||
}
|
}) {
|
||||||
|
|
||||||
const cy = () => {
|
|
||||||
const val = shiftY(centerY, radius, position)
|
|
||||||
|
|
||||||
if (isNaN(val)) return 0
|
|
||||||
else return val
|
|
||||||
}
|
|
||||||
|
|
||||||
return h('circle', {
|
return h('circle', {
|
||||||
class: 'vue-flow__edgeupdater',
|
class: `vue-flow__edgeupdater vue-flow__edgeupdater-${type}`,
|
||||||
cx: cx(),
|
cx: shiftX(centerX, radius, position),
|
||||||
cy: cy(),
|
cy: shiftY(centerY, radius, position),
|
||||||
r: radius,
|
r: radius,
|
||||||
stroke: 'transparent',
|
stroke: 'transparent',
|
||||||
fill: 'transparent',
|
fill: 'transparent',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeAnchor.props = ['radius', 'centerX', 'centerY', 'position']
|
EdgeAnchor.props = ['radius', 'centerX', 'centerY', 'position', 'type']
|
||||||
EdgeAnchor.compatConfig = { MODE: 3 }
|
EdgeAnchor.compatConfig = { MODE: 3 }
|
||||||
|
|
||||||
export default EdgeAnchor
|
export default EdgeAnchor
|
||||||
|
|||||||
Reference in New Issue
Block a user