mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
In onLayoutChange, only scroll if the view is shown and the content view is ready
Summary: ScrollViews don't properly maintain position where they are hidden and shown. When a ScrollView's content is laid out, onLayoutChange is triggered. This is also fired when the views are hidden, which is not desirable as the layout may not be accurate when the view is hidden. Check that the scroll view is showing before attempting a scroll. Changelog: [Internal][Fixed] - In onLayoutChange, only scroll if the view is shown and the content view is ready Reviewed By: sshic Differential Revision: D42808119 fbshipit-source-id: 0197ae55fa7d80e52c2ea483609e62d512a117f3
This commit is contained in:
committed by
Facebook GitHub Bot
parent
9e65ba2b7b
commit
115dbe9433
@@ -1127,10 +1127,12 @@ public class ReactScrollView extends ScrollView
|
||||
mMaintainVisibleContentPositionHelper.updateScrollPosition();
|
||||
}
|
||||
|
||||
int currentScrollY = getScrollY();
|
||||
int maxScrollY = getMaxScrollY();
|
||||
if (currentScrollY > maxScrollY) {
|
||||
scrollTo(getScrollX(), maxScrollY);
|
||||
if (isShown() && isContentReady()) {
|
||||
int currentScrollY = getScrollY();
|
||||
int maxScrollY = getMaxScrollY();
|
||||
if (currentScrollY > maxScrollY) {
|
||||
scrollTo(getScrollX(), maxScrollY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user