Skip to content

Commit e1b722d

Browse files
committed
Merge branch 'master' into under_layout
2 parents 27feaef + e5d6981 commit e1b722d

File tree

6 files changed

+49
-7
lines changed

6 files changed

+49
-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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ typedef enum {
140140
*/
141141
- (UIPanGestureRecognizer *)panGesture;
142142

143+
/** Slides the top view in the direction of the specified side.
144+
145+
A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
146+
147+
@param side The side for the top view to slide towards.
148+
*/
149+
- (void)anchorTopViewTo:(ECSide)side;
150+
143151
/** Slides the top view in the direction of the specified side.
144152
145153
A peek amount or reveal amount must be set for the given side. The top view will anchor to one of those specified values.
@@ -150,6 +158,12 @@ typedef enum {
150158
*/
151159
- (void)anchorTopViewTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete;
152160

161+
/** Slides the top view off of the screen in the direction of the specified side.
162+
163+
@param side The side for the top view to slide off the screen towards.
164+
*/
165+
- (void)anchorTopViewOffScreenTo:(ECSide)side;
166+
153167
/** Slides the top view off of the screen in the direction of the specified side.
154168
155169
@param side The side for the top view to slide off the screen towards.
@@ -161,6 +175,13 @@ typedef enum {
161175
/** Slides the top view back to the center. */
162176
- (void)resetTopView;
163177

178+
/** Slides the top view back to the center.
179+
180+
@param animations Perform changes to properties that will be animated while top view is moved back to the center of the screen. Can be nil.
181+
@param onComplete Executed after the animation is completed. Can be nil.
182+
*/
183+
- (void)resetTopViewWithAnimations:(void(^)())animations onComplete:(void(^)())complete;
184+
164185
/** Returns true if the underLeft view is showing (even partially) */
165186
- (BOOL)underLeftShowing;
166187

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
225225
CGFloat currentVelocityX = currentVelocityPoint.x;
226226

227227
if ([self underLeftShowing] && currentVelocityX > 100) {
228-
[self anchorTopViewTo:ECRight animations:nil onComplete:nil];
228+
[self anchorTopViewTo:ECRight];
229229
} else if ([self underRightShowing] && currentVelocityX < 100) {
230-
[self anchorTopViewTo:ECLeft animations:nil onComplete:nil];
230+
[self anchorTopViewTo:ECLeft];
231231
} else {
232232
[self resetTopView];
233233
}
@@ -239,6 +239,11 @@ - (UIPanGestureRecognizer *)panGesture
239239
return _panGesture;
240240
}
241241

242+
- (void)anchorTopViewTo:(ECSide)side
243+
{
244+
[self anchorTopViewTo:side animations:nil onComplete:nil];
245+
}
246+
242247
- (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplete:(void (^)())complete
243248
{
244249
CGFloat newCenter = self.topView.center.x;
@@ -274,6 +279,11 @@ - (void)anchorTopViewTo:(ECSide)side animations:(void (^)())animations onComplet
274279
}];
275280
}
276281

282+
- (void)anchorTopViewOffScreenTo:(ECSide)side
283+
{
284+
[self anchorTopViewOffScreenTo:side animations:nil onComplete:nil];
285+
}
286+
277287
- (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations onComplete:(void(^)())complete
278288
{
279289
CGFloat newCenter = self.topView.center.x;
@@ -304,10 +314,21 @@ - (void)anchorTopViewOffScreenTo:(ECSide)side animations:(void(^)())animations o
304314
}
305315

306316
- (void)resetTopView
317+
{
318+
[self resetTopViewWithAnimations:nil onComplete:nil];
319+
}
320+
321+
- (void)resetTopViewWithAnimations:(void(^)())animations onComplete:(void(^)())complete
307322
{
308323
[UIView animateWithDuration:0.25f animations:^{
324+
if (animations) {
325+
animations();
326+
}
309327
[self updateTopViewHorizontalCenter:self.resettedCenter];
310328
} completion:^(BOOL finished) {
329+
if (complete) {
330+
complete();
331+
}
311332
[self topViewHorizontalCenterDidChange:self.resettedCenter];
312333
}];
313334
}

0 commit comments

Comments
 (0)