1- import {
2- ConnectionLineComponentProps ,
3- useStoreState as flowState ,
4- } from 'react-flow-renderer' ;
5- import { useStoreState } from '../../state/Hooks' ;
1+ // import {
2+ // ConnectionLineComponentProps,
3+ // useStore as flowState,
4+ // } from 'react-flow-renderer';
5+ // import { useStoreState } from '../../state/Hooks';
66
7- const getPos = ( isSource : boolean , bounds : DOMRect , transform : number [ ] ) => {
8- let x , y ;
7+ // const getPos = (isSource: boolean, bounds: DOMRect, transform: number[]) => {
8+ // let x, y;
99
10- if ( isSource ) {
11- x = ( bounds . x + bounds . width - transform [ 0 ] ) / transform [ 2 ] ;
12- } else {
13- x = ( bounds . x - transform [ 0 ] ) / transform [ 2 ] ;
14- }
10+ // if (isSource) {
11+ // x = (bounds.x + bounds.width - transform[0]) / transform[2];
12+ // } else {
13+ // x = (bounds.x - transform[0]) / transform[2];
14+ // }
1515
16- y = ( bounds . y + bounds . height / 2 - 60 - transform [ 1 ] ) / transform [ 2 ] ;
16+ // y = (bounds.y + bounds.height / 2 - 60 - transform[1]) / transform[2];
1717
18- return { x, y } ;
19- } ;
18+ // return { x, y };
19+ // };
2020
21- const ConnectionLine = ( { targetX, targetY } : ConnectionLineComponentProps ) => {
22- const connecting = useStoreState ( ( state ) => state . connecting ) ;
23- const altAction = useStoreState ( ( state ) => state . altAction ) ;
24- const transform = flowState ( ( state : any ) => state . transform ) ;
25- const handle = connecting ?. start ?. ref ?. current as Element ;
26- const isSource = connecting ?. start ?. id . connectionHandleType === 'source' ;
21+ // const ConnectionLine = ({ targetX, targetY }: ConnectionLineComponentProps) => {
22+ // const connecting = useStoreState((state) => state.connecting);
23+ // const altAction = useStoreState((state) => state.altAction);
24+ // const transform = flowState((state: any) => state.transform);
25+ // const handle = connecting?.start?.ref?.current as Element;
26+ // const isSource = connecting?.start?.id.connectionHandleType === 'source';
2727
28- if ( ! handle ) {
29- return null ;
30- }
28+ // if (!handle) {
29+ // return null;
30+ // }
3131
32- const bounds = handle . getBoundingClientRect ( ) ;
33- const start = getPos ( isSource , bounds , transform ) ;
34- let end = { x : targetX , y : targetY } ;
35- const dist = 30 * ( isSource ? 1 : - 1 ) ;
36- const invalid = isSource ? end . x < start . x : end . y > start . x ;
37- let color = '#76CDFF' ;
32+ // const bounds = handle.getBoundingClientRect();
33+ // const start = getPos(isSource, bounds, transform);
34+ // let end = { x: targetX, y: targetY };
35+ // const dist = 30 * (isSource ? 1 : -1);
36+ // const invalid = isSource ? end.x < start.x : end.y > start.x;
37+ // let color = '#76CDFF';
3838
39- if ( ! invalid && connecting ?. end ?. ref ) {
40- const snapTo = connecting ?. end . ref ?. current as Element ;
39+ // if (!invalid && connecting?.end?.ref) {
40+ // const snapTo = connecting?.end.ref?.current as Element;
4141
42- if ( snapTo && connecting ?. end ?. ref . current !== handle ) {
43- const snapToBounds = snapTo . getBoundingClientRect ( ) ;
44- end = getPos ( ! isSource , snapToBounds , transform ) ;
45- color = '#0078CA' ;
46- }
47- }
42+ // if (snapTo && connecting?.end?.ref.current !== handle) {
43+ // const snapToBounds = snapTo.getBoundingClientRect();
44+ // end = getPos(!isSource, snapToBounds, transform);
45+ // color = '#0078CA';
46+ // }
47+ // }
4848
49- color = invalid || altAction ? '#F24646' : color ;
49+ // color = invalid || altAction ? '#F24646' : color;
5050
51- return (
52- < g >
53- < path
54- fill = "none"
55- stroke = { color }
56- strokeWidth = { 1.5 }
57- className = "animated"
58- d = { `M${ start . x } ,${ start . y } ${ start . x + dist } ,${ start . y } ${
59- start . x + dist
60- } ,${ start . y } ${ end . x - dist } ,${ end . y } ${ end . x - dist } ,${ end . y } ${
61- end . x
62- } ,${ end . y } `}
63- />
64- < circle
65- cx = { end . x }
66- cy = { end . y }
67- fill = "#fff"
68- r = { 3 }
69- stroke = { color }
70- strokeWidth = { 1.5 }
71- />
72- < circle
73- cx = { start . x - 2 }
74- cy = { start . y }
75- fill = "#fff"
76- r = { 3 }
77- stroke = { color }
78- strokeWidth = { 1.5 }
79- />
80- </ g >
81- ) ;
82- } ;
51+ // return (
52+ // <g>
53+ // <path
54+ // fill="none"
55+ // stroke={color}
56+ // strokeWidth={1.5}
57+ // className="animated"
58+ // d={`M${start.x},${start.y} ${start.x + dist},${start.y} ${
59+ // start.x + dist
60+ // },${start.y} ${end.x - dist},${end.y} ${end.x - dist},${end.y} ${
61+ // end.x
62+ // },${end.y}` }
63+ // />
64+ // <circle
65+ // cx={end.x}
66+ // cy={end.y}
67+ // fill="#fff"
68+ // r={3}
69+ // stroke={color}
70+ // strokeWidth={1.5}
71+ // />
72+ // <circle
73+ // cx={start.x - 2}
74+ // cy={start.y}
75+ // fill="#fff"
76+ // r={3}
77+ // stroke={color}
78+ // strokeWidth={1.5}
79+ // />
80+ // </g>
81+ // );
82+ // };
8383
84- export default ConnectionLine ;
84+ // export default ConnectionLine;
85+
86+ export default { }
0 commit comments