antvis/G6

[Bug]: When the mouse is placed on a custom node, the action wheel cannot zoom in and out of the canvas #6664

irelib posted onGitHub

Describe the bug / 问题描述

鼠标放在自定义节点上,操作滚轮无法对画布进行缩放

No response

Steps to Reproduce the Bug or Issue / 重现步骤

No response

G6 Version / G6 版本

🆕 5.x

OS / 操作系统

  • macOS
  • Windows
  • Linux
  • Others / 其他

Browser / 浏览器

  • Chrome
  • Edge
  • Firefox
  • Safari (Limited support / 有限支持)
  • IE (Nonsupport / 不支持)
  • Others / 其他

感谢您提供详细的信息。您提到的问题是当鼠标放在自定义节点上时,无法通过滚轮对画布进行缩放。这可能是由于事件处理或配置的问题。

在G6中,缩放功能通常是通过 mousewheel 事件来实现的。如果自定义节点阻止了该事件的传播,可能会导致无法缩放。

以下是一些可能的解决方案:

  1. 检查事件传播:确保自定义节点没有阻止 mousewheel 事件的传播。可以在自定义节点的事件处理函数中调用 event.stopPropagation() 来防止事件传播。

  2. 配置缩放行为:确保在初始化G6图表时,正确配置了缩放行为。可以通过 graph.get('canvas').set('zoomable', true) 来启用缩放功能。

  3. 调试事件:使用浏览器的开发者工具来调试事件,确保 mousewheel 事件在自定义节点上被正确触发。

如果这些建议没有解决您的问题,您可以提供更多的代码片段或详细信息,以便我能更好地帮助您。

如果您需要进一步的帮助,请随时告诉我。

<details> <summary>🪧 Tips</summary> For further assistance, please describe your question in the comments and @petercat-assistant to start a conversation with me. </details>

posted by petercat-assistant[bot] 4 months ago

如果是 HTML/React 节点,需要自行将节点 pointerEvents 设为 none

posted by Aarebecca 4 months ago

@Aarebecca 除了配置pointerEvents 外,有其他的方法吗?因为 react 节点有自己的 button,graph 也有节点点击的业务,需要处各自理自己的业务逻辑

posted by Rey-Wang 3 months ago

Fund this Issue

$0.00
Funded

Pull requests