Skip to content
This repository was archived by the owner on Jan 14, 2018. It is now read-only.
Closed
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
5 changes: 5 additions & 0 deletions ECSlidingViewController/ECSlidingAnimationController.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@
*/
@interface ECSlidingAnimationController : NSObject <UIViewControllerAnimatedTransitioning>

/**
The default duration of the view transition.
*/
@property (nonatomic, assign) NSTimeInterval defaultTransitionDuration;

@end
2 changes: 1 addition & 1 deletion ECSlidingViewController/ECSlidingAnimationController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ @implementation ECSlidingAnimationController
#pragma mark - UIViewControllerAnimatedTransitioning

- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
return 0.25;
return _defaultTransitionDuration ?: 0.25;
}

- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
Expand Down
9 changes: 9 additions & 0 deletions ECSlidingViewController/ECSlidingViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#import <UIKit/UIKit.h>
#import "ECSlidingConstants.h"

extern NSString *const kECSWillAnchorTopViewToLeftNotification;
extern NSString *const kECSWillResetTopViewNotification;
extern NSString *const kECSWillAnchorTopViewToRightNotification;

@class ECSlidingViewController;

/**
Expand Down Expand Up @@ -298,4 +302,9 @@
*/
@property (nonatomic, strong) NSArray *customAnchoredGestures;

/**
The default duration of the view transition.
*/
@property (nonatomic, assign) NSTimeInterval defaultTransitionDuration;

@end
14 changes: 14 additions & 0 deletions ECSlidingViewController/ECSlidingViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#import "ECSlidingInteractiveTransition.h"
#import "ECSlidingSegue.h"

NSString *const kECSWillAnchorTopViewToLeftNotification = @"kECSWillAnchorTopViewToLeftNotification";
NSString *const kECSWillResetTopViewNotification = @"kECSWillResetTopViewNotification";
NSString *const kECSWillAnchorTopViewToRightNotification = @"kECSWillAnchorTopViewToRightNotification";

@interface ECSlidingViewController()
@property (nonatomic, assign) ECSlidingViewControllerOperation currentOperation;
@property (nonatomic, strong) ECSlidingAnimationController *defaultAnimationController;
Expand Down Expand Up @@ -316,6 +320,10 @@ - (void)setAnchorRightRevealAmount:(CGFloat)anchorRightRevealAmount {
self.preserveRightPeekAmount = NO;
}

- (void)setDefaultTransitionDuration:(NSTimeInterval)defaultTransitionDuration {
self.defaultAnimationController.defaultTransitionDuration = defaultTransitionDuration;
}

- (CGFloat)anchorLeftPeekAmount {
if (_anchorLeftPeekAmount == CGFLOAT_MAX && _anchorLeftRevealAmount != CGFLOAT_MAX) {
return CGRectGetWidth(self.view.bounds) - _anchorLeftRevealAmount;
Expand Down Expand Up @@ -420,20 +428,26 @@ - (void)resetTopViewAnimated:(BOOL)animated {
}

- (void)anchorTopViewToRightAnimated:(BOOL)animated onComplete:(void (^)())complete {
[[NSNotificationCenter defaultCenter] postNotificationName:kECSWillAnchorTopViewToRightNotification object:nil];

self.isAnimated = animated;
self.animationComplete = complete;
ECSlidingViewControllerOperation operation = [self operationFromPosition:self.currentTopViewPosition toPosition:ECSlidingViewControllerTopViewPositionAnchoredRight];
[self animateOperation:operation];
}

- (void)anchorTopViewToLeftAnimated:(BOOL)animated onComplete:(void (^)())complete {
[[NSNotificationCenter defaultCenter] postNotificationName:kECSWillAnchorTopViewToLeftNotification object:nil];

self.isAnimated = animated;
self.animationComplete = complete;
ECSlidingViewControllerOperation operation = [self operationFromPosition:self.currentTopViewPosition toPosition:ECSlidingViewControllerTopViewPositionAnchoredLeft];
[self animateOperation:operation];
}

- (void)resetTopViewAnimated:(BOOL)animated onComplete:(void(^)())complete {
[[NSNotificationCenter defaultCenter] postNotificationName:kECSWillResetTopViewNotification object:nil];

self.isAnimated = animated;
self.animationComplete = complete;
ECSlidingViewControllerOperation operation = [self operationFromPosition:self.currentTopViewPosition toPosition:ECSlidingViewControllerTopViewPositionCentered];
Expand Down