File tree Expand file tree Collapse file tree
packages/react-native/ReactCommon/react/renderer Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,9 +63,12 @@ void ScrollViewShadowNode::layout(LayoutContext layoutContext) {
6363 updateStateIfNeeded ();
6464}
6565
66- Point ScrollViewShadowNode::getContentOriginOffset () const {
66+ Point ScrollViewShadowNode::getContentOriginOffset (
67+ bool /* includeTransform */ ) const {
68+
6769 auto stateData = getStateData ();
6870 auto contentOffset = stateData.contentOffset ;
71+
6972 return {-contentOffset.x , -contentOffset.y + stateData.scrollAwayPaddingTop };
7073}
7174
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class ScrollViewShadowNode final : public ConcreteViewShadowNode<
3737#pragma mark - LayoutableShadowNode
3838
3939 void layout (LayoutContext layoutContext) override ;
40- Point getContentOriginOffset () const override ;
40+ Point getContentOriginOffset (bool includeTransform ) const override ;
4141
4242 private:
4343 void updateStateIfNeeded ();
Original file line number Diff line number Diff line change @@ -151,7 +151,11 @@ LayoutMetrics LayoutableShadowNode::computeRelativeLayoutMetrics(
151151 }
152152
153153 if (i != 0 && policy.includeTransform ) {
154- resultFrame.origin += currentShadowNode->getContentOriginOffset ();
154+ // Transformation is not applied here and instead we delegated out in
155+ // getContentOriginOffset. The reason is that for `ScrollViewShadowNode`,
156+ // we need to consider `scrollAwayPaddingTop` which should NOT be included
157+ // in the transform.
158+ resultFrame.origin += currentShadowNode->getContentOriginOffset (true );
155159 }
156160
157161 if (policy.enableOverflowClipping ) {
@@ -188,7 +192,9 @@ Transform LayoutableShadowNode::getTransform() const {
188192 return Transform::Identity ();
189193}
190194
191- Point LayoutableShadowNode::getContentOriginOffset () const {
195+ Point LayoutableShadowNode::getContentOriginOffset (
196+ bool /* includeTransform*/ ) const {
197+
192198 return {0 , 0 };
193199}
194200
@@ -269,7 +275,7 @@ ShadowNode::Shared LayoutableShadowNode::findNodeAtPoint(
269275 }
270276
271277 auto newPoint = point - transformedFrame.origin -
272- layoutableShadowNode->getContentOriginOffset ();
278+ layoutableShadowNode->getContentOriginOffset (false );
273279
274280 auto sortedChildren = node->getChildren ();
275281 std::stable_sort (
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ class LayoutableShadowNode : public ShadowNode {
123123 * `LayoutableShadowNode::getRelativeLayoutMetrics` and
124124 * `LayoutableShadowNode::findNodeAtPoint`.
125125 */
126- virtual Point getContentOriginOffset () const ;
126+ virtual Point getContentOriginOffset (bool includeTransform ) const ;
127127
128128 /*
129129 * Sets layout metrics for the shadow node.
Original file line number Diff line number Diff line change @@ -76,7 +76,9 @@ class TestShadowNode final : public ConcreteViewShadowNode<
7676
7777 facebook::react::Point _contentOriginOffset{};
7878
79- facebook::react::Point getContentOriginOffset () const override {
79+ facebook::react::Point getContentOriginOffset (
80+ bool /* includeTransform */ ) const override {
81+
8082 return _contentOriginOffset;
8183 }
8284};
Original file line number Diff line number Diff line change @@ -357,7 +357,7 @@ DOMPoint getScrollPosition(
357357 return DOMPoint{};
358358 }
359359
360- auto scrollPosition = layoutableShadowNode->getContentOriginOffset ();
360+ auto scrollPosition = layoutableShadowNode->getContentOriginOffset (false );
361361
362362 return DOMPoint{
363363 .x = scrollPosition.x == 0 ? 0 : -scrollPosition.x ,
You can’t perform that action at this time.
0 commit comments