Skip to content

Commit 69d2842

Browse files
Billy OhgrenBilly Ohgren
Billy Ohgren
authored and
Billy Ohgren
committed
back to 1.3.3 again
1 parent 65a2ca2 commit 69d2842

20 files changed

+550
-169
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ language: objective-c
22
before_install: rake travis:before_install
33
install: rake travis:install
44
script: rake travis:script
5+
branches:
6+
only: master

ECSlidingViewController.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22
s.name = "ECSlidingViewController"
3-
s.version = "2.0.0-beta1"
3+
s.version = "2.0.0-beta2"
44
s.summary = "View controller container that presents its child view controllers in two sliding layers. Inspired by the Path 2.0 and Facebook iPhone apps."
55
s.description = "ECSlidingViewController is a view controller container that presents its child view controllers in two layers. It provides functionality for sliding the top view to reveal the views underneath it. This functionality is inspired by the Path 2.0 and Facebook iPhone apps."
66
s.homepage = "https://github.com/ECSlidingViewController/ECSlidingViewController"
77
s.license = 'MIT'
88
s.author = { "Mike Enriquez" => "[email protected]" }
9-
s.source = { :git => "https://github.com/ECSlidingViewController/ECSlidingViewController.git", :tag => "2.0.0-beta1" }
9+
s.source = { :git => "https://github.com/ECSlidingViewController/ECSlidingViewController.git", :tag => "2.0.0-beta2" }
1010

1111
s.platform = :ios, '7.0'
1212
s.requires_arc = true

ECSlidingViewController/ECPercentDrivenInteractiveTransition.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,25 @@
2525

2626
@interface ECPercentDrivenInteractiveTransition ()
2727
@property (nonatomic, assign) id<UIViewControllerContextTransitioning> transitionContext;
28+
@property (nonatomic, assign) BOOL isActive;
29+
- (void)removeAnimationsRecursively:(CALayer *)layer;
2830
@end
2931

3032
@implementation ECPercentDrivenInteractiveTransition
3133

3234
- (void)startInteractiveTransition:(id<UIViewControllerContextTransitioning>)transitionContext {
35+
self.isActive = YES;
3336
self.transitionContext = transitionContext;
3437

38+
CALayer *containerLayer = [self.transitionContext containerView].layer;
39+
[self removeAnimationsRecursively:containerLayer];
3540
[self.animationController animateTransition:transitionContext];
3641
[self updateInteractiveTransition:0];
3742
}
3843

3944
- (void)updateInteractiveTransition:(CGFloat)percentComplete {
45+
if (!self.isActive) return;
46+
4047
[self.transitionContext updateInteractiveTransition:_percentComplete];
4148

4249
CGFloat boundedPercentage;
@@ -56,13 +63,18 @@ - (void)updateInteractiveTransition:(CGFloat)percentComplete {
5663
}
5764

5865
- (void)cancelInteractiveTransition {
66+
if (!self.isActive) return;
67+
5968
[self.transitionContext cancelInteractiveTransition];
6069

6170
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(reversePausedAnimation:)];
6271
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
6372
}
6473

6574
- (void)finishInteractiveTransition {
75+
if (!self.isActive) return;
76+
self.isActive = NO;
77+
6678
[self.transitionContext finishInteractiveTransition];
6779

6880
CALayer *layer = [self.transitionContext containerView].layer;
@@ -89,10 +101,22 @@ - (void)reversePausedAnimation:(CADisplayLink *)displayLink {
89101
[self updateInteractiveTransition:self.percentComplete];
90102

91103
if (_percentComplete == 0.0) {
104+
self.isActive = NO;
92105
CALayer *layer = [self.transitionContext containerView].layer;
93106
[layer removeAllAnimations];
94107
layer.speed = 1.0;
95108
}
96109
}
97110

111+
#pragma mark - Private
112+
113+
- (void)removeAnimationsRecursively:(CALayer *)layer {
114+
if (layer.sublayers.count > 0) {
115+
for (CALayer *subLayer in layer.sublayers) {
116+
[subLayer removeAllAnimations];
117+
[self removeAnimationsRecursively:subLayer];
118+
}
119+
}
120+
}
121+
98122
@end

ECSlidingViewController/ECSlidingAnimationController.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
4141
UIViewController *topViewController = [transitionContext viewControllerForKey:ECTransitionContextTopViewControllerKey];
4242
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
4343
UIView *containerView = [transitionContext containerView];
44+
CGRect topViewInitialFrame = [transitionContext initialFrameForViewController:topViewController];
4445
CGRect topViewFinalFrame = [transitionContext finalFrameForViewController:topViewController];
4546

47+
topViewController.view.frame = topViewInitialFrame;
48+
4649
if (topViewController != toViewController) {
47-
CGRect toViewInitialFrame = [transitionContext initialFrameForViewController:toViewController];
48-
toViewController.view.frame = toViewInitialFrame;
50+
CGRect toViewFinalFrame = [transitionContext finalFrameForViewController:toViewController];
51+
toViewController.view.frame = toViewFinalFrame;
4952
[containerView insertSubview:toViewController.view belowSubview:topViewController.view];
5053
}
5154

ECSlidingViewController/ECSlidingViewController.m

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ @interface ECSlidingViewController()
3434
@property (nonatomic, strong) id<UIViewControllerAnimatedTransitioning> currentAnimationController;
3535
@property (nonatomic, strong) id<UIViewControllerInteractiveTransitioning> currentInteractiveTransition;
3636
@property (nonatomic, strong) UIView *gestureView;
37-
@property (nonatomic, strong) UIPanGestureRecognizer *resetPanGesture;
3837
@property (nonatomic, strong) NSMapTable *customAnchoredGesturesViewMap;
3938
@property (nonatomic, assign) CGFloat currentAnimationPercentage;
4039
@property (nonatomic, assign) BOOL preserveLeftPeekAmount;
@@ -175,18 +174,9 @@ - (void)viewDidDisappear:(BOOL)animated {
175174
}
176175
}
177176

178-
- (void)viewWillLayoutSubviews {
179-
if (self.currentOperation == ECSlidingViewControllerOperationNone) {
180-
self.gestureView.frame = [self topViewCalculatedFrameForPosition:self.currentTopViewPosition];
181-
self.topViewController.view.frame = [self topViewCalculatedFrameForPosition:self.currentTopViewPosition];
182-
self.underLeftViewController.view.frame = [self underLeftViewCalculatedFrame];
183-
self.underRightViewController.view.frame = [self underRightViewCalculatedFrame];
184-
}
185-
}
186-
187177
- (void)viewDidLayoutSubviews {
188178
if (self.currentOperation == ECSlidingViewControllerOperationNone) {
189-
[self topViewCalculatedFrameForPosition:self.currentTopViewPosition];
179+
self.gestureView.frame = [self topViewCalculatedFrameForPosition:self.currentTopViewPosition];
190180
self.topViewController.view.frame = [self topViewCalculatedFrameForPosition:self.currentTopViewPosition];
191181
self.underLeftViewController.view.frame = [self underLeftViewCalculatedFrame];
192182
self.underRightViewController.view.frame = [self underRightViewCalculatedFrame];
@@ -258,7 +248,6 @@ - (void)setTopViewController:(UIViewController *)topViewController {
258248

259249
if ([self isViewLoaded]) {
260250
[_topViewController beginAppearanceTransition:YES animated:NO];
261-
_topViewController.view.frame = [self topViewCalculatedFrameForPosition:self.currentTopViewPosition];
262251
[self.view addSubview:_topViewController.view];
263252
[_topViewController endAppearanceTransition];
264253
}
@@ -388,14 +377,6 @@ - (UIView *)gestureView {
388377
return _gestureView;
389378
}
390379

391-
- (UIPanGestureRecognizer *)resetPanGesture {
392-
if (_resetPanGesture) return _resetPanGesture;
393-
394-
_resetPanGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(detectPanGestureRecognizer:)];
395-
396-
return _resetPanGesture;
397-
}
398-
399380
- (NSMapTable *)customAnchoredGesturesViewMap {
400381
if (_customAnchoredGesturesViewMap) return _customAnchoredGesturesViewMap;
401382

@@ -580,6 +561,8 @@ - (ECSlidingViewControllerOperation)operationFromPosition:(ECSlidingViewControll
580561
- (void)animateOperation:(ECSlidingViewControllerOperation)operation {
581562
if (![self operationIsValid:operation]) return;
582563
if (self.transitionInProgress) return;
564+
565+
self.view.userInteractionEnabled = NO;
583566

584567
self.transitionInProgress = YES;
585568

@@ -697,25 +680,28 @@ - (void)updateTopViewGestures {
697680
topView.userInteractionEnabled = NO;
698681
} else {
699682
self.gestureView.frame = topView.frame;
700-
for (UIGestureRecognizer *gesture in self.gestureView.gestureRecognizers) {
701-
[self.gestureView removeGestureRecognizer:gesture];
702-
}
703683

704-
if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGesturePanning && self.panGesture.view && self.panGesture.isEnabled) {
705-
[self.gestureView addGestureRecognizer:self.resetPanGesture];
684+
if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGesturePanning &&
685+
![self.customAnchoredGesturesViewMap objectForKey:self.panGesture]) {
686+
[self.customAnchoredGesturesViewMap setObject:self.panGesture.view forKey:self.panGesture];
687+
[self.panGesture.view removeGestureRecognizer:self.panGesture];
688+
[self.gestureView addGestureRecognizer:self.panGesture];
706689
if (!self.gestureView.superview) [self.view insertSubview:self.gestureView aboveSubview:topView];
707690
}
708691

709-
if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGestureTapping) {
692+
if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGestureTapping &&
693+
![self.customAnchoredGesturesViewMap objectForKey:self.resetTapGesture]) {
710694
[self.gestureView addGestureRecognizer:self.resetTapGesture];
711695
if (!self.gestureView.superview) [self.view insertSubview:self.gestureView aboveSubview:topView];
712696
}
713697

714698
if (self.topViewAnchoredGesture & ECSlidingViewControllerAnchoredGestureCustom) {
715699
for (UIGestureRecognizer *gesture in self.customAnchoredGestures) {
716-
[self.customAnchoredGesturesViewMap setObject:gesture.view forKey:gesture];
717-
[gesture.view removeGestureRecognizer:gesture];
718-
[self.gestureView addGestureRecognizer:gesture];
700+
if (![self.customAnchoredGesturesViewMap objectForKey:gesture]) {
701+
[self.customAnchoredGesturesViewMap setObject:gesture.view forKey:gesture];
702+
[gesture.view removeGestureRecognizer:gesture];
703+
[self.gestureView addGestureRecognizer:gesture];
704+
}
719705
}
720706
if (!self.gestureView.superview) [self.view insertSubview:self.gestureView aboveSubview:topView];
721707
}
@@ -725,7 +711,15 @@ - (void)updateTopViewGestures {
725711
[self.gestureView removeFromSuperview];
726712
for (UIGestureRecognizer *gesture in self.customAnchoredGestures) {
727713
UIView *originalView = [self.customAnchoredGesturesViewMap objectForKey:gesture];
728-
if (![originalView.gestureRecognizers containsObject:gesture]) [originalView addGestureRecognizer:gesture];
714+
if ([originalView isDescendantOfView:self.topViewController.view]) {
715+
[originalView addGestureRecognizer:gesture];
716+
}
717+
}
718+
if ([self.customAnchoredGesturesViewMap objectForKey:self.panGesture]) {
719+
UIView *view = [self.customAnchoredGesturesViewMap objectForKey:self.panGesture];
720+
if ([view isDescendantOfView:self.topViewController.view]) {
721+
[view addGestureRecognizer:self.panGesture];
722+
}
729723
}
730724
[self.customAnchoredGesturesViewMap removeAllObjects];
731725
}
@@ -739,6 +733,7 @@ - (void)detectPanGestureRecognizer:(UIPanGestureRecognizer *)recognizer {
739733
}
740734

741735
[self.defaultInteractiveTransition updateTopViewHorizontalCenterWithRecognizer:recognizer];
736+
_isInteractive = NO;
742737
}
743738

744739
#pragma mark - UIViewControllerTransitionCoordinatorContext
@@ -833,9 +828,9 @@ - (void)completeTransition:(BOOL)didComplete {
833828
if (self.animationComplete) self.animationComplete();
834829
self.animationComplete = nil;
835830

836-
[self endAppearanceTransitionForOperation:self.currentOperation isCancelled:[self transitionWasCancelled]];
837831
[self setNeedsStatusBarAppearanceUpdate];
838832
[self updateTopViewGestures];
833+
[self endAppearanceTransitionForOperation:self.currentOperation isCancelled:[self transitionWasCancelled]];
839834

840835
_transitionWasCancelled = NO;
841836
_isInteractive = NO;
@@ -845,6 +840,7 @@ - (void)completeTransition:(BOOL)didComplete {
845840
self.currentAnimationPercentage = 0;
846841
self.currentOperation = ECSlidingViewControllerOperationNone;
847842
self.transitionInProgress = NO;
843+
self.view.userInteractionEnabled = YES;
848844
[UIViewController attemptRotationToDeviceOrientation];
849845
}
850846

@@ -864,10 +860,10 @@ - (UIViewController *)viewControllerForKey:(NSString *)key {
864860
if (key == UITransitionContextFromViewControllerKey) return self.topViewController;
865861
if (key == UITransitionContextToViewControllerKey) return self.underLeftViewController;
866862
} else if (self.currentOperation == ECSlidingViewControllerOperationResetFromLeft) {
867-
if (key == UITransitionContextFromViewControllerKey) return self.underLeftViewController;
863+
if (key == UITransitionContextFromViewControllerKey) return self.underRightViewController;
868864
if (key == UITransitionContextToViewControllerKey) return self.topViewController;
869865
} else if (self.currentOperation == ECSlidingViewControllerOperationResetFromRight) {
870-
if (key == UITransitionContextFromViewControllerKey) return self.underRightViewController;
866+
if (key == UITransitionContextFromViewControllerKey) return self.underLeftViewController;
871867
if (key == UITransitionContextToViewControllerKey) return self.topViewController;
872868
}
873869

@@ -877,10 +873,8 @@ - (UIViewController *)viewControllerForKey:(NSString *)key {
877873
- (CGRect)initialFrameForViewController:(UIViewController *)vc {
878874
if (self.currentOperation == ECSlidingViewControllerOperationAnchorLeft) {
879875
if ([vc isEqual:self.topViewController]) return [self topViewCalculatedFrameForPosition:ECSlidingViewControllerTopViewPositionCentered];
880-
if ([vc isEqual:self.underRightViewController]) return [self underRightViewCalculatedFrame];
881876
} else if (self.currentOperation == ECSlidingViewControllerOperationAnchorRight) {
882877
if ([vc isEqual:self.topViewController]) return [self topViewCalculatedFrameForPosition:ECSlidingViewControllerTopViewPositionCentered];
883-
if ([vc isEqual:self.underLeftViewController]) return [self underLeftViewCalculatedFrame];
884878
} else if (self.currentOperation == ECSlidingViewControllerOperationResetFromLeft) {
885879
if ([vc isEqual:self.topViewController]) return [self topViewCalculatedFrameForPosition:ECSlidingViewControllerTopViewPositionAnchoredLeft];
886880
if ([vc isEqual:self.underRightViewController]) return [self underRightViewCalculatedFrame];
@@ -929,6 +923,7 @@ - (void)notifyWhenInteractionEndsUsingBlock:(void(^)(id<UIViewControllerTransiti
929923
self.coordinatorInteractionEnded = handler;
930924
}
931925

926+
/*
932927
#pragma mark AutoRotation
933928
934929
- (BOOL)shouldAutorotate {
@@ -948,5 +943,5 @@ - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
948943
return [self.topViewController preferredInterfaceOrientationForPresentation];
949944
}
950945
951-
946+
*/
952947
@end

0 commit comments

Comments
 (0)