antvis/G6

icon闪烁问题 #4775

xiaohun254700 posted onGitHub

问题描述

在G6中,鼠标移出的时候,icon图标会闪烁,我觉得好像是重新加载了一遍图片,能避免嘛?还是说就是G6的特性。

重现链接

https://g6.antv.antgroup.com/zh/examples/tree/customItemTree#customEdgeTree

重现步骤

1:进入页面。 2:鼠标移入icon。 3:鼠标移出icon。 4:会出现icon的闪烁问题。

预期行为

我希望看到icon或者图片不闪烁,但是实际上它是闪烁的

平台

  • 操作系统: Windows
  • 网页浏览器: Google
  • G6 版本: 4.8.17

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


还是没解决这个问题,有没有老哥有解决方案

posted by xiaohun254700 over 1 year ago

可以给图形元素的的img属性传入一个Image对象

const iconImage = new Image()

iconImage.src = 'https://gw.alipayobjects.com/mdn/rms_f8c6a0/afts/img/A*Q_FQT6nwEC8AAAAAAAAAAABkARQnAQ'

// ...
 group.addShape('image', {
          attrs: {
            x: 8 - w / 2,
            y: 8 - h / 2,
            width: 24,
            height: 24,
            img: iconImage
          },
          // must be assigned in G6 3.3 and later versions. it can be any string you want, but should be unique in a custom item type
          name: 'image-shape',
});
posted by nieyuyao over 1 year ago

我也遇到了

posted by manmanhunhun 12 months 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