diff --git a/src/components/Edges/EdgeAnchor.tsx b/src/components/Edges/EdgeAnchor.tsx
new file mode 100644
index 00000000..a452ef39
--- /dev/null
+++ b/src/components/Edges/EdgeAnchor.tsx
@@ -0,0 +1,42 @@
+import React from 'react';
+
+import { Position } from '../../types';
+
+const shiftX = (x: number, shift: number, position: Position) => {
+ if (position === Position.Left) return x - shift;
+ if (position === Position.Right) return x + shift;
+ return x;
+}
+
+const shiftY = (y: number, shift: number, position: Position) => {
+ if (position === Position.Top) return y - shift;
+ if (position === Position.Bottom) return y + shift;
+ return y;
+}
+
+export interface EdgeAnchorProps {
+ className?: string
+ position: Position
+ centerX: number
+ centerY: number
+ radius?: number
+}
+
+export const EdgeAnchor = ({
+ className = "react-flow__edgeupdater",
+ position,
+ centerX,
+ centerY,
+ radius = 10
+}: EdgeAnchorProps): JSX.Element => {
+ return (
+
+ );
+}
diff --git a/src/components/Edges/EdgeAnchors.tsx b/src/components/Edges/EdgeAnchors.tsx
deleted file mode 100644
index a8717671..00000000
--- a/src/components/Edges/EdgeAnchors.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import React from 'react';
-
-import { WrapEdgeProps, Position } from '../../types';
-
-const radiusEdgeUpdater = 10;
-
-const shiftX = (position: Position, x: number) => {
- if (position === Position.Right) return x + radiusEdgeUpdater;
- if (position === Position.Left) return x - radiusEdgeUpdater;
- return x;
-}
-
-const shiftY = (position: Position, y: number) => {
- if (position === Position.Bottom) return y + radiusEdgeUpdater;
- if (position === Position.Top) return y - radiusEdgeUpdater;
- return y;
-}
-
-export const EdgeAnchorStart = ({
- sourceX,
- sourceY,
- sourcePosition,
-}: WrapEdgeProps): JSX.Element => {
- return (
-
- );
-}
-
-export const EdgeAnchorEnd = ({
- targetX,
- targetY,
- targetPosition,
-}: WrapEdgeProps): JSX.Element => {
- return (
-
- );
-}
diff --git a/src/components/Edges/wrapEdge.tsx b/src/components/Edges/wrapEdge.tsx
index 657de81d..cc3152ca 100644
--- a/src/components/Edges/wrapEdge.tsx
+++ b/src/components/Edges/wrapEdge.tsx
@@ -4,44 +4,42 @@ import cc from 'classcat';
import { useStoreActions, useStoreState } from '../../store/hooks';
import { Edge, EdgeProps, WrapEdgeProps } from '../../types';
import { onMouseDown } from '../../components/Handle/handler';
-import { EdgeAnchorStart, EdgeAnchorEnd } from './EdgeAnchors';
+import { EdgeAnchor } from './EdgeAnchor';
export default (EdgeComponent: ComponentType) => {
- const EdgeWrapper = (props: WrapEdgeProps): JSX.Element | null => {
- const {
- id,
- className,
- type,
- data,
- onClick,
- selected,
- animated,
- label,
- labelStyle,
- labelShowBg,
- labelBgStyle,
- labelBgPadding,
- labelBgBorderRadius,
- style,
- arrowHeadType,
- source,
- target,
- sourceX,
- sourceY,
- targetX,
- targetY,
- sourcePosition,
- targetPosition,
- elementsSelectable,
- markerEndId,
- isHidden,
- sourceHandleId,
- targetHandleId,
- handleEdgeUpdate,
- onConnectEdge,
- onContextMenu,
- } = props;
-
+ const EdgeWrapper = ({
+ id,
+ className,
+ type,
+ data,
+ onClick,
+ selected,
+ animated,
+ label,
+ labelStyle,
+ labelShowBg,
+ labelBgStyle,
+ labelBgPadding,
+ labelBgBorderRadius,
+ style,
+ arrowHeadType,
+ source,
+ target,
+ sourceX,
+ sourceY,
+ targetX,
+ targetY,
+ sourcePosition,
+ targetPosition,
+ elementsSelectable,
+ markerEndId,
+ isHidden,
+ sourceHandleId,
+ targetHandleId,
+ handleEdgeUpdate,
+ onConnectEdge,
+ onContextMenu,
+ }: WrapEdgeProps): JSX.Element | null => {
const addSelectedElements = useStoreActions((actions) => actions.addSelectedElements);
const setConnectionNodeId = useStoreActions((actions) => actions.setConnectionNodeId);
const setPosition = useStoreActions((actions) => actions.setConnectionPosition);
@@ -149,7 +147,11 @@ export default (EdgeComponent: ComponentType) => {
onMouseEnter={onEdgeUpdaterMouseEnter}
onMouseOut={onEdgeUpdaterMouseOut}
>
-
+
)}
) => {
/>
{handleEdgeUpdate && (
-
+
)}