Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Pod/Classes/JDFPeekabooCoordinator.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,21 @@
*/
- (void)fullyExpandViews;

/**
* Returns all of the views to their default position.
*/
- (void)fullyExpandViewsAnimated:(BOOL)animated;

/**
* Moves all of the views to their minimised position;
*/
- (void)fullyHideViews;

/**
* Moves all of the views to their minimised position;
*/
- (void)fullyHideViewsAnimated:(BOOL)animated;


#pragma mark - Enabling/Disabling

Expand Down
47 changes: 37 additions & 10 deletions Pod/Classes/JDFPeekabooCoordinator.m
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,40 @@ - (void)setBarsNeedDisplay

- (void)fullyExpandViews
{
[self animateTopViewToYPosition:self.topViewDefaultY];
[self animateBottomViewToYPosition:(self.containingView.frame.size.height - self.bottomBarDefaultHeight)];
[self fullyExpandViewsAnimated:NO];
}

- (void)fullyExpandViewsAnimated:(BOOL)animated
{
void (^block)() = ^() {
[self animateTopViewToYPosition:self.topViewDefaultY];
[self animateBottomViewToYPosition:(self.containingView.frame.size.height - self.bottomBarDefaultHeight)];
};

if (!animated) {
[UIView performWithoutAnimation:block];
} else {
block();
}
[self setBarsNeedDisplay];
}

- (void)fullyHideViews
{
[self animateTopViewToYPosition:[self topViewMinimisedY]];
[self animateBottomViewToYPosition:[self bottomViewMinimisedY]];
[self fullyHideViewsAnimated:NO];
}

- (void)fullyHideViewsAnimated:(BOOL)animated
{
void (^block)() = ^() {
[self animateTopViewToYPosition:[self topViewMinimisedY]];
[self animateBottomViewToYPosition:[self bottomViewMinimisedY]];
};
if (!animated) {
[UIView performWithoutAnimation:block];
} else {
block();
}
[self setBarsNeedDisplay];
}

Expand Down Expand Up @@ -240,7 +265,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView

CGFloat topViewPercentageHidden = [self topViewPercentageHidden];
[self updateTopViewSubviews:(1 - topViewPercentageHidden)];

self.previousScrollViewYOffset = scrollOffset;
}

Expand Down Expand Up @@ -296,7 +321,7 @@ - (void)updateTopViewSubviews:(CGFloat)alpha
} else if (alpha < 0.0f) {
alpha = 0.0f;
}

for (UIView *view in self.topViewItems) {
view.alpha = alpha;
}
Expand All @@ -320,8 +345,10 @@ - (void)animateTopViewToYPosition:(CGFloat)y
frame.origin.y = y;
[self.topView setFrame:frame];
[self updateTopViewSubviews:alpha];
} completion:^(BOOL finished) {
[self setBarsNeedDisplay];
} completion:^(BOOL finished) {
//[self setBarsNeedDisplay];
}];
}

Expand All @@ -331,16 +358,16 @@ - (void)animateBottomViewToYPosition:(CGFloat)y
CGRect frame = self.bottomView.frame;
frame.origin.y = y;
[self.bottomView setFrame:frame];
} completion:^(BOOL finished) {
[self setBarsNeedDisplay];
} completion:^(BOOL finished) {
//[self setBarsNeedDisplay];
}];
}

- (CGFloat)topViewPercentageHidden
{
CGFloat statusBarHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
CGRect frame = self.topView.frame;
CGFloat percentage = (self.topViewDefaultY - frame.origin.y - (self.topViewDefaultY - statusBarHeight)) / (frame.size.height - 1 - self.topViewMinimisedHeight);
CGFloat percentage = 1 - (frame.size.height + frame.origin.y - self.topViewMinimisedHeight) / (frame.size.height - self.topViewMinimisedHeight);
return percentage;
}

Expand Down