Skip to content

Commit 398eaf8

Browse files
authored
fix: overscanning for bidirectional layouts
1 parent 2d97559 commit 398eaf8

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

packages/@react-stately/virtualizer/src/OverscanManager.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,19 @@ export class OverscanManager {
3535
this.visibleRect = rect;
3636
}
3737

38-
getOverscannedRect(orientation: Orientation): Rect {
38+
getOverscannedRect(): Rect {
3939
let overscanned = this.visibleRect.copy();
4040

41-
if (orientation === 'vertical' || this.velocity.y !== 0) {
42-
let overscanY = this.visibleRect.height / 3;
43-
overscanned.height += overscanY;
44-
if (this.velocity.y < 0) {
45-
overscanned.y -= overscanY;
46-
}
41+
let overscanY = this.visibleRect.height / 3;
42+
overscanned.height += overscanY;
43+
if (this.velocity.y < 0) {
44+
overscanned.y -= overscanY;
4745
}
4846

49-
if (orientation === 'horizontal' || this.velocity.x !== 0) {
50-
let overscanX = this.visibleRect.width / 3;
51-
overscanned.width += overscanX;
52-
if (this.velocity.x < 0) {
53-
overscanned.x -= overscanX;
54-
}
47+
let overscanX = this.visibleRect.width / 3;
48+
overscanned.width += overscanX;
49+
if (this.velocity.x < 0) {
50+
overscanned.x -= overscanX;
5551
}
5652

5753
return overscanned;

packages/@react-stately/virtualizer/src/Virtualizer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ export class Virtualizer<T extends object, V> {
191191
if (isTestEnv && !(isClientWidthMocked && isClientHeightMocked)) {
192192
rect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);
193193
} else {
194-
rect = this._overscanManager.getOverscannedRect(this.layout.getOrientation!()!);
194+
rect = this._overscanManager.getOverscannedRect();
195195
}
196196
let layoutInfos = this.layout.getVisibleLayoutInfos(rect);
197197
let map = new Map;

0 commit comments

Comments
 (0)