Skip to content

Commit f9fec20

Browse files
DymoneLewisboyongjiong
authored andcommitted
fix: 修复点击节点无法选中问题
1 parent cb181b2 commit f9fec20

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/core/src/view/node/BaseNode.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,17 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
336336
// 节点拖拽进画布之后,不触发click事件相关emit
337337
// 点拖拽进画布没有触发mousedown事件,没有startTime,用这个值做区分
338338
const isDragging = this.mouseUpDrag === false
339+
const curTime = new Date().getTime()
339340
if (!this.startTime) return
341+
const timeInterval = curTime - this.startTime
340342
const { model, graphModel } = this.props
341-
if (!isDragging) return // 如果是拖拽, 不触发click事件。
343+
// 这里会有一种极端情况:当网格大小是1或者关闭网格吸附时,用触摸板点击节点会触发拖拽事件导致节点无法选中
344+
// 所以这里在增加了下面的判断:只有状态是拖拽中且时间间隔小于100ms时,才触发点击事件
345+
if (!isDragging && timeInterval > 100) return
346+
if (!isDragging) {
347+
this.onDragEnd()
348+
this.handleMouseUp()
349+
}
342350
// 节点数据,多为事件对象数据抛出
343351
const nodeData = model.getData()
344352
const position = graphModel.getPointByClient({

0 commit comments

Comments
 (0)