Skip to content

Commit

Permalink
fix flatlist - more robust solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmydel committed Apr 19, 2024
1 parent 172a326 commit 294dd19
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
diff --git a/node_modules/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp b/node_modules/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp
index a8ecce5..d42a518 100644
index a8ecce5..6ad790e 100644
--- a/node_modules/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp
+++ b/node_modules/react-native/ReactCommon/react/renderer/components/scrollview/ScrollViewShadowNode.cpp
@@ -66,6 +66,16 @@ void ScrollViewShadowNode::layout(LayoutContext layoutContext) {
@@ -66,7 +66,17 @@ void ScrollViewShadowNode::layout(LayoutContext layoutContext) {
Point ScrollViewShadowNode::getContentOriginOffset() const {
auto stateData = getStateData();
auto contentOffset = stateData.contentOffset;
- return {-contentOffset.x, -contentOffset.y + stateData.scrollAwayPaddingTop};
+ auto props = getConcreteProps();
+
+ if (props.transform.operations.size() > 0) {
+ if (props.transform.operations[0].y == -1) {
+ return {-contentOffset.x, contentOffset.y - stateData.scrollAwayPaddingTop};
+ } else if (props.transform.operations[0].x == -1) {
+ return {contentOffset.x, -contentOffset.y + stateData.scrollAwayPaddingTop};
+ }
+ float productX = 1.0f;
+ float productY = 1.0f;
+
+ for (const auto& operation : props.transform.operations) {
+ productX *= operation.x;
+ productY *= operation.y;
+ }
+
return {-contentOffset.x, -contentOffset.y + stateData.scrollAwayPaddingTop};
+ return {-contentOffset.x * productX, (-contentOffset.y + stateData.scrollAwayPaddingTop) * productY};
}

} // namespace facebook::react

0 comments on commit 294dd19

Please sign in to comment.