Browse Source

fix: fix tabs when vertical scroll and collapse shows extra arrow (#927)

fix: fix tabs when vertical scroll and collapse shows extra arrow
YannLynn 3 years ago
parent
commit
5509240454
1 changed files with 20 additions and 0 deletions
  1. 20 0
      packages/semi-foundation/overflowList/foundation.ts

+ 20 - 0
packages/semi-foundation/overflowList/foundation.ts

@@ -16,6 +16,8 @@ class OverflowListFoundation extends BaseFoundation<OverflowListAdapter> {
         super({ ...adapter });
     }
 
+    previousY = undefined;
+
     isScrollMode = (): boolean => {
         const { renderMode } = this.getProps();
         return renderMode === 'scroll';
@@ -47,6 +49,24 @@ class OverflowListFoundation extends BaseFoundation<OverflowListAdapter> {
             res[itemKey] = entry;
             visibleState.set(itemKey, visible);
         });
+        let someItemVisible = false;
+        for (const value of visibleState.values()) {
+            if (value) {
+                someItemVisible = true;
+                break;
+            }
+        }
+        // Any item is visible, indicating that the List is visible
+        const wholeListVisible = someItemVisible;
+        // If scrolling in the vertical direction makes the List invisible, no processing is required. 
+        // If this.previousY is undefined, it means that the List is mounted for the first time and will not be processed.
+        const [entry1] = entries;
+        const currentY = entry1.boundingClientRect.y;
+        if (!wholeListVisible && this.previousY !== undefined && currentY !== this.previousY) {
+            this.previousY = currentY;
+            return;
+        }
+        this.previousY = currentY;
         this._adapter.updateVisibleState(visibleState);
         this._adapter.notifyIntersect(res);
     }