fix(图表): 修复移动端图表开启提示之后不会自动消失 #13276 #14337

This commit is contained in:
wisonic
2025-01-03 17:57:06 +08:00
committed by wisonic-s
parent 8b65cf2bf2
commit ecae1ae3ab

View File

@@ -1343,7 +1343,7 @@ export function configPlotTooltipEvent<O extends PickOptions, P extends Plot<O>>
plot.chart.getTheme().components.tooltip.y = event.clientY
})
// https://github.com/antvis/G2/blob/master/src/chart/controller/tooltip.ts#hideTooltip
plot.on('plot:mouseleave', () => {
plot.on('plot:leave', () => {
const tooltipCtl = plot.chart.getController('tooltip')
if (!tooltipCtl) {
return
@@ -1355,6 +1355,22 @@ export function configPlotTooltipEvent<O extends PickOptions, P extends Plot<O>>
}
tooltipCtl.hideTooltip()
})
// 移动端处理,关闭其他图表的提示
plot.on('plot:touchstart', () => {
const wrapperDom = document.getElementById(G2_TOOLTIP_WRAPPER)
if (wrapperDom) {
const tooltipCtl = plot.chart.getController('tooltip')
if (!tooltipCtl) {
return
}
const container = tooltipCtl.tooltip.cfg.container
for (const ele of wrapperDom.children) {
if (container.id !== ele.id) {
ele.style.display = 'none'
}
}
}
})
}
export const TOOLTIP_TPL =