[FIX]: don't handle the scrolling if the content size of the scroll view is insufficiently long. #12

This commit is contained in:
Mazyad Alabduljaleel 2014-07-15 14:18:17 +04:00
parent 45f9297f28
commit d97164f728
3 changed files with 23 additions and 1 deletions

View File

@ -152,9 +152,18 @@ static inline CGFloat AACStatusBarHeight()
#pragma mark - Private methods
- (BOOL)_shouldHandleScrolling
{
CGRect scrollFrame = UIEdgeInsetsInsetRect(self.scrollView.bounds, self.scrollView.contentInset);
CGFloat scrollableAmount = self.scrollView.contentSize.height - CGRectGetHeight(scrollFrame);
BOOL scrollViewIsSuffecientlyLong = (scrollableAmount > self.navBarController.totalHeight);
return (self.isViewControllerVisible && scrollViewIsSuffecientlyLong);
}
- (void)_handleScrolling
{
if (!self.isViewControllerVisible)
if (![self _shouldHandleScrolling])
{
return;
}

View File

@ -35,6 +35,8 @@ typedef CGFloat(^TLYShyViewControllerContractionAmountBlock)(UIView *view);
@property (nonatomic) BOOL hidesSubviews;
@property (nonatomic) BOOL hidesAfterContraction;
@property (nonatomic, readonly) CGFloat totalHeight;
- (CGFloat)updateYOffset:(CGFloat)deltaY;
- (CGFloat)snap:(BOOL)contract;

View File

@ -24,6 +24,8 @@ const CGFloat contractionVelocity = 300.f;
@implementation TLYShyViewController
#pragma mark - Properties
// convenience
- (CGPoint)expandedCenterValue
{
@ -50,6 +52,13 @@ const CGFloat contractionVelocity = 300.f;
return fabs(self.view.center.y - self.expandedCenterValue.y) < FLT_EPSILON;
}
- (CGFloat)totalHeight
{
return self.child.totalHeight + (self.expandedCenterValue.y - self.contractedCenterValue.y);
}
#pragma mark - Private methods
// This method is courtesy of GTScrollNavigationBar
// https://github.com/luugiathuy/GTScrollNavigationBar
- (void)_updateSubviewsToAlpha:(CGFloat)alpha
@ -66,6 +75,8 @@ const CGFloat contractionVelocity = 300.f;
}
}
#pragma mark - Public methods
- (CGFloat)updateYOffset:(CGFloat)deltaY
{
if (self.child && deltaY < 0)