Open hebertialmeida opened 10 years ago
Sorry @xhzengAIB I'm working on another project because I'm going to the WWDC and I need finish this.
Hi! @hebertialmeida That's ok, you finish your project! Because WWDC is very great.
Jack
Hi! @hebertialmeida
I am trying to replicate the UIPanGestureRecognizer,
The above code is not working 100%,It shows a lag while progress,but it is working .
Can you please tell me where i am wrong,in calculating progress and offset,If u have implemented
Thank You.
(void)oneFingerGesture:(UIPanGestureRecognizer *)sender { static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined; CGPoint point; CGPoint tempvelocity;
CGFloat magnitude; if (sender.state == UIGestureRecognizerStateEnded) { [self endInteractionWithSuccess:YES];
} else if (sender.state == UIGestureRecognizerStateCancelled) { [self endInteractionWithSuccess:NO]; } else if (sender.numberOfTouches == 1 ){ NSLog(@"On finger gesture");
// the main touch point
CGPoint point1; // location of touch #1
CGFloat distance = 0.0; // computed distance between both touches
// return the locations of each gesture’s touches in the local coordinate system of a given view
point1 = [sender locationOfTouch:0 inView:sender.view];
// get the main touch point
point = [sender locationInView:sender.view];
if (sender.state == UIGestureRecognizerStateBegan)
{
tempvelocity = [sender velocityInView:sender.view];
BOOL isVerticalGesture = fabs(tempvelocity.y) > fabs(tempvelocity.x);
if (isVerticalGesture) {
if (tempvelocity.y > 0) {
direction = UIPanGestureRecognizerDirectionDown;
if (!self.hasActiveInteraction)
{
//self.initialPinchDistance = distance;
self.initialPinchPoint = point;
self.hasActiveInteraction = YES; // the transition is in active motion
[self.delegate interactionBeganAtPoint:point];
}
} else {
direction = UIPanGestureRecognizerDirectionUp;
if (!self.hasActiveInteraction)
{
//self.initialPinchDistance = distance;
self.initialPinchPoint = point;
self.hasActiveInteraction = YES; // the transition is in active motion
[self.delegate interactionBeganAtPoint:point];
}
}
}
}
if (self.hasActiveInteraction){
if (sender.state == UIGestureRecognizerStateChanged){
CGPoint translation = [sender translationInView:sender.view];
magnitude = sqrt((translation.x * translation.x) + (translation.y * translation.y));
self.initialPinchDistance = magnitude;
CGFloat delta = magnitude - self.initialPinchDistance;
CGFloat offsetX = point.x - self.initialPinchPoint.x;
CGFloat offsetY = (point.y - self.initialPinchPoint.y)+delta/M_PI;
UIOffset offsetToUse = UIOffsetMake(offsetX, offsetY);
[sender setTranslation:CGPointMake(0, 0) inView:sender.view];//no change
// CGFloat distanceDelta =magnitude; // if (self.navigationOperation == UINavigationControllerOperationPop) // { // distanceDelta = -distanceDelta; // } // CGFloat progress = MAX(MIN(((magnitude + (tempvelocity.y+tempvelocity.x) * M_PI) / 250), 1.0), 0.0);
[self updateWithProgress:magnitude andOffset:offsetToUse];
}
}
}
}
Hi! @mukyasa
You can try pull request to this open source?
Jack
I will upload this project with my version of PanGesture soon(With small Performance improvement)
@mukyasa
Please tell me, your project link?
Thanks
Jack
@mukyasa
Thanks !
Jack
Hey Jack check it now,I have made some tweaks,
Also heberti please check it out the zoom pan gesture in my version,please give some suggestion so that we can improve it.
Cheers
Hi @mukyasa I will check it! And when do you finish it, please make a pull request to this repo if possible...
Hi! @hebertialmeida would you have finished?
Jack