Skip to content

Commit eb8cf5b

Browse files
committed
Cherrypicked status bar animation changes from unmerged pull request. gotosleep#173
1 parent 5913385 commit eb8cf5b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

JASidePanels/Source/JASidePanelController.h

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ typedef enum _JASidePanelState {
9494
// by default applies rounded corners to the panel. override in sublcass to change
9595
- (void)stylePanel:(UIView *)panel;
9696

97+
// This method will be called whenever the sidepanel visible amount change. Subclass this method to react to changes of how much of the center panel / side panels are visible
98+
- (void)willPanToSidePanelVisiblePercent:(CGFloat)percent duration:(CGFloat)duration;
99+
97100
#pragma mark - Animation
98101

99102
// the minimum % of total screen width the centerPanel.view must move for panGesture to succeed

JASidePanels/Source/JASidePanelController.m

+11-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ - (void)_handlePan:(UIGestureRecognizer *)sender {
517517
[self _layoutSideContainers:NO duration:0];
518518
}
519519

520-
if (sender.state == UIGestureRecognizerStateEnded) {
520+
if(sender.state == UIGestureRecognizerStateChanged) {
521+
CGFloat fullyVisibleWidth = frame.origin.x > 0.0f ? self.leftVisibleWidth : -self.rightVisibleWidth;
522+
[self willPanToSidePanelVisiblePercent:(frame.origin.x / fullyVisibleWidth) duration:0.0f];
523+
} else if (sender.state == UIGestureRecognizerStateEnded) {
521524
CGFloat deltaX = frame.origin.x - _locationBeforePan.x;
522525
if ([self _validateThreshold:deltaX]) {
523526
[self _completePan:deltaX];
@@ -567,6 +570,8 @@ - (void)_undoPan {
567570
}
568571
}
569572

573+
- (void)willPanToSidePanelVisiblePercent:(CGFloat)percent duration:(CGFloat)duration {}
574+
570575
#pragma mark - Tap Gesture
571576

572577
- (void)setTapView:(UIView *)tapView {
@@ -740,6 +745,8 @@ - (void)_animateCenterPanel:(BOOL)shouldBounce completion:(void (^)(BOOL finishe
740745
}
741746

742747
CGFloat duration = [self _calculatedDuration];
748+
CGFloat sidePanelVisiblePercent = _centerPanelRestingFrame.origin.x == 0.0f ? 0.0f : 1.0f;
749+
[self willPanToSidePanelVisiblePercent:sidePanelVisiblePercent duration:duration];
743750
[UIView animateWithDuration:duration delay:0.0f options:UIViewAnimationOptionCurveLinear|UIViewAnimationOptionLayoutSubviews animations:^{
744751
self.centerPanelContainer.frame = _centerPanelRestingFrame;
745752
[self styleContainer:self.centerPanelContainer animate:YES duration:duration];
@@ -831,6 +838,7 @@ - (void)_showLeftPanel:(BOOL)animated bounce:(BOOL)shouldBounce {
831838
if (animated) {
832839
[self _animateCenterPanel:shouldBounce completion:nil];
833840
} else {
841+
[self willPanToSidePanelVisiblePercent:1.0f duration:0.0f];
834842
self.centerPanelContainer.frame = _centerPanelRestingFrame;
835843
[self styleContainer:self.centerPanelContainer animate:NO duration:0.0f];
836844
if (self.style == JASidePanelMultipleActive || self.pushesSidePanels) {
@@ -853,6 +861,7 @@ - (void)_showRightPanel:(BOOL)animated bounce:(BOOL)shouldBounce {
853861
if (animated) {
854862
[self _animateCenterPanel:shouldBounce completion:nil];
855863
} else {
864+
[self willPanToSidePanelVisiblePercent:1.0f duration:0.0f];
856865
self.centerPanelContainer.frame = _centerPanelRestingFrame;
857866
[self styleContainer:self.centerPanelContainer animate:NO duration:0.0f];
858867
if (self.style == JASidePanelMultipleActive || self.pushesSidePanels) {
@@ -878,6 +887,7 @@ - (void)_showCenterPanel:(BOOL)animated bounce:(BOOL)shouldBounce {
878887
[self _unloadPanels];
879888
}];
880889
} else {
890+
[self willPanToSidePanelVisiblePercent:0.0f duration:0.0f];
881891
self.centerPanelContainer.frame = _centerPanelRestingFrame;
882892
[self styleContainer:self.centerPanelContainer animate:NO duration:0.0f];
883893
if (self.style == JASidePanelMultipleActive || self.pushesSidePanels) {

0 commit comments

Comments
 (0)