@@ -35,6 +35,7 @@ export default abstract class BaseNode extends Component<IProps, IState> {
35
35
}
36
36
stepDrag : StepDrag ;
37
37
contextMenuTime : number ;
38
+ mouseUpDrag : boolean ;
38
39
startTime : number ;
39
40
clickTimer : number ;
40
41
modelDisposer : IReactionDisposer ;
@@ -261,13 +262,17 @@ export default abstract class BaseNode extends Component<IProps, IState> {
261
262
const { model } = this . props ;
262
263
model . isDragging = false ;
263
264
} ;
265
+ handleMouseUp = ( ) => {
266
+ const { model } = this . props ;
267
+ this . mouseUpDrag = model . isDragging ;
268
+ } ;
264
269
handleClick = ( e : MouseEvent ) => {
265
270
// 节点拖拽进画布之后,不触发click事件相关emit
266
271
// 点拖拽进画布没有触发mousedown事件,没有startTime,用这个值做区分
272
+ const isDragging = this . mouseUpDrag === false ;
267
273
if ( ! this . startTime ) return ;
268
- const time = new Date ( ) . getTime ( ) - this . startTime ;
269
- if ( time > 200 ) return ; // 事件大于200ms,认为是拖拽, 不触发click事件。
270
274
const { model, graphModel } = this . props ;
275
+ if ( ! isDragging ) return ; // 如果是拖拽, 不触发click事件。
271
276
// 节点数据,多为事件对象数据抛出
272
277
const nodeData = model . getData ( ) ;
273
278
const position = graphModel . getPointByClient ( {
@@ -426,6 +431,7 @@ export default abstract class BaseNode extends Component<IProps, IState> {
426
431
< g
427
432
className = { `${ this . getStateClassName ( ) } ${ className } ` }
428
433
onMouseDown = { this . handleMouseDown }
434
+ onMouseUp = { this . handleMouseUp }
429
435
onClick = { this . handleClick }
430
436
onMouseEnter = { this . setHoverON }
431
437
onMouseOver = { this . setHoverON }
0 commit comments