G6 icon indicating copy to clipboard operation
G6 copied to clipboard

如何实现拖拽节点时让节点在某条直线上滑动而不跟随鼠标当前位置?

Open LeaveZzz opened this issue 3 years ago • 2 comments

问题描述

拖拽节点时期望节点在某条直线及其延长线上滑动,目前在代码中监听node:drag事件,根据节点实时x坐标通过直线公式修正节点y坐标无效,节点仍然跟随鼠标当前位置。

重现链接

https://codesandbox.io/s/fervent-butterfly-f18v4x?file=/index.js

重现步骤

1.进入页面 2.拖拽红色节点

预期行为

期望拖拽节点时让节点在某条直线及其延长线上滑动而不跟随鼠标当前位置。

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]
  • G6 版本: [4.5.1 ... ]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

LeaveZzz avatar May 09 '23 03:05 LeaveZzz

drag-node behavior 要去掉,计算传的 x 应该是鼠标当前位置的 x

https://codesandbox.io/s/practical-voice-ml5hk4?file=/index.js

Yanyan-Wang avatar May 24 '23 03:05 Yanyan-Wang

drag-node behavior 要去掉,计算传的 x 应该是鼠标当前位置的 x

https://codesandbox.io/s/practical-voice-ml5hk4?file=/index.js

感谢解答

LeaveZzz avatar May 24 '23 06:05 LeaveZzz