[FIX]: don't handle the scrolling if the content size of the scroll view is insufficiently long. #12
This commit is contained in:
parent
45f9297f28
commit
d97164f728
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue