From 86a7cbc2de916778ec4b2bc74755b7b2145a151b Mon Sep 17 00:00:00 2001 From: Yosuke Ishikawa Date: Sat, 8 Jun 2013 23:45:22 +0900 Subject: [PATCH] will not call setNeedsLayout if visible contents is far away from refresh control #13 --- ISRefreshControl/ISRefreshControl.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ISRefreshControl/ISRefreshControl.m b/ISRefreshControl/ISRefreshControl.m index 6160868..c54f486 100644 --- a/ISRefreshControl/ISRefreshControl.m +++ b/ISRefreshControl/ISRefreshControl.m @@ -175,7 +175,9 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView CGFloat y = offset < -self.frame.size.height ? offset - topInset : -self.frame.size.height - topInset; self.frame = CGRectOffset(self.frame, 0.f, y - self.frame.origin.y); - self.gumView.distance = offset < -self.frame.size.height ? -offset-self.frame.size.height : 0.f; + if (offset < 0.f) { + self.gumView.distance = offset < -self.frame.size.height ? -offset-self.frame.size.height : 0.f; + } // hides gumView when it is about to appear by inertial scrolling. if (scrollView.isTracking && !self.isRefreshing) { @@ -268,6 +270,7 @@ - (void)subtractTopInsets completion:^(BOOL finished) { self.subtractingTopInset = NO; self.addedTopInset = NO; + self.gumView.distance = 0.f; if (scrollView.contentOffset.y <= scrollView.contentInset.top && !scrollView.isDragging) { [self reset];