Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report]: v2版本 构造方法中nodeTextDraggable/edgeTextDraggable 属性设置为true无效 无法实现节点文本和连接线文本的拖拽 #1891

Open
eye33 opened this issue Sep 29, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@eye33
Copy link

eye33 commented Sep 29, 2024

发生了什么?

v2版本 构造方法中nodeTextDraggable/edgeTextDraggable 属性设置为true无效 无法实现节点文本和连接线文本的拖拽 (可用状态时 鼠标位于文本上回有移动的鼠标指针模式 且文本可拖动)
v1版本 这2个属性可用

// 创建画布实例,也可以 new Core.LogicFLow
const lf = new Core.default({
container: document.querySelector('#container'),
width: 700,
height: 500,
grid: true,
nodeTextDraggable:true,
edgeTextDraggable:true,
})

示例地址
https://github.com/eye33/logicFlow_demo_v2/blob/main/index.html

logicflow/core版本

2.x

logicflow/extension版本

2.x

logicflow/engine版本

No response

浏览器&环境

Chrome, Microsoft Edge

@eye33 eye33 added the bug Something isn't working label Sep 29, 2024
@ChangeSuger
Copy link
Collaborator

允许文本拖动的逻辑在2.0版本更新后有变化,详见:

- 优化允许文本拖动的逻辑判断 -> nodeTextDraggable && draggable 才可以允许拖动

想要实现文本拖拽的话,可以参考以下修改:

// 修改前的节点定义
{
	id: '21',
	type: 'rect',
	x: 100,
	y: 200,
	text: 'rect node',
}

// 修改后的节点定义
{
	id: '21',
	type: 'rect',
	x: 100,
	y: 200,
	text: {
		value: 'rect node',
		x: 100,
		y: 200,
		draggable: true,
	},
}

不过目前文本拖拽的位移计算似乎有问题,可以先看看目前的文本拖拽功能能不能满足实现。

@Yuan-ZW
Copy link
Contributor

Yuan-ZW commented Oct 16, 2024

允许文本拖动的逻辑在2.0版本更新后有变化,详见:

- 优化允许文本拖动的逻辑判断 -> nodeTextDraggable && draggable 才可以允许拖动

为了使节点和边的文本都可以拖拽, 我是不是还得写一段类似这样的代码?

lf.on('text:update', ({ data }) => {
  lf.getModelById(data.id).text.draggable = true
})

这或许有些不合理了, 让原本只要一个配置项就能实现的功能复杂化

我认为也许这么设定会更好些:

  • typeof text.draggable === 'boolean' 时, 以 text.draggable 为准
  • 否则, 以 nodeTextDraggable/edgeTextDraggable 为准

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants