Skip to content

Commit d9c2f7d

Browse files
committed
fix: 修复仍容易出现节点点击后触发拖拽问题
1 parent 4c56d67 commit d9c2f7d

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
4242
mouseUpDrag?: boolean
4343
startTime?: number
4444
modelDisposer: IReactionDisposer
45+
mouseDownPosition?: LogicFlow.Position
4546

4647
constructor(props: IProps) {
4748
super()
@@ -88,9 +89,9 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
8889
}
8990
}
9091

91-
componentDidMount() { }
92+
componentDidMount() {}
9293

93-
componentDidUpdate() { }
94+
componentDidUpdate() {}
9495

9596
abstract getShape(): h.JSX.Element | null
9697

@@ -249,6 +250,10 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
249250
} = graphModel
250251
model.isDragging = true
251252
const { clientX, clientY } = event!
253+
const { x: mouseDownX, y: mouseDownY } = this.mouseDownPosition!
254+
if (clientX - mouseDownX > gridSize || clientY - mouseDownY > gridSize) {
255+
model.isDragging = true
256+
}
252257
let {
253258
canvasOverlayPosition: { x, y },
254259
} = graphModel.getPointByClient({
@@ -342,7 +347,7 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
342347
const { model, graphModel } = this.props
343348
// 这里会有一种极端情况:当网格大小是1或者关闭网格吸附时,用触摸板点击节点会触发拖拽事件导致节点无法选中
344349
// 当触摸板点击节点时,为了防止误触发拖拽导致节点无法选中,允许在非拖拽状态且时间间隔小于100ms时触发点击事件
345-
if (!isDragging && timeInterval > 100) return
350+
if (!isDragging && timeInterval > 300) return
346351
if (!isDragging) {
347352
this.onDragEnd()
348353
this.handleMouseUp()
@@ -433,6 +438,7 @@ export abstract class BaseNode<P extends IProps = IProps> extends Component<
433438

434439
handleMouseDown = (ev: MouseEvent) => {
435440
const { model, graphModel } = this.props
441+
this.mouseDownPosition = { x: ev.clientX, y: ev.clientY }
436442
this.startTime = new Date().getTime()
437443
const { editConfigModel } = graphModel
438444
if (editConfigModel.adjustNodePosition && model.draggable) {

0 commit comments

Comments
 (0)