antvis/G6

type为quadratic类型的边,当鼠标放在边的两端时无法触发鼠标事件 #4970

ZhOUCFff posted onGitHub

问题描述

当quadratic类型的边的长度超过一定值时,边的两端会出现一部分中空区域,无法触发边的交互事件。 代码:

import G6 from '@antv/g6';

const data = { nodes: [ { id: '0', x: 0, y: 100, }, { id: '1', x: 1200, y: 500, }, ], edges: [ // Built-in polyline { source: '0', target: '1', }, ], };

const width = document.getElementById('container').scrollWidth; const height = document.getElementById('container').scrollHeight || 500; const graph = new G6.Graph({ container: 'container', width, height, fitCenter: true, linkCenter: true, modes: { default: ['zoom-canvas', 'drag-canvas'], }, defaultEdge: { type: 'quadratic', style: { lineWidth: 3, }, }, edgeStateStyles: { active: { lineWidth: 3, }, selected: { lineWidth: 3, }, }, });

graph.data(data); graph.render();

graph.on('edge:mouseenter', (evt) => { const { item } = evt; graph.setItemState(item, 'active', true); });

graph.on('edge:mouseleave', (evt) => { const { item } = evt; graph.setItemState(item, 'active', false); });

graph.on('edge:click', (evt) => { const { item } = evt; graph.setItemState(item, 'selected', true); }); graph.on('canvas:click', (evt) => { graph.getEdges().forEach((edge) => { graph.clearItemStates(edge); }); });

重现链接

https://stackblitz.com/edit/react-6hrru8?file=index.js

重现步骤

  1. 进入页面
  2. 使用鼠标滚轮放大到最大
  3. 将鼠标移入边的最末端
  4. 会发现无法触发边的hover或者select

预期行为

希望整条边都能触发边的交互事件,但是两端出现了不能交互的一部分边

平台

  • 操作系统: [Windows.]
  • 网页浏览器: [Google Chrome]
  • G6 版本: [4.8.22 ]

屏幕截图或视频(可选)

https://github.com/antvis/G6/assets/53998318/f07ef853-d81c-4fb8-99d6-16d45fbc2da7

补充说明(可选)

No response


posted by Yanyan-Wang over 1 year ago

尝试将命中范围扩大 lineAppendWidth https://g6.antv.antgroup.com/manual/middle/elements/edges/default-edge#%E6%A0%B7%E5%BC%8F%E5%B1%9E%E6%80%A7-style

我加了,作用微乎其微

posted by ZhOUCFff over 1 year ago

@Yanyan-Wang 我也遇到了同样的问题,到边上了就触发了进入「节点」的事件,但是实际还在「边」上。这个问题和响应区粗细没有关系。这个有办法改吗

posted by Dawnwangzi over 1 year ago

我尝试把边的层级提高,可以临时避免这个问题。但是不确定会不会产生性能问题。

      const edges = graph.getEdges();
      edges.forEach((edge) => {
        edge.toFront();
      });
posted by Dawnwangzi over 1 year ago

我尝试把边的层级提高,可以临时避免这个问题。但是不确定会不会产生性能问题。

      const edges = graph.getEdges();
      edges.forEach((edge) => {
        edge.toFront();
      });

这个应该没有啥性能问题,但是我加了没生效,请问有完整的demo吗

posted by ZhOUCFff over 1 year ago

我尝试把边的层级提高,可以临时避免这个问题。但是不确定会不会产生性能问题。

      const edges = graph.getEdges();
      edges.forEach((edge) => {
        edge.toFront();
      });

这个应该没有啥性能问题,但是我加了没生效,请问有完整的demo吗

例子在这里 https://g6.antv.antgroup.com/manual/middle/elements/methods/element-index#step-3-%E7%9B%91%E5%90%AC%E9%BC%A0%E6%A0%87%E4%BA%8B%E4%BB%B6%E5%B9%B6%E6%94%B9%E5%8F%98%E7%9B%AE%E6%A0%87%E5%85%83%E7%B4%A0%E5%B1%82%E7%BA%A7

可能是没有加 groupByTypes: false,

posted by Dawnwangzi over 1 year ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests