Skip to content
This repository

Added continuous callback block for sliding. #103

Closed
wants to merge 1 commit into from

2 participants

@thingsdoer Mike Enriquez
@thingsdoer

Allows you to hook into the sliding to provide a continuous callback, useful for synchronized animations, as follows:

self.slidingViewController.continuousBlock = ^(float x){
    self.view.backgroundColor = [UIColor colorWithWhite:x/self.view.bounds.size.width alpha:1];
  };
Mike Enriquez
Owner

This is neat!

The problem is that it is only called while panning. It doesn't get called when tapping buttons that cause an anchor or reset.

Mike Enriquez
Owner

Merged e6fed49

Mike Enriquez enriquez closed this September 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 15, 2013
@thingsdoer Added a continuous block callback to sliding 2ae2a2b
This page is out of date. Refresh to see the latest.
4  ECSlidingViewController/SecondTopViewController.m
@@ -20,6 +20,10 @@ - (void)viewWillAppear:(BOOL)animated
20 20
   self.slidingViewController.underRightViewController = nil;
21 21
   
22 22
   [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
+  };
23 27
 }
24 28
 
25 29
 - (IBAction)revealMenu:(id)sender
7  ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.h
@@ -159,6 +159,13 @@ typedef enum {
159 159
  */
160 160
 @property (nonatomic, assign) ECResetStrategy resetStrategy;
161 161
 
  162
+/** Can be set to provide a continuous callback as the top view slides.
  163
+ 
  164
+ Useful for animations synchronized to the sliding.
  165
+ 
  166
+ */
  167
+@property (nonatomic,copy) void (^continuousBlock)(float xPos);
  168
+
162 169
 /** Returns a horizontal panning gesture for moving the top view.
163 170
  
164 171
  This is typically added to the top view or a top view's navigation bar.
3  ECSlidingViewController/Vendor/ECSlidingViewController/ECSlidingViewController.m
@@ -248,6 +248,9 @@ - (void)updateTopViewHorizontalCenterWithRecognizer:(UIPanGestureRecognizer *)re
248 248
 {
249 249
   CGPoint currentTouchPoint     = [recognizer locationInView:self.view];
250 250
   CGFloat currentTouchPositionX = currentTouchPoint.x;
  251
+    
  252
+  if(self.continuousBlock)
  253
+    self.continuousBlock(currentTouchPositionX);
251 254
   
252 255
   if (recognizer.state == UIGestureRecognizerStateBegan) {
253 256
     self.initialTouchPositionX = currentTouchPositionX;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.