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

render:done回调函数中无法区分是调用哪个API触发的render:done事件 #2920

Closed
linkun-wang opened this issue Nov 23, 2022 · 5 comments
Labels
type: feature 新功能 Feature/enhancement requests

Comments

@linkun-wang
Copy link
Contributor

linkun-wang commented Nov 23, 2022

问题描述

如果设置了异步加载async:true,那么在调用fromJSON、resetCell、clearCells、addNode、Cell.attr/setAttrs等会触发画布重绘的API时,如果没有配置silent:true,都会触发render:done事件,但是无法区分是在哪个操作/哪个API后触发的该事件。

重现链接

https://codesandbox.io/s/render-donece-shi-smvtib

重现步骤

  1. 进入页面,打开console控制台
  2. 最开始的两个节点和一条edge渲染完成后会触发一次render:done,但是无法区分是addNode还是addEdge触发的
  3. 点击下方"添加节点"按钮,addNode()会触发render:done
  4. 悬浮到edge上,或者鼠标离开edge,或者点击节点,attr()会触发render:done
  5. 点击画布空白处,drawBackground()也会触发render:done
  6. 总之,上述几种场景都会触发render:done事件,但是在render:done回调函数中无法区分是调用哪个API触发的。其中点击节点修改边框颜色时加入了自定义的options--{ testKey: "nodeClick" },但在render:done中没有把该自定义选项带过来

预期行为

  • 希望可以提供一种方式,能够在render:done的回调中区分是哪个动作/调用哪个API触发的
  • 比如在setAttrs时的自定义options:{testKey:'testValue'},可以在render:done回调中接收到该自定义选项

平台

  • 操作系统: Windows
  • 网页浏览器: Google Chrome
  • X6 版本: 1.32.8

屏幕截图或视频(可选)

renderDone频繁触发

补充说明(可选)

业务场景:有一些逻辑仅仅是在初始化完成(比如调用了fromJSON)后才需要执行,但是现在很多操作都可以触发render:done,在render:done回调中无法区分是哪个操作触发的render:done

@x6-bot
Copy link
Contributor

x6-bot bot commented Nov 23, 2022

👋 @linkun-wang

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@NewByVector NewByVector added the feature feature label Dec 23, 2022
@x6-bot
Copy link
Contributor

x6-bot bot commented Dec 23, 2022

👋 @linkun-wang, please use our idea board to request new features.

@x6-bot x6-bot bot closed this as completed Dec 23, 2022
@NewByVector NewByVector reopened this Dec 24, 2022
@NewByVector NewByVector added type: feature 新功能 Feature/enhancement requests and removed feature feature labels Dec 24, 2022
@bighhhh
Copy link

bighhhh commented Aug 18, 2023

render:done回调是移除了吗?api为啥找不到这个回调了

@NewByVector
Copy link
Contributor

@hhzhldhjl 是的,移除了,在 2.x 版本中大部分场景是不需要再回调中操作的。

@x6-bot
Copy link
Contributor

x6-bot bot commented Sep 7, 2024

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature 新功能 Feature/enhancement requests
Projects
None yet
Development

No branches or pull requests

3 participants