@@ -32,6 +32,7 @@ interface IState {
32
32
endX : number ,
33
33
endY : number ,
34
34
hover : boolean ,
35
+ draging : boolean ,
35
36
}
36
37
37
38
class Anchor extends Component < IProps , IState > {
@@ -50,6 +51,7 @@ class Anchor extends Component<IProps, IState> {
50
51
endX : 0 ,
51
52
endY : 0 ,
52
53
hover : false ,
54
+ draging : false ,
53
55
} ;
54
56
55
57
this . dragHandler = createDrag ( {
@@ -59,8 +61,6 @@ class Anchor extends Component<IProps, IState> {
59
61
} ) ;
60
62
}
61
63
onDragStart = ( ) => {
62
- console . log ( 'onDragStart' ) ;
63
-
64
64
const {
65
65
x, y, nodeModel, graphModel,
66
66
} = this . props ;
@@ -75,8 +75,6 @@ class Anchor extends Component<IProps, IState> {
75
75
} ) ;
76
76
} ;
77
77
onDraging = ( { deltaX, deltaY } ) => {
78
- console . log ( 'onDraging' ) ;
79
-
80
78
const { endX, endY } = this . state ;
81
79
const { graphModel, nodeModel } = this . props ;
82
80
const { transformMatrix, nodes } = graphModel ;
@@ -88,6 +86,7 @@ class Anchor extends Component<IProps, IState> {
88
86
this . setState ( {
89
87
endX : x ,
90
88
endY : y ,
89
+ draging : true ,
91
90
} ) ;
92
91
const info = targetNodeInfo ( { x : endX , y : endY } , nodes ) ;
93
92
if ( info ) {
@@ -117,15 +116,19 @@ class Anchor extends Component<IProps, IState> {
117
116
}
118
117
} ;
119
118
onDragEnd = ( ) => {
120
- console . log ( 'onDragEnd' ) ;
121
119
this . checkEnd ( ) ;
122
120
this . setState ( {
123
121
startX : 0 ,
124
122
startY : 0 ,
125
123
endX : 0 ,
126
124
endY : 0 ,
125
+ draging : false ,
127
126
} ) ;
128
127
} ;
128
+ onDblClick = ( ) => {
129
+ const { graphModel, nodeModel } = this . props ;
130
+ graphModel . setElementStateById ( nodeModel . id , ElementState . TEXT_EDIT ) ;
131
+ } ;
129
132
130
133
setHover ( isHover : boolean , ev : MouseEvent ) : void {
131
134
const { nodeDraging, setHoverOFF } = this . props ;
@@ -147,13 +150,15 @@ class Anchor extends Component<IProps, IState> {
147
150
// nodeModel.setSelected(false);
148
151
/* 创建连线 */
149
152
const { nodes, edgeType } = graphModel ;
150
- const { endX, endY } = this . state ;
153
+ const { endX, endY, draging } = this . state ;
151
154
const info = targetNodeInfo ( { x : endX , y : endY } , nodes ) ;
152
155
// 为了保证鼠标离开的时候,将上一个节点状态重置为正常状态。
153
156
if ( this . preTargetNode && this . preTargetNode . state !== ElementState . DEFAULT ) {
154
157
this . preTargetNode . setElementState ( ElementState . DEFAULT ) ;
155
158
this . preTargetNode . setAnchorActive ( - 1 ) ;
156
159
}
160
+ // 没有draging就结束连线
161
+ if ( ! draging ) return ;
157
162
if ( info ) {
158
163
const targetNode = info . node ;
159
164
const {
@@ -208,7 +213,7 @@ class Anchor extends Component<IProps, IState> {
208
213
} = this . props ;
209
214
return (
210
215
// className="lf-anchor" 作为下载时,需要将锚点删除的依据,不要修改,svg结构也不要做修改否则会引起下载bug
211
- < g className = "lf-anchor" >
216
+ < g className = "lf-anchor" onDblClick = { this . onDblClick } >
212
217
{ hover || activeAnchor === anchorIndex ? (
213
218
< Circle
214
219
className = "lf-node-anchor-hover"
0 commit comments