mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix horizontal scrolling in RTL scripts
Summary: Changelog: [internal] Fabric's scrollView now supports horizontal scroll view. Reviewed By: JoshuaGross Differential Revision: D26608231 fbshipit-source-id: 176a7802fa580247d12657e08780805daacd8357
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c060f368b9
commit
e5921f7f38
@@ -37,6 +37,11 @@
|
||||
self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
}
|
||||
|
||||
// We intentionally force `UIScrollView`s `semanticContentAttribute` to `LTR` here
|
||||
// because this attribute affects a position of vertical scrollbar; we don't want this
|
||||
// scrollbar flip because we also flip it with whole `UIScrollView` flip.
|
||||
self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
|
||||
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
_delegateSplitter = [[RCTGenericDelegateSplitter alloc] initWithDelegateUpdateBlock:^(id delegate) {
|
||||
[weakSelf setPrivateDelegate:delegate];
|
||||
|
||||
@@ -152,6 +152,20 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
|
||||
return concreteComponentDescriptorProvider<ScrollViewComponentDescriptor>();
|
||||
}
|
||||
|
||||
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
||||
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
||||
{
|
||||
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
||||
if (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection) {
|
||||
CGAffineTransform transform = (layoutMetrics.layoutDirection == LayoutDirection::LeftToRight)
|
||||
? CGAffineTransformIdentity
|
||||
: CGAffineTransformMakeScale(-1, 1);
|
||||
|
||||
_containerView.transform = transform;
|
||||
_scrollView.transform = transform;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &)oldProps
|
||||
{
|
||||
const auto &oldScrollViewProps = *std::static_pointer_cast<const ScrollViewProps>(_props);
|
||||
@@ -279,7 +293,7 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg
|
||||
}
|
||||
|
||||
_contentSize = contentSize;
|
||||
_containerView.frame = CGRect{CGPointZero, contentSize};
|
||||
_containerView.frame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};
|
||||
|
||||
[self _preserveContentOffsetIfNeededWithBlock:^{
|
||||
self->_scrollView.contentSize = contentSize;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace facebook {
|
||||
namespace react {
|
||||
|
||||
Size ScrollViewState::getContentSize() const {
|
||||
return Size{contentBoundingRect.getMaxX(), contentBoundingRect.getMaxY()};
|
||||
return contentBoundingRect.size;
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user