This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from telly/develop
v1.0
- Loading branch information
Showing
48 changed files
with
508 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// TLYShyChild.h | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#ifndef TLYShyChild_h | ||
#define TLYShyChild_h | ||
|
||
|
||
@protocol TLYShyChild <NSObject> | ||
|
||
- (void)offsetCenterBy:(CGPoint)deltaPoint; | ||
|
||
@end | ||
|
||
#endif /* TLYShyChild_h */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// TLYShyScrollViewController.h | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "TLYShyViewController.h" | ||
#import "TLYShyParent.h" | ||
#import "TLYShyChild.h" | ||
|
||
|
||
@interface TLYShyScrollViewController : NSObject <TLYShyChild> | ||
|
||
@property (nonatomic, weak) UIScrollView *scrollView; | ||
@property (nonatomic, weak) TLYShyViewController *parent; | ||
|
||
- (CGFloat)updateLayoutIfNeeded:(BOOL)intelligently; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// TLYShyScrollViewController.m | ||
// TLYShyNavBarDemo | ||
// | ||
// Created by Mazyad Alabduljaleel on 11/13/15. | ||
// Copyright © 2015 Telly, Inc. All rights reserved. | ||
// | ||
|
||
#import "TLYShyScrollViewController.h" | ||
#import "../Categories/UIScrollView+Helpers.h" | ||
|
||
|
||
@implementation TLYShyScrollViewController | ||
|
||
- (void)offsetCenterBy:(CGPoint)deltaPoint | ||
{ | ||
[self updateLayoutIfNeeded:NO]; | ||
} | ||
|
||
- (CGFloat)updateLayoutIfNeeded:(BOOL)intelligently | ||
{ | ||
if (self.scrollView.contentSize.height < FLT_EPSILON | ||
&& ([self.scrollView isKindOfClass:[UITableView class]] | ||
|| [self.scrollView isKindOfClass:[UICollectionView class]]) | ||
) | ||
{ | ||
return 0.f; | ||
} | ||
|
||
CGFloat parentMaxY = [self.parent maxYRelativeToView:self.scrollView.superview]; | ||
CGFloat normalizedY = parentMaxY - self.scrollView.frame.origin.y; | ||
UIEdgeInsets insets = self.scrollView.contentInset; | ||
insets.top = normalizedY; | ||
|
||
if (normalizedY > -FLT_EPSILON && !UIEdgeInsetsEqualToEdgeInsets(insets, self.scrollView.contentInset)) | ||
{ | ||
CGFloat delta = insets.top - self.scrollView.contentInset.top; | ||
[self.scrollView tly_setInsets:insets preserveOffset:intelligently]; | ||
|
||
return delta; | ||
} | ||
|
||
if (normalizedY < -FLT_EPSILON) | ||
{ | ||
CGRect frame = self.scrollView.frame; | ||
frame = UIEdgeInsetsInsetRect(frame, insets); | ||
|
||
self.scrollView.frame = frame; | ||
return [self updateLayoutIfNeeded:YES]; | ||
} | ||
|
||
return 0.f; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.