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

fix: fix DragndropPlugin #1742

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open

fix: fix DragndropPlugin #1742

wants to merge 1 commit into from

Conversation

mivui
Copy link

@mivui mivui commented Jul 19, 2024

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

antvis/G6#5619

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English fixed an issue where G6 drag-and-drop events could not capture subgraphs such as port
🇨🇳 Chinese 修复G6拖拽事件捕获不到子图形问题例如port

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@Aarebecca
Copy link
Contributor

@mivui Hi~,可以描述一下现有逻辑的问题以及你的改动如何解决该问题的吗?

@mivui
Copy link
Author

mivui commented Sep 4, 2024

问题复现

import { Graph, NodeEvent } from '@antv/g6';

const graph = new Graph({
  container: 'container',
  data: {
    nodes: [
      {
        id: 'node1',
        type:'rect',
        style: {
          portR: 6,
          ports: [
            {
              placement: 'left',
            },
            {
              placement: 'right',
            },
          ],
        },
      },
      {
        id: 'node2',
        type:'rect',
        style: {
          portR: 6,
          ports: [
            {
              placement: 'left',
            },
            {
              placement: 'right',
            },
          ],
        },
      },
    ],
    edges: [],
  },
  layout: {
    type: 'grid',
  },
  behaviors: [
    {
      type: 'create-edge',
      trigger: 'drag',
      style: {
        fill: 'red',
        lineWidth: 2,
      },
      enable: (e) => {
        console.log(e.originalTarget);
        //TODO:只能通过port完成连线
        //darg无法获取port图形, e.originalTarget 为 Rect类型 (父节点图形)
        return true;
      },
    },
    {
      type: 'drag-element',
      enable: (e) => {
        console.log(e.originalTarget);
        //TODO: port不能拖拽需完成连线功能
        //darg无法获取port图形, e.originalTarget 为  Rect类型 (父节点图形)
        return true;
      },
    },
  ],
});

graph.on(NodeEvent.CLICK, (event) => {
  const { originalTarget } = event;
  //单击可以获取port图形 e.originalTarget 为 Circle类型
  console.log(originalTarget);
});


graph.render();

如何修复

通过具体图形dispatchEvent

@mivui
Copy link
Author

mivui commented Oct 10, 2024

@Aarebecca 是什么阻止了合并?或者是否提供可以只能通过端口连线功能。

@Aarebecca
Copy link
Contributor

@wang1212 可能需要评估一下

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

Successfully merging this pull request may close these issues.

2 participants