Skip to content

Commit 3a0fa68

Browse files
committed
Update doc
1 parent 4b43839 commit 3a0fa68

File tree

4 files changed

+44
-69
lines changed

4 files changed

+44
-69
lines changed

Source/AMWaveTransition.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
@import UIKit;
1010

11-
/**-----------------------------------------------------------------------------
11+
/**
1212
* @name AMWaveTransitioning
13-
* -----------------------------------------------------------------------------
13+
* Delegate protocol for AMWaveTransition
1414
*/
1515
@protocol AMWaveTransitioning <NSObject>
1616

@@ -29,8 +29,11 @@
2929
* Enum that specifies the type of animation
3030
*/
3131
typedef NS_ENUM(NSInteger, AMWaveTransitionType) {
32+
/** Smooth transition */
3233
AMWaveTransitionTypeSubtle,
34+
/** Springy transition */
3335
AMWaveTransitionTypeNervous,
36+
/** Spring transition with looser springs */
3437
AMWaveTransitionTypeBounce
3538
};
3639

@@ -39,16 +42,17 @@ typedef NS_ENUM(NSInteger, AMWaveTransitionType) {
3942
* Enum that specifies the transition type
4043
*/
4144
typedef NS_ENUM(NSInteger, AMWaveInteractiveTransitionType) {
45+
/** The transition needs to start from the edge */
4246
AMWaveTransitionEdgePan,
43-
AMWaveTransitionFullScreenPan,
47+
/** The transition can start from anywhere */
48+
AMWaveTransitionFullScreenPan
4449
};
4550

46-
@interface AMWaveTransition : NSObject <UIViewControllerAnimatedTransitioning>
47-
48-
/**-----------------------------------------------------------------------------
51+
/**
4952
* @name AMWaveTransition
50-
* -----------------------------------------------------------------------------
53+
* Custom transition between viewcontrollers holding tableviews. Each cell is animated to simulate a 'wave effect'.
5154
*/
55+
@interface AMWaveTransition : NSObject <UIViewControllerAnimatedTransitioning>
5256

5357
/** New transition
5458
*
@@ -99,9 +103,8 @@ typedef NS_ENUM(NSInteger, AMWaveInteractiveTransitionType) {
99103
*/
100104
- (void)detachInteractiveGesture;
101105

102-
/**-----------------------------------------------------------------------------
106+
/**
103107
* @name AMWaveTransition Properties
104-
* -----------------------------------------------------------------------------
105108
*/
106109

107110
/** Operation type

Source/AMWaveTransition.m

Lines changed: 21 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// AMWaveTransitioning
44
//
55
// Created by Andrea on 11/04/14.
6-
// Copyright (c) 2014 Fancy Pixel. All rights reserved.
6+
// Copyright (c) 2015 Fancy Pixel. All rights reserved.
77
//
88

99
#import "AMWaveTransition.h"
@@ -53,23 +53,19 @@ - (instancetype)init {
5353
return self;
5454
}
5555

56-
+ (instancetype)transitionWithOperation:(UINavigationControllerOperation)operation
57-
{
56+
+ (instancetype)transitionWithOperation:(UINavigationControllerOperation)operation {
5857
return [[self alloc] initWithOperation:operation andTransitionType:AMWaveTransitionTypeNervous];
5958
}
6059

61-
- (instancetype)initWithOperation:(UINavigationControllerOperation)operation
62-
{
60+
- (instancetype)initWithOperation:(UINavigationControllerOperation)operation {
6361
return [self initWithOperation:operation andTransitionType:AMWaveTransitionTypeNervous];
6462
}
6563

66-
+ (instancetype)transitionWithOperation:(UINavigationControllerOperation)operation andTransitionType:(AMWaveTransitionType)type
67-
{
64+
+ (instancetype)transitionWithOperation:(UINavigationControllerOperation)operation andTransitionType:(AMWaveTransitionType)type {
6865
return [[self alloc] initWithOperation:operation andTransitionType:type];
6966
}
7067

71-
- (instancetype)initWithOperation:(UINavigationControllerOperation)operation andTransitionType:(AMWaveTransitionType)type
72-
{
68+
- (instancetype)initWithOperation:(UINavigationControllerOperation)operation andTransitionType:(AMWaveTransitionType)type {
7369
self = [super init];
7470
if (self) {
7571
[self setup];
@@ -79,17 +75,15 @@ - (instancetype)initWithOperation:(UINavigationControllerOperation)operation and
7975
return self;
8076
}
8177

82-
- (void)setup
83-
{
78+
- (void)setup {
8479
_viewControllersInset = 20;
8580
_interactiveTransitionType = AMWaveTransitionEdgePan;
8681
_animateAlphaWithInteractiveTransition = NO;
8782
_duration = DURATION;
8883
_maxDelay = MAX_DELAY;
8984
}
9085

91-
- (void)attachInteractiveGestureToNavigationController:(UINavigationController *)navigationController
92-
{
86+
- (void)attachInteractiveGestureToNavigationController:(UINavigationController *)navigationController {
9387
self.navigationController = navigationController;
9488
if (self.interactiveTransitionType == AMWaveTransitionEdgePan) {
9589
UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self
@@ -107,8 +101,7 @@ - (void)attachInteractiveGestureToNavigationController:(UINavigationController *
107101
self.attachmentsTo = [@[] mutableCopy];
108102
}
109103

110-
- (void)detachInteractiveGesture
111-
{
104+
- (void)detachInteractiveGesture {
112105
UINavigationController *navigationController = self.navigationController;
113106
[navigationController.view removeGestureRecognizer:self.gesture];
114107
self.navigationController = nil;
@@ -117,8 +110,7 @@ - (void)detachInteractiveGesture
117110
self.animator = nil;
118111
}
119112

120-
- (void)handlePan:(UIScreenEdgePanGestureRecognizer *)gesture
121-
{
113+
- (void)handlePan:(UIScreenEdgePanGestureRecognizer *)gesture {
122114
UINavigationController *navigationController = self.navigationController; // support CLANG_WARN_OBJC_RECEIVER_WEAK
123115

124116
// Starting controller
@@ -239,8 +231,7 @@ - (void)handlePan:(UIScreenEdgePanGestureRecognizer *)gesture
239231
}
240232
}
241233

242-
- (void)animationCompletionForInteractiveTransitionForView:(UIView *)view
243-
{
234+
- (void)animationCompletionForInteractiveTransitionForView:(UIView *)view {
244235
CGRect rect = view.frame;
245236
rect.origin.x = 0;
246237
UINavigationController *navigationController = self.navigationController;
@@ -253,17 +244,14 @@ - (void)animationCompletionForInteractiveTransitionForView:(UIView *)view
253244
view.alpha = [self alphaForView:view];
254245
}
255246

256-
257-
- (void)setPresentedFrameForView:(UIView *)view
258-
{
247+
- (void)setPresentedFrameForView:(UIView *)view {
259248
CGRect rect = view.frame;
260249
rect.origin.x = 0;
261250
view.frame = rect;
262251
view.alpha = [self alphaForView:view];
263252
}
264253

265-
- (void)kickCellOutside:(UIView *)view
266-
{
254+
- (void)kickCellOutside:(UIView *)view {
267255
CGRect rect = view.frame;
268256
rect.origin.x = -SCREEN_WIDTH - self.viewControllersInset;
269257
UINavigationController *navigationController = self.navigationController;
@@ -276,18 +264,15 @@ - (void)kickCellOutside:(UIView *)view
276264
view.frame = rect;
277265
}
278266

279-
- (void)completeToVC:(UIView *)view
280-
{
267+
- (void)completeToVC:(UIView *)view {
281268
[self completeTransitionWithView:view inVC:AMWaveTransitionToVC];
282269
}
283270

284-
- (void)completeFromVC:(UIView *)view
285-
{
271+
- (void)completeFromVC:(UIView *)view {
286272
[self completeTransitionWithView:view inVC:AMWaveTransitionFromVC];
287273
}
288274

289-
- (void)completeTransitionWithView:(UIView *)view inVC:(AMWaveTransitionViewControllers)viewController
290-
{
275+
- (void)completeTransitionWithView:(UIView *)view inVC:(AMWaveTransitionViewControllers)viewController {
291276
CGRect rect = view.frame;
292277
if (viewController == AMWaveTransitionFromVC) {
293278
rect.origin.x = SCREEN_WIDTH - self.viewControllersInset;
@@ -302,8 +287,7 @@ - (void)changeAttachmentWithIndex:(NSUInteger)index
302287
inView:(UIView *)view
303288
touchX:(CGFloat)touchX
304289
velocity:(CGFloat)velocity
305-
inVC:(AMWaveTransitionViewControllers)viewController
306-
{
290+
inVC:(AMWaveTransitionViewControllers)viewController {
307291
int selectionIndex;
308292
NSInteger correction = 2;
309293
NSMutableArray *arrayWithAttachments;
@@ -328,8 +312,7 @@ - (void)changeAttachmentWithIndex:(NSUInteger)index
328312
[arrayWithAttachments[index] setAnchorPoint:(CGPoint){delta, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}];
329313
}
330314

331-
- (void)createAttachmentForView:(UIView *)view inVC:(AMWaveTransitionViewControllers)viewController
332-
{
315+
- (void)createAttachmentForView:(UIView *)view inVC:(AMWaveTransitionViewControllers)viewController {
333316
UIAttachmentBehavior *attachment = [[UIAttachmentBehavior alloc] initWithItem:view attachedToAnchor:(CGPoint){0, [view.superview convertPoint:view.frame.origin toView:nil].y + view.frame.size.height / 2}];
334317
[attachment setDamping:0.4];
335318
[attachment setFrequency:1];
@@ -346,8 +329,7 @@ - (void)createAttachmentForView:(UIView *)view inVC:(AMWaveTransitionViewControl
346329
[arrayWithAttachments addObject:attachment];
347330
}
348331

349-
- (CGFloat)alphaForView:(UIView *)view
350-
{
332+
- (CGFloat)alphaForView:(UIView *)view {
351333
if (self.animateAlphaWithInteractiveTransition) {
352334
CGFloat width = SCREEN_WIDTH - self.viewControllersInset;
353335
CGFloat alpha = (width - fabs(view.frame.origin.x)) * (1 / width);
@@ -359,13 +341,11 @@ - (CGFloat)alphaForView:(UIView *)view
359341

360342
#pragma mark - Non interactive transition
361343

362-
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext
363-
{
344+
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
364345
return self.duration + self.maxDelay;
365346
}
366347

367-
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext
368-
{
348+
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
369349
UIViewController *fromVC;
370350
if ([[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey] isKindOfClass:[UINavigationController class]]) {
371351
fromVC = (UIViewController*)([(UINavigationController*)[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey] visibleViewController]);
@@ -465,8 +445,7 @@ - (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionC
465445
}];
466446
}
467447

468-
- (NSArray *)visibleCellsForViewController:(UIViewController*)viewController
469-
{
448+
- (NSArray *)visibleCellsForViewController:(UIViewController*)viewController {
470449
NSArray *visibleCells = nil;
471450

472451
if ([viewController respondsToSelector:@selector(visibleCells)]) {

Source/AMWaveViewController.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
#import "AMWaveTransition.h"
1010

11-
@import UIKit;
11+
#import <UIKit/UIKit.h>
1212

13-
@interface AMWaveViewController : UIViewController <UINavigationControllerDelegate, AMWaveTransitioning>
14-
15-
/**-----------------------------------------------------------------------------
13+
/**
1614
* @name AMWaveViewController
17-
* -----------------------------------------------------------------------------
15+
* UIViewController subclass that implements the custom transition
1816
*/
17+
@interface AMWaveViewController : UIViewController <UINavigationControllerDelegate, AMWaveTransitioning>
1918

2019
/** Wave transition
2120
*

Source/AMWaveViewController.m

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Demo
44
//
55
// Created by Andrea Mazzini on 16/04/14.
6-
// Copyright (c) 2014 Fancy Pixel. All rights reserved.
6+
// Copyright (c) 2015 Fancy Pixel. All rights reserved.
77
//
88

99
#import "AMWaveViewController.h"
@@ -14,42 +14,36 @@ @interface AMWaveViewController ()
1414

1515
@implementation AMWaveViewController
1616

17-
- (void)viewDidLoad
18-
{
17+
- (void)viewDidLoad {
1918
[super viewDidLoad];
2019
}
2120

22-
- (void)viewDidAppear:(BOOL)animated
23-
{
21+
- (void)viewDidAppear:(BOOL)animated {
2422
[super viewDidAppear:animated];
2523
[self.navigationController setDelegate:self];
2624
[self.interactive attachInteractiveGestureToNavigationController:self.navigationController];
2725
}
2826

29-
- (void)viewDidDisappear:(BOOL)animated
30-
{
27+
- (void)viewDidDisappear:(BOOL)animated {
3128
[super viewDidDisappear:animated];
3229
[self.interactive detachInteractiveGesture];
3330
}
3431

3532
- (id<UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
3633
animationControllerForOperation:(UINavigationControllerOperation)operation
3734
fromViewController:(UIViewController*)fromVC
38-
toViewController:(UIViewController*)toVC
39-
{
35+
toViewController:(UIViewController*)toVC {
4036
if (operation != UINavigationControllerOperationNone) {
4137
return [AMWaveTransition transitionWithOperation:operation andTransitionType:AMWaveTransitionTypeNervous];
4238
}
4339
return nil;
4440
}
4541

46-
- (NSArray *)visibleCells
47-
{
42+
- (NSArray *)visibleCells {
4843
return nil;
4944
}
5045

51-
- (void)dealloc
52-
{
46+
- (void)dealloc {
5347
[self.navigationController setDelegate:nil];
5448
}
5549

0 commit comments

Comments
 (0)