From 2cfd1ed038abef97b45c8c4989ab73e038ff3c90 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Mon, 11 Aug 2025 11:44:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=A4=9A=E4=B8=AAtab=E9=A1=B5=EF=BC=8C=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=94=99=E4=B9=B1=EF=BC=8C=E4=BC=9A=E6=8A=8A?= =?UTF-8?q?tab2=E7=9A=84=E6=8F=90=E7=A4=BA=E6=98=BE=E7=A4=BA=E5=88=B0tab1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20#16271?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/g2plot_tooltip_carousel.ts | 25 ++++++++++++++++--- .../components/js/panel/common/common_antv.ts | 4 +++ 2 files changed, 26 insertions(+), 3 deletions(-) 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