antvis/G6

[Feat]: Applying the combo working principle in v5 to v4 #6799

RackweLLizm posted onGitHub

Describe the feature / 功能描述

https://g6.antv.antgroup.com/en/examples/element/combo/#circle

The example above is a combo made with antv g6 v5. As the node in this combo is dragged, it increases the size of the combo and optimizes the combo frame.

How can I do this behavior in antv g6 v4?

In v4, when I drag the node inside the combo, I can take it out of the combo, I don't want this to happen, I want the node to always stay inside the combo when dragged.

Are you willing to contribute? / 是否愿意参与贡献?

✅ Yes / 是


It seems you are interested in applying the combo working principle from AntV G6 version 5 to version 4. In version 5, the combo automatically adjusts its size when a node is dragged, ensuring the node remains within the combo. However, in version 4, the node can be dragged out of the combo, which is not the desired behavior for your use case.

Unfortunately, I cannot provide a direct solution for version 4 as it might require significant changes to the underlying code or logic, which is not supported in the older version. However, I can suggest a workaround or guide you on how to implement a similar feature:

  1. Custom Drag Behavior: You can implement a custom drag behavior that checks the node's position during the drag event. If the node is about to leave the combo's boundary, you can programmatically adjust its position to keep it inside.

  2. Update Combo Size Manually: You can manually update the combo's size based on the positions of its child nodes. This might involve recalculating the bounding box of the combo whenever a node is moved.

  3. Event Listeners: Use event listeners to monitor node movements and apply constraints to ensure nodes remain within the combo.

If you are willing to contribute, you might consider implementing these features and sharing them with the community. If you need further assistance or specific code examples, feel free to ask!

For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me.

posted by petercat-assistant[bot] 2 months ago
   modes: {
            default: [
                {
                    type: 'drag-node',
                    onlyChangeComboSize: true,
                },
            ],
        },

onlyChangeComboSize:true When set to , it shows the same behavior as antv g6 v5.

posted by RackweLLizm about 2 months ago

Fund this Issue

$0.00
Funded

Pull requests