Skip to content

Commit

Permalink
Fixed finalPoint handling
Browse files Browse the repository at this point in the history
  • Loading branch information
taglia committed Feb 16, 2016
1 parent 5e33d12 commit 4f88f5e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 334 deletions.
8 changes: 4 additions & 4 deletions ElasticTransistionExample/InitialViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ - (void)viewDidLoad {
transition.sticky = YES;
transition.showShadow = YES;
transition.panThreshold = 0.3;
//transition.radiusFactor = 0.3;
transition.transformType = TRANSLATEMID;
transition.overlayColor = [UIColor colorWithWhite:0 alpha:0.5];
transition.shadowColor = [UIColor colorWithWhite:0 alpha:0.5];
transition.transformType = ROTATE;

//transition.overlayColor = [UIColor colorWithWhite:0 alpha:0.5];
//transition.shadowColor = [UIColor colorWithWhite:0 alpha:0.5];


// gesture recognizers
Expand Down
18 changes: 6 additions & 12 deletions ElasticTransition/EdgePanTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ -(id)init{
self.panThreshold = 0.2;
self.edge = RIGHT;

NSLog(@"[EdgePanTransition] %@" , [HelperFunctions typeToStringOfEdge:self.edge]);
//NSLog(@"[EdgePanTransition] %@" , [HelperFunctions typeToStringOfEdge:self.edge]);

self.transitioning = NO;
self.presenting = YES;
Expand Down Expand Up @@ -153,32 +153,26 @@ -(void)startInteractivePresentFromViewController:(UIViewController*)fromVC ToVie
self.translation = [pan translationInView:pan.view];
self.dragPoint = [pan locationInView:pan.view];

NSLog(@"START T:(%.1f,%.1f)\tD:(%.1f,%.1f)", self.translation.x, self.translation.y, self.dragPoint.x, self.dragPoint.y);
//NSLog(@"START T:(%.1f,%.1f)\tD:(%.1f,%.1f)", self.translation.x, self.translation.y, self.dragPoint.x, self.dragPoint.y);
}


-(BOOL)updateInteractiveTransitionWithGestureRecognizer:(UIPanGestureRecognizer*) pan{

if (self.transitioning == true){
NSLog(@"YES");
}else{
NSLog(@"NO");
}



if (!self.transitioning){
NSLog(@"UPDATE NO");

return NO;
}

NSLog(@"UPDATE YES");
//NSLog(@"UPDATE YES");

if (pan.state == UIGestureRecognizerStateChanged){

self.translation = [pan translationInView:pan.view];
self.dragPoint = [pan locationInView:pan.view];

NSLog(@"UPDATE T:(%.1f,%.1f)\tD:(%.1f,%.1f)", self.translation.x, self.translation.y, self.dragPoint.x, self.dragPoint.y);
//NSLog(@"UPDATE T:(%.1f,%.1f)\tD:(%.1f,%.1f)", self.translation.x, self.translation.y, self.dragPoint.x, self.dragPoint.y);

[self update];

Expand Down
10 changes: 1 addition & 9 deletions ElasticTransition/ElasticShapeLayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ @implementation ElasticShapeLayer
@synthesize dragPoint;
@synthesize radiusFactor;


-(id)init{

self = [super init];
Expand Down Expand Up @@ -84,7 +83,7 @@ -(CGPathRef)currentPath{

CGPoint centerPoint = self.dragPoint;

NSLog(@"D:(%.1f,%.1f)",self.dragPoint.x, self.dragPoint.y);
//NSLog(@"D:(%.1f,%.1f)",self.dragPoint.x, self.dragPoint.y);

CGPoint leftPoint, rightPoint, bottomRightPoint, bottomLeftPoint;

Expand Down Expand Up @@ -116,13 +115,6 @@ -(CGPathRef)currentPath{
break;
}

/*
NSLog(@"leftPoint :(%.1f,%.1f)", leftPoint.x, leftPoint.y);
NSLog(@"rightPoint :(%.1f,%.1f)", rightPoint.x, rightPoint.y);
NSLog(@"bottomRightPoint :(%.1f,%.1f)", bottomRightPoint.x, bottomRightPoint.y);
NSLog(@"bottomLeftPoint :(%.1f,%.1f)", bottomLeftPoint.x, bottomLeftPoint.y);
*/

UIBezierPath *shapePath = [UIBezierPath new];

[shapePath moveToPoint:leftPoint];
Expand Down
4 changes: 4 additions & 0 deletions ElasticTransition/ElasticTransition.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ typedef NS_ENUM(int,ElasticTransitionBackgroundTransform){
*/
@property (nonatomic) CGFloat shadowRadius;



@property (nonatomic) ElasticTransitionBackgroundTransform transformType;

@property (nonatomic) BOOL useTranlation;
Expand All @@ -112,6 +114,8 @@ typedef NS_ENUM(int,ElasticTransitionBackgroundTransform){
@end




@protocol ElasticMenuTransitionDelegate

@optional
Expand Down
33 changes: 14 additions & 19 deletions ElasticTransition/ElasticTransition.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,19 @@ -(id)init{
self.containerColor = [UIColor colorWithRed:152.0/255.0 green:174.0/255.0 blue:196.0/255.0 alpha:1.0];
self.overlayColor = [UIColor colorWithRed:152.0/255.0 green:174.0/255.0 blue:196.0/255.0 alpha:0.5];
self.showShadow = FALSE;
self.shadowColor = [UIColor colorWithRed:100.0/255.0 green:122.0/255.0 blue:144.0/255.0 alpha:0.5];
self.shadowColor = [UIColor colorWithRed:100.0/255.0 green:122.0/255.0 blue:144.0/255.0 alpha:1.0];
self.shadowRadius = 50.0;

self.transformType = TRANSLATEMID;

NSLog(@"[ElasticTransition] %@", [self transformTypeToString]);
//NSLog(@"[ElasticTransition] %@", [self transformTypeToString]);

self.startingPoint = CGPointZero;


self.contentLength = 0.0;
self.lastPoint = CGPointZero;

// self.maskLayer = [[CALayer alloc] init];

self.useTranlation = TRUE;
self.damping = 0.2f;

Expand Down Expand Up @@ -115,7 +113,7 @@ -(void)setContentLength:(CGFloat)aContentLength{

self.stickDistance = self.sticky ? self.contentLength * self.panThreshold : 0.0;

NSLog(@"stickDistance: %f", self.stickDistance);
//NSLog(@"stickDistance: %f", self.stickDistance);
}


Expand Down Expand Up @@ -143,12 +141,10 @@ -(void)setDamping:(CGFloat)aDamping{

- (CGPoint)finalPoint{

static BOOL p;

p = TRUE;
BOOL p = self.presenting;

// NSLog(@"presenting è nil");
// NSLog(@"%@| self %@", p ? @"1" : @"0", self.presenting ? @"Yes" : @"No");
// NSLog(@"presenting è nil");
// NSLog(@"%@| self %@", p ? @"1" : @"0", self.presenting ? @"Yes" : @"No");

switch (self.edge){
case LEFT:
Expand All @@ -164,12 +160,10 @@ - (CGPoint)finalPoint{

- (CGPoint)finalPoint:(BOOL)presentingIn{

BOOL p;
BOOL p = presentingIn;

p = presentingIn;

NSLog(@"presenting: %@", presentingIn ? @"1" : @"0");
NSLog(@"%@| self %@", p ? @"1" : @"0", self.presenting ? @"Yes" : @"No");
// NSLog(@"presenting: %@", presentingIn ? @"1" : @"0");
// NSLog(@"%@| self %@", p ? @"1" : @"0", self.presenting ? @"Yes" : @"No");

switch (self.edge){
case LEFT:
Expand Down Expand Up @@ -325,7 +319,7 @@ -(void)update{
}


NSLog(@"cb.point:(%.1f,%.1f) | lb.point:(%.1f,%.1f)", self.cb.point.x, self.cb.point.y, self.lb.point.x, self.lb.point.y);
//NSLog(@"cb.point:(%.1f,%.1f) | lb.point:(%.1f,%.1f)", self.cb.point.x, self.cb.point.y, self.lb.point.x, self.lb.point.y);
}
}

Expand Down Expand Up @@ -354,7 +348,6 @@ -(void)updateShape{

CGFloat progress = 1.0 - (CGPointDistance(self.lc.center, finalPoint) / CGPointDistance(initialPoint, finalPoint));

NSLog(@"Progress: %f", progress);

switch (self.edge){

Expand Down Expand Up @@ -474,7 +467,7 @@ -(void)updateShape{
}
}

NSLog(@"Translation: (%.1f, %.1f)", x, y);
//NSLog(@"Translation: (%.1f, %.1f)", x, y);

self.backView.layer.transform = CATransform3DMakeTranslation(x, y, 0);

Expand All @@ -487,6 +480,8 @@ -(void)updateShape{
}
}

//NSLog(@"progress: %f", progress);

self.overlayView.alpha = progress;

[self updateShadow:progress];
Expand Down Expand Up @@ -550,7 +545,7 @@ -(void)setup{
self.overlayView.frame = self.container.bounds;
self.overlayView.backgroundColor = self.overlayColor;
[self.overlayView addGestureRecognizer:self.backgroundExitPanGestureRecognizer];
//[self.container addSubview:self.overlayView];
[self.container addSubview:self.overlayView];

// 4. setup front view
CGRect rect = self.container.bounds;
Expand Down
Binary file not shown.
Loading

0 comments on commit 4f88f5e

Please sign in to comment.