From 7226046846b99411c62e41e11dc190421fc4095f Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 13 Mar 2024 15:05:18 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E8=A7=86=E5=9B=BE):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20AntV=20=E8=A1=A8=E6=A0=BC=E6=BB=9A=E5=8A=A8=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=EF=BC=8C=E9=81=BF=E5=85=8D=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/chart/components/ChartComponentS2.vue | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/frontend/src/views/chart/components/ChartComponentS2.vue b/core/frontend/src/views/chart/components/ChartComponentS2.vue index 05e82e7073..8e2360272d 100644 --- a/core/frontend/src/views/chart/components/ChartComponentS2.vue +++ b/core/frontend/src/views/chart/components/ChartComponentS2.vue @@ -527,7 +527,7 @@ export default { clearTimeout(this.scrollTimer) const customAttr = JSON.parse(this.chart.customAttr) const senior = JSON.parse(this.chart.senior) - if (senior && senior.scrollCfg && senior.scrollCfg.open && (this.chart.type === 'table-normal' || (this.chart.type === 'table-info' && !this.showPage))) { + if (senior?.scrollCfg?.open && (this.chart.type === 'table-normal' || (this.chart.type === 'table-info' && !this.showPage))) { // 防止多次渲染 this.myChart.facet.timer?.stop() if (this.myChart.store.get('scrollY') !== 0) { @@ -536,11 +536,19 @@ export default { } // 平滑滚动,兼容原有的滚动速率设置 // 假设原设定为 2 行间隔 2 秒,换算公式为: 滚动到底部的时间 = 未展示部分行数 / 2行 * 2秒 + const offsetHeight = document.getElementById(this.chartId).offsetHeight + // 没显示就不滚了 + if (!offsetHeight) { + return + } const rowHeight = customAttr.size.tableItemHeight const headerHeight = customAttr.size.tableTitleHeight const scrollBarSize = this.myChart.theme.scrollBar.size - const offsetHeight = document.getElementById(this.chartId).offsetHeight const scrollHeight = rowHeight * this.chart.data.tableRow.length + headerHeight - offsetHeight + scrollBarSize + // 显示内容没撑满 + if (scrollHeight < scrollBarSize) { + return + } const viewHeight = offsetHeight - headerHeight - scrollBarSize const scrollViewCount = this.chart.data.tableRow.length - viewHeight / rowHeight const duration = scrollViewCount / senior.scrollCfg.row * senior.scrollCfg.interval