Skip to content

Commit 94d098c

Browse files
zdavisonenriquez
authored andcommitted
Added a continuous block callback to sliding
1 parent b2a1d16 commit 94d098c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

ECSlidingViewController/SecondTopViewController.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ - (void)viewWillAppear:(BOOL)animated
2020
self.slidingViewController.underRightViewController = nil;
2121

2222
[self.view addGestureRecognizer:self.slidingViewController.panGesture];
23+
24+
self.slidingViewController.continuousBlock = ^(float x){
25+
self.view.backgroundColor = [UIColor colorWithRed:x/self.view.bounds.size.width green:50 blue:70 alpha:1];
26+
};
2327
}
2428

2529
- (IBAction)revealMenu:(id)sender

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ typedef enum {
165165
*/
166166
@property (nonatomic, assign) NSUInteger panningVelocityXThreshold;
167167

168+
/** Can be set to provide a continuous callback as the top view slides.
169+
170+
Useful for animations synchronized to the sliding.
171+
172+
*/
173+
@property (nonatomic,copy) void (^continuousBlock)(float xPos);
174+
168175
/** Returns a horizontal panning gesture for moving the top view.
169176
170177
This is typically added to the top view or a top view's navigation bar.

ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
250250
{
251251
CGPoint currentTouchPoint = [recognizer locationInView:self.view];
252252
CGFloat currentTouchPositionX = currentTouchPoint.x;
253+
254+
if(self.continuousBlock)
255+
self.continuousBlock(currentTouchPositionX);
253256

254257
if (recognizer.state == UIGestureRecognizerStateBegan) {
255258
self.initialTouchPositionX = currentTouchPositionX;

0 commit comments

Comments
 (0)