Skip to content

Commit e5d6981

Browse files
committed
Convenience methods for anchoring without callbacks
- Instead of calling anchorTopView:animations:onComplete: with nil blocks, you can just call anchorTopView:
1 parent d9ce954 commit e5d6981

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
lines changed

ECSlidingViewController/FirstTopViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO
4646

4747
- (IBAction)revealMenu:(id)sender
4848
{
49-
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
49+
[self.slidingViewController anchorTopViewTo:ECRight];
5050
}
5151

5252
- (IBAction)revealUnderRight:(id)sender
5353
{
54-
[self.slidingViewController anchorTopViewTo:ECLeft animations:nil onComplete:nil];
54+
[self.slidingViewController anchorTopViewTo:ECLeft];
5555
}
5656

5757
@end

ECSlidingViewController/SampleTableViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
4040

4141
- (IBAction)revealMenu:(id)sender
4242
{
43-
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
43+
[self.slidingViewController anchorTopViewTo:ECRight];
4444
}
4545

4646
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation

ECSlidingViewController/SecondTopViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ - (void)viewWillAppear:(BOOL)animated
2626

2727
- (IBAction)revealMenu:(id)sender
2828
{
29-
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
29+
[self.slidingViewController anchorTopViewTo:ECRight];
3030
}
3131

3232
@end

ECSlidingViewController/ThirdTopViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ - (void)viewWillAppear:(BOOL)animated
5353

5454
- (IBAction)revealMenu:(id)sender
5555
{
56-
[self.slidingViewController anchorTopViewTo:ECRight animations:nil onComplete:nil];
56+
[self.slidingViewController anchorTopViewTo:ECRight];
5757
}
5858

5959
// slidingViewController notification

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ typedef enum {
118118
*/
119119
- (UIPanGestureRecognizer *)panGesture;
120120

121+
/** Slides the top view in the direction of the specified side.
122+
123+
A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
124+
125+
@param side The side for the top view to slide towards.
126+
*/
127+
- (void)anchorTopViewTo:(ECSide)side;
128+
121129
/** Slides the top view in the direction of the specified side.
122130
123131
A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
@@ -128,6 +136,12 @@ typedef enum {
128136
*/
129137
- (void)anchorTopViewTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete;
130138

139+
/** Slides the top view off of the screen in the direction of the specified side.
140+
141+
@param side The side for the top view to slide off the screen towards.
142+
*/
143+
- (void)anchorTopViewOffScreenTo:(ECSide)side;
144+
131145
/** Slides the top view off of the screen in the direction of the specified side.
132146
133147
@param side The side for the top view to slide off the screen towards.

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
185185
CGFloat currentVelocityX = currentVelocityPoint.x;
186186

187187
if ([self underLeftShowing] && currentVelocityX > 100) {
188-
[self anchorTopViewTo:ECRight animations:nil onComplete:nil];
188+
[self anchorTopViewTo:ECRight];
189189
} else if ([self underRightShowing] && currentVelocityX < 100) {
190-
[self anchorTopViewTo:ECLeft animations:nil onComplete:nil];
190+
[self anchorTopViewTo:ECLeft];
191191
} else {
192192
[self resetTopView];
193193
}
@@ -199,6 +199,11 @@ - (UIPanGestureRecognizer *)panGesture
199199
return _panGesture;
200200
}
201201

202+
- (void)anchorTopViewTo:(ECSide)side
203+
{
204+
[self anchorTopViewTo:side animations:nil onComplete:nil];
205+
}
206+
202207
- (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplete:(void (^)())complete
203208
{
204209
CGFloat newCenter = self.topView.center.x;
@@ -234,6 +239,11 @@ - (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplet
234239
}];
235240
}
236241

242+
- (void)anchorTopViewOffScreenTo:(ECSide)side
243+
{
244+
[self anchorTopViewOffScreenTo:side animations:nil onComplete:nil];
245+
}
246+
237247
- (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete
238248
{
239249
CGFloat newCenter = self.topView.center.x;

0 commit comments

Comments
 (0)