Skip to content

Commit

Permalink
Merge pull request #35 from luosheng/fix-extra-padding
Browse files Browse the repository at this point in the history
Wait for other UI actions to be done on main thread.
  • Loading branch information
m1entus committed Mar 13, 2015
2 parents b8490c9 + aba1174 commit 4aaf39a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions INSPullToRefresh/INSPullToRefreshBackgroundView.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ - (void)beginRefreshing {
if (self.state == INSPullToRefreshBackgroundViewStateNone) {
[self changeState:INSPullToRefreshBackgroundViewStateTriggered];

[self.scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x, -CGRectGetHeight(self.frame) -_externalContentInset.top ) animated:YES];
dispatch_async(dispatch_get_main_queue(), ^{
[self.scrollView setContentOffset:CGPointMake(_scrollView.contentOffset.x, -CGRectGetHeight(self.frame) -_externalContentInset.top ) animated:YES];
});

[self changeState:INSPullToRefreshBackgroundViewStateLoading];
}
Expand All @@ -151,7 +153,9 @@ - (void)endRefreshing {
[self changeState:INSPullToRefreshBackgroundViewStateNone];
if (self.scrollToTopAfterEndRefreshing) {
CGPoint originalContentOffset = CGPointMake(-_externalContentInset.left, -_externalContentInset.top);
[self.scrollView setContentOffset:originalContentOffset animated:NO];
dispatch_async(dispatch_get_main_queue(), ^{
[self.scrollView setContentOffset:originalContentOffset animated:NO];
});
}
}
}
Expand Down

0 comments on commit 4aaf39a

Please sign in to comment.