Merge pull request #8472 from dataease/pr@dev@perf_antv_table_scroll

perf(视图): 优化 AntV 表格滚动条件,避免不必要的滚动
This commit is contained in:
wisonic-s 2024-03-13 15:06:12 +08:00 committed by GitHub
commit eb02184a0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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