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

使用 custom_node_render 自定义节点后,拖拽卡顿,有时无法拖拽 #566

Closed
aloehh opened this issue Jan 22, 2024 · 6 comments · Fixed by #567
Closed

使用 custom_node_render 自定义节点后,拖拽卡顿,有时无法拖拽 #566

aloehh opened this issue Jan 22, 2024 · 6 comments · Fixed by #567
Assignees
Labels

Comments

@aloehh
Copy link

aloehh commented Jan 22, 2024

No description provided.

@hizzgdev
Copy link
Owner

不用 custom_node_render 时会卡顿吗?
能看看你是怎么实现的 custom_node_render 吗?要不然不知道怎么帮你。

@aloehh
Copy link
Author

aloehh commented Jan 22, 2024

感谢作者回复。
不用 custom_node_render 拖拽正常,不卡顿。以下是我用 custom_node_render的代码 :

const options = {
container: 'jsmind_container', // [必选] 容器的ID
editable: true, // [可选] 是否启用编辑
theme: 'primary', // 主题
view: {
engine: 'canvas', // 思维导图各节点之间线条的绘制引擎
hmargin: 100, // 思维导图距容器外框的最小水平距离
vmargin: 50, // 思维导图距容器外框的最小垂直距离
line_width: 2, // 思维导图线条的粗细
line_color: '#4181FF', // 思维导图线条的颜色
mode: 'side', // 右侧显示
draggable: true,
custom_node_render(jm, element, node) {
console.log(element, node);
element.innerHTML = <div class='node-title-my relative'>${node.topic} <span onclick="alert(11)" >click-me</span></div>;
return true;
}
}

@hizzgdev
Copy link
Owner

hizzgdev commented Jan 22, 2024

你好, @aloehh 我在本地测试的时候并没有出现卡顿的情况,你是在什么环境下测试的?

你有没有试过把 node-title-my relative 这俩样式去掉呢?也可以试试去掉 onclick=alert() 这个再测试一下。

另外,我感觉应该写成 custom_node_render: function(jm, element, node) {...}, 不过你这种写法也能正常运行,在我这里两种写法都没有卡顿的现象。

或者你能录一下屏吗?

@hizzgdev
Copy link
Owner

你说有时无法拖拽 是说有时候鼠标拖不动节点的意思吧。这个我倒是发现了,它其实跟鼠标事件的捕获相关,我看一下是否能从 jsmind 角度来处理。如果不行的话我再跟你说 custom render 要怎么改。

@aloehh
Copy link
Author

aloehh commented Jan 22, 2024

”你说有时无法拖拽 是说有时候鼠标拖不动节点的意思吧“,对, 是这种现象, 有时拖不动节点。
样式以及点击事件我都去掉过, 写法也换过custom_node_render: function(jm, element, node) {...},但 时而无法拖动的现象仍旧存在。
感谢作者大大百忙之中帮忙查问题~

@hizzgdev
Copy link
Owner

Hi @aloehh 这个问题已经在 0.8.1 中修复了,你升级一下试试吧,如有问题的话,可以 reopen 这个 issue.
非常感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants