improve custom edge swipe recognizer on detecting start point. Swipe half screen from left edge to quit session now works on ipad mini5.

This commit is contained in:
ZWM
2024-05-09 23:00:19 +08:00
parent b98ccb2a30
commit 2e7ffc2c52
@@ -36,12 +36,15 @@
[super touchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
CGPoint gestureEndPoint = [touch locationInView:self.view];
CGFloat nomarlizedgestureEndPointXDelta = (gestureEndPoint.x-_startPoint.x)/screenWidthInPoints;
CGFloat nomarlizedGestureEndPointX = gestureEndPoint.x/screenWidthInPoints;
CGFloat nomarlizedStartPointX = _startPoint.x/screenWidthInPoints;
// CGFloat nomarlizedgestureEndPointYDelta = (gestureEndPoint.y-_startPoint.y)/screenHeightInPoints;
// Log(LOG_I, @"current point x: %f", nomarlizedgestureEndPointXDelta);
NSLog(@"in CUSTOM swipe REC");
NSLog(@"startpointX %f", _startPoint.x);
NSLog(@"NorXDelta %f", nomarlizedGestureEndPointX);
_nomarlizedswipeThreshold = 0.5; // You need swipe half of screen width from left edge to trigger this Recognizer
if (_startPoint.x == 0.0 && nomarlizedgestureEndPointXDelta > _nomarlizedswipeThreshold) {
if (nomarlizedStartPointX <= 0.025 && nomarlizedGestureEndPointX > _nomarlizedswipeThreshold) {
// Detected a swipe from the left edge that exceeds _nomarlizedswipeThreshold
if (self.state == UIGestureRecognizerStatePossible) {
self.state = UIGestureRecognizerStateBegan;