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

removeTool后同步修改interacting,removeTool无法生效 #3931

Closed
ChaoqiYin opened this issue Sep 25, 2023 · 2 comments · Fixed by #3933
Closed

removeTool后同步修改interacting,removeTool无法生效 #3931

ChaoqiYin opened this issue Sep 25, 2023 · 2 comments · Fixed by #3933

Comments

@ChaoqiYin
Copy link

Describe the bug

class xxx {

public graph?: Graph;

/**
 * 切换到只读状态
 */
public toReadonly(): void {
    // 删除边上删除按钮
    this.graph?.getEdges().forEach((edge) => {
        if (edge.hasTool('button-remove')) {
            edge.removeTool('button-remove');
        }
    });
    // 删除节点上删除按钮
    this.graph?.getNodes().forEach((node) => {
        if (node.hasTool('button-remove')) {
            node.removeTool('button-remove');
        }
    });
    if (this.graph) {
        this.graph.options.interacting = false;
    }
}

/**
 * 切换到编辑状态
 */
public toEdit(): void {
    if (this.graph) {
        this.graph.options.interacting = true;
    }
    // 添加边上删除按钮
    this.graph?.getEdges().forEach((edge) => {
        edge.addTools([
            {
                name: 'button-remove',
                args: { distance: '50%' }
            }
        ]);
    });
    // 添加节点上删除按钮
    this.graph?.getNodes().forEach((node) => {
        node.addTools([
            {
                name: 'button-remove',
                args: { x: '100%', y: 0 }
            }
        ]);
    });
}

}

Your Example Website or App

https://x6.antv.antgroup.com/api/registry/node-tool

Steps to Reproduce the Bug or Issue

在执行了toEdit完成graph的渲染之后,我在3s延迟之后再执行了toReadonly,removeTool不能达到预期效果,但是限制交互可以生效。
如果我给toReadonly的this.graph.options.interacting = false;执行代码加上一个setTimeout,并延迟1s,则removeTool可以生效,但是延迟这个方案并不是很靠谱的方案

Expected behavior

removeTool能使button-remove正常被移除,同时限制交互可以生效

Screenshots or Videos

Jietu20230925-122312-HD.mp4

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 2.11.1]

Additional context

No response

@x6-bot
Copy link
Contributor

x6-bot bot commented Sep 25, 2023

👋 @ChaoqiYin

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.

@x6-bot
Copy link
Contributor

x6-bot bot commented Sep 25, 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 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant