Skip to content

Commit 13b7a59

Browse files
authored
Merge pull request #60340 from software-mansion-labs/Guccio163/horizontalFlatList
fix simultaneous scrolling in two directions
2 parents 018589c + d389574 commit 13b7a59

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
diff --git a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js
2+
index 1b8a228..1efeb14 100644
3+
--- a/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js
4+
+++ b/node_modules/react-native-web/dist/vendor/react-native/VirtualizedList/index.js
5+
@@ -719,21 +719,22 @@ class VirtualizedList extends StateSafePureComponent {
6+
const targetDelta = delta - leftoverDelta;
7+
if (this.props.inverted && this._scrollRef && this._scrollRef.getScrollableNode) {
8+
const node = this._scrollRef.getScrollableNode();
9+
- if (isHorizontal) {
10+
- ev.target.scrollLeft += targetDelta;
11+
- const nextScrollLeft = node.scrollLeft - leftoverDelta;
12+
- node.scrollLeft = !this.props.getItemLayout ? Math.min(nextScrollLeft, this._totalCellLength) : nextScrollLeft;
13+
14+
+ if (isHorizontal) {
15+
if (Math.abs(deltaX) > Math.abs(deltaY)) {
16+
- ev.preventDefault();
17+
+ ev.target.scrollLeft += targetDelta;
18+
+ const nextScrollLeft = node.scrollLeft - leftoverDelta;
19+
+ node.scrollLeft = !this.props.getItemLayout ? Math.min(nextScrollLeft, this._totalCellLength) : nextScrollLeft;
20+
+ ev.preventDefault();
21+
+ ev.stopPropagation();
22+
}
23+
} else {
24+
- ev.target.scrollTop += targetDelta;
25+
- const nextScrollTop = node.scrollTop - leftoverDelta;
26+
- node.scrollTop = !this.props.getItemLayout ? Math.min(nextScrollTop, this._totalCellLength) : nextScrollTop;
27+
-
28+
if (Math.abs(deltaY) > Math.abs(deltaX)) {
29+
- ev.preventDefault();
30+
+ ev.target.scrollTop += targetDelta;
31+
+ const nextScrollTop = node.scrollTop - leftoverDelta;
32+
+ node.scrollTop = !this.props.getItemLayout ? Math.min(nextScrollTop, this._totalCellLength) : nextScrollTop;
33+
+ ev.preventDefault();
34+
+ ev.stopPropagation();
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)