Fix sticky headers position when scrolling while RefreshControl is refreshing

Summary:
When scrolling while RefreshControl is refreshing the sticky headers are offset by the height of the UIRefreshControl. This simply removes the height of the UIRefreshControl while it is refreshing and fixes the problem.

You can repro the bug using this example in UIExplorer by doing a pull to refresh and scrolling the ListView immediately after.
https://gist.github.com/janicduplessis/26b4f2758e90b2aa1620

Fixes #5405
Closes https://github.com/facebook/react-native/pull/5517

Reviewed By: svcscm

Differential Revision: D2895623

Pulled By: nicklockwood

fb-gh-sync-id: 81df36cccfc3e7b973c2be78565f8b8408c9fc12
This commit is contained in:
Janic Duplessis 2016-02-03 07:59:28 -08:00 committed by facebook-github-bot-6
parent 4a3900bf5d
commit 34389c529d

View File

@ -275,6 +275,11 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
{
UIView *contentView = [self contentView];
CGFloat scrollTop = self.bounds.origin.y + self.contentInset.top;
// If the RefreshControl is refreshing, remove it's height so sticky headers are
// positioned properly when scrolling down while refreshing.
if (self.refreshControl != nil && self.refreshControl.refreshing) {
scrollTop -= self.refreshControl.frame.size.height;
}
// Find the section headers that need to be docked
__block UIView *previousHeader = nil;