mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Support ScrollAway in ReactScrollView
Summary: Support ScrollAway in ReactScrollView for Fabric/non-Fabric. Changelog: [Android][Added] Support for ScrollAway native nav bars added to ReactScrollView Reviewed By: mdvacca Differential Revision: D28308855 fbshipit-source-id: 9a922159ef50fb7c8e9c484a4b97ca57ab248496
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d87542ee4c
commit
0ef5beee85
@@ -34,7 +34,7 @@ void ScrollViewShadowNode::updateStateIfNeeded() {
|
||||
void ScrollViewShadowNode::updateScrollContentOffsetIfNeeded() {
|
||||
#ifndef ANDROID
|
||||
if (getLayoutMetrics().layoutDirection == LayoutDirection::RightToLeft) {
|
||||
// Yoga place `contentView` on the right side of `scrollView` when RTL
|
||||
// Yoga places `contentView` on the right side of `scrollView` when RTL
|
||||
// layout is enforced. To correct for this, in RTL setting, correct the
|
||||
// frame's origin. React Native Classic does this as well in
|
||||
// `RCTScrollContentShadowView.m`.
|
||||
@@ -58,8 +58,9 @@ void ScrollViewShadowNode::layout(LayoutContext layoutContext) {
|
||||
}
|
||||
|
||||
Point ScrollViewShadowNode::getContentOriginOffset() const {
|
||||
auto contentOffset = getStateData().contentOffset;
|
||||
return {-contentOffset.x, -contentOffset.y};
|
||||
auto stateData = getStateData();
|
||||
auto contentOffset = stateData.contentOffset;
|
||||
return {-contentOffset.x, -contentOffset.y + stateData.scrollAwayPaddingTop};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
@@ -25,6 +25,7 @@ class ScrollViewState final {
|
||||
public:
|
||||
Point contentOffset;
|
||||
Rect contentBoundingRect;
|
||||
int scrollAwayPaddingTop;
|
||||
|
||||
/*
|
||||
* Returns size of scrollable area.
|
||||
@@ -37,11 +38,13 @@ class ScrollViewState final {
|
||||
: contentOffset(
|
||||
{(Float)data["contentOffsetLeft"].getDouble(),
|
||||
(Float)data["contentOffsetTop"].getDouble()}),
|
||||
contentBoundingRect({}){};
|
||||
contentBoundingRect({}),
|
||||
scrollAwayPaddingTop((Float)data["scrollAwayPaddingTop"].getDouble()){};
|
||||
|
||||
folly::dynamic getDynamic() const {
|
||||
return folly::dynamic::object("contentOffsetLeft", contentOffset.x)(
|
||||
"contentOffsetTop", contentOffset.y);
|
||||
"contentOffsetTop", contentOffset.y)(
|
||||
"scrollAwayPaddingTop", scrollAwayPaddingTop);
|
||||
};
|
||||
MapBuffer getMapBuffer() const {
|
||||
return MapBufferBuilder::EMPTY();
|
||||
|
||||
@@ -26,7 +26,7 @@ TEST(ConcreteShadowNodeTest, testSetStateData) {
|
||||
|
||||
auto shadowNode = builder.build(element);
|
||||
|
||||
shadowNode->setStateData({{10, 11}, {{21, 22}, {301, 302}}});
|
||||
shadowNode->setStateData({{10, 11}, {{21, 22}, {301, 302}}, 0});
|
||||
|
||||
EXPECT_NE(
|
||||
shadowNode->getState(), shadowNode->getFamily().getMostRecentState());
|
||||
|
||||
Reference in New Issue
Block a user