From c73cd63db47b0f9d0d1d3133cf35788853ccce7d Mon Sep 17 00:00:00 2001 From: Bryce Hackel <34104885+bhackel@users.noreply.github.com> Date: Sun, 1 Sep 2024 12:50:04 -0700 Subject: [PATCH] Cancel gesture after 1 second of inactivity --- YTLitePlus.xm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/YTLitePlus.xm b/YTLitePlus.xm index bfc82c8..ae9a152 100644 --- a/YTLitePlus.xm +++ b/YTLitePlus.xm @@ -870,6 +870,13 @@ BOOL isTabSelected = NO; } // Deactive the activity flag isValidHorizontalPan = NO; + // Cancel this gesture if it has not activated after 1 second + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + if (!isValidHorizontalPan && panGestureRecognizer.state != UIGestureRecognizerStateEnded) { + // Cancel the gesture by setting its state to UIGestureRecognizerStateCancelled + panGestureRecognizer.state = UIGestureRecognizerStateCancelled; + } + }); } // Handle changed gesture state by activating the gesture once it has exited the deadzone,