From 1207090967da3465e003942c095e3e957306967f Mon Sep 17 00:00:00 2001 From: Luis Oliveira Date: Wed, 8 Feb 2023 21:58:39 -0300 Subject: [PATCH 1/3] feature: fixed header add class on vertical scroll --- packages/ve-table/src/index.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/ve-table/src/index.jsx b/packages/ve-table/src/index.jsx index 4f05bcd8e..cacfd22cd 100644 --- a/packages/ve-table/src/index.jsx +++ b/packages/ve-table/src/index.jsx @@ -360,6 +360,8 @@ export default { isLeftScrolling: false, // is scrolling right isRightScrolling: false, + // is scrolling vertically + isVerticalScrolling: false, // has horizontal scroll bar hasXScrollBar: false, // has vertical scroll bar @@ -588,6 +590,7 @@ export default { isVirtualScroll, isLeftScrolling, isRightScrolling, + isVerticalScrolling, isCellEditing, isAutofillStarting, enableCellSelection, @@ -598,6 +601,7 @@ export default { [clsName("virtual-scroll")]: isVirtualScroll, [clsName("container-left-scrolling")]: isLeftScrolling, [clsName("container-right-scrolling")]: isRightScrolling, + [clsName("container-vertical-scrolling")]: isVerticalScrolling, [clsName("is-cell-editing")]: isCellEditing, [clsName("autofilling")]: isAutofillStarting, // 如果开启单元格选择,则关闭 user-select @@ -2050,10 +2054,10 @@ export default { // set scrolling setScrolling(tableContainerRef) { - if (this.hasFixedColumn) { - const { scrollWidth, clientWidth, scrollLeft } = - tableContainerRef; + const { scrollWidth, clientWidth, scrollLeft, scrollTop } = + tableContainerRef; + if (this.hasFixedColumn) { const { previewTableContainerScrollLeft: previewScrollLeft } = this; @@ -2071,6 +2075,10 @@ export default { this.isLeftScrolling = scrollLeft > 0; this.isRightScrolling = scrollWidth - clientWidth > scrollLeft; } + + if (this.fixedHeader) { + this.isVerticalScrolling = scrollTop > 0; + } }, // set scroll bar status From 5051ebdb2741e19f418cb26d0c6987b51e007531 Mon Sep 17 00:00:00 2001 From: Luis Oliveira Date: Wed, 8 Feb 2023 23:42:56 -0300 Subject: [PATCH 2/3] refactor: create consts only if needed --- packages/ve-table/src/index.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ve-table/src/index.jsx b/packages/ve-table/src/index.jsx index cacfd22cd..080894a4b 100644 --- a/packages/ve-table/src/index.jsx +++ b/packages/ve-table/src/index.jsx @@ -2054,12 +2054,11 @@ export default { // set scrolling setScrolling(tableContainerRef) { - const { scrollWidth, clientWidth, scrollLeft, scrollTop } = - tableContainerRef; - if (this.hasFixedColumn) { - const { previewTableContainerScrollLeft: previewScrollLeft } = - this; + const { scrollWidth, clientWidth, scrollLeft } = + tableContainerRef; + const { previewTableContainerScrollLeft: previewScrollLeft } = + this; // 仅横向滚动需要处理 if ( @@ -2077,6 +2076,7 @@ export default { } if (this.fixedHeader) { + const { scrollTop } = tableContainerRef; this.isVerticalScrolling = scrollTop > 0; } }, From 61c4d3d44a45a4cf3cc620d74b98ac1c2dccbc4c Mon Sep 17 00:00:00 2001 From: Luis Oliveira Date: Wed, 8 Feb 2023 23:47:13 -0300 Subject: [PATCH 3/3] fix: setScrolling function indentation --- packages/ve-table/src/index.jsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/ve-table/src/index.jsx b/packages/ve-table/src/index.jsx index 080894a4b..0469bae61 100644 --- a/packages/ve-table/src/index.jsx +++ b/packages/ve-table/src/index.jsx @@ -2055,10 +2055,11 @@ export default { // set scrolling setScrolling(tableContainerRef) { if (this.hasFixedColumn) { - const { scrollWidth, clientWidth, scrollLeft } = - tableContainerRef; - const { previewTableContainerScrollLeft: previewScrollLeft } = - this; + const { scrollWidth, clientWidth, scrollLeft } = + tableContainerRef; + + const { previewTableContainerScrollLeft: previewScrollLeft } = + this; // 仅横向滚动需要处理 if ( @@ -2076,8 +2077,8 @@ export default { } if (this.fixedHeader) { - const { scrollTop } = tableContainerRef; - this.isVerticalScrolling = scrollTop > 0; + const { scrollTop } = tableContainerRef; + this.isVerticalScrolling = scrollTop > 0; } },