antvis/G6

tooltip 在有滚动条的时候显示位置不准确 #4533

git-hongxia posted onGitHub

问题描述

tooltip 在有滚动条的时候显示位置不准确

重现链接

重现步骤

预期行为

tooltip 在滚动的前提下也能正常显示

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox]
  • G6 版本: [4.5.1 ... ]

屏幕截图或视频(可选)

25d653fb3d16d536745e5ff083fab3c

箭头处为设置的tooltip显示位置 当滚动条滚动时 tooltip位置发生偏移 滚动条滚动距离大 tooltip不显示(应该是便宜位置远着不着了)

b9827be609d85a9a4cca386a95463de

补充说明(可选)

No response


有解决方法了吗

posted by icemanjin almost 2 years ago
   const jtoolTip:= document.createElement('div')
  jtoolTip.classList.add('g6-component-tooltip')
  const tipContainer = document.querySelector('#drag') 
  graph.value.on('node:mouseover', (evt: any) => {
    const { item } = evt
    const model = item.getModel()
    const zoom = graph.value.getZoom()
    const canvas = graph.value.get('canvas')
    const canvasBBox = canvas.getCanvasBBox()
    const canvasLeft = canvasBBox.minX
    const canvasTop = canvasBBox.minY
    jtoolTip.innerHTML = model.name
    jtoolTip.style.position = 'absolute'
    jtoolTip.style.top = (evt.clientY + canvasTop - 8) * zoom + 'px'
    jtoolTip.style.left =
      (canvasLeft + model.x + model.size[0] + 6) * zoom + 'px'
    if (tipContainer.childNodes.length <= 1) {
      tipContainer.appendChild(jtoolTip)
    } else {
      jtoolTip.style.display = ''
    }
  })

  // 监听鼠标离开节点事件
  graph.value.on('node:mouseout', () => {
    jtoolTip.style.display = 'none'
  })

可以先这样处理

posted by icemanjin almost 2 years ago

自定义 DOM 作为 tooltip 看看是否可行,挂载方式:https://g6.antv.antgroup.com/manual/advanced/coordinate-system

posted by Yanyan-Wang almost 2 years 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