diff --git a/core/core-frontend/src/views/chart/components/js/g2plot_tooltip_carousel.ts b/core/core-frontend/src/views/chart/components/js/g2plot_tooltip_carousel.ts index 75bcb42d06..d8379b78dd 100644 --- a/core/core-frontend/src/views/chart/components/js/g2plot_tooltip_carousel.ts +++ b/core/core-frontend/src/views/chart/components/js/g2plot_tooltip_carousel.ts @@ -270,7 +270,8 @@ class ChartCarouselTooltip { this.chart.customAttr?.tooltip?.show && this.chart.customAttr?.tooltip?.carousel?.enable && this.values.length > 0 && - this.chartIsVisible + this.chartIsVisible && + !this.hasParentWithSwitchHidden(this.plot.chart.ele) ) } @@ -434,6 +435,21 @@ class ChartCarouselTooltip { return tooltipCtl.tooltip?.cfg?.container } + /** + * 判断元素是否有父元素包含 'switch-hidden' 类 + * @param element + */ + public hasParentWithSwitchHidden(element: HTMLElement) { + let parent = element.parentElement + while (parent) { + if (parent.classList.contains('switch-hidden')) { + return true + } + parent = parent.parentElement + } + return false + } + /** * 绑定事件监听 * */ @@ -475,8 +491,11 @@ class ChartCarouselTooltip { // 定义鼠标滚轮事件处理函数 const handleMouseWheel = this.debounce(() => { CAROUSEL_MANAGER_INSTANCES?.forEach(instance => { - instance.paused() - instance.resume() + // 如果元素有父元素不包含 'switch-hidden' 类,则继续轮播 + if (!this.hasParentWithSwitchHidden(instance.plot.chart.ele)) { + instance.paused() + instance.resume() + } }) }, 50) // 定义 touchmove 事件处理函数(移动端) diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index f38b052325..f7e94358e5 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -1784,6 +1784,10 @@ export function configPlotTooltipEvent> if (!tooltipCtl) { return } + const tooltipInstance = ChartCarouselTooltip.getInstanceByContainer(chart.container) + if (tooltipInstance && tooltipInstance.hasParentWithSwitchHidden(plot.chart.ele)) { + return + } // 处理 tooltip 与下拉菜单的显示冲突问题 const viewTrackBarElement = document.getElementById('view-track-bar-' + chart.id) const event = plot.chart.interactions.tooltip?.context?.event