From 34389c529dc5a1dff86164b6087228ca021fdde7 Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Wed, 3 Feb 2016 07:59:28 -0800 Subject: [PATCH] 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 --- React/Views/RCTScrollView.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/React/Views/RCTScrollView.m b/React/Views/RCTScrollView.m index 09c606176231d6..10f2e5ec9c5336 100644 --- a/React/Views/RCTScrollView.m +++ b/React/Views/RCTScrollView.m @@ -275,6 +275,11 @@ - (void)dockClosestSectionHeader { 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;