Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace mach_absolute_time with CACurrentMediaTime #2830

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions apple/Handlers/RNLongPressHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

#import <React/RCTConvert.h>

#import <mach/mach_time.h>

@interface RNBetterLongPressGestureRecognizer : UILongPressGestureRecognizer {
uint64_t startTime;
uint64_t previousTime;
CFTimeInterval startTime;
CFTimeInterval previousTime;
}

- (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler;
Expand All @@ -42,7 +40,7 @@ - (id)initWithGestureHandler:(RNGestureHandler *)gestureHandler

- (void)handleGesture:(UIGestureRecognizer *)recognizer
{
previousTime = mach_absolute_time();
previousTime = CACurrentMediaTime();
[_gestureHandler handleGesture:recognizer];
}

Expand All @@ -64,7 +62,7 @@ - (void)touchesBegan:(NSSet<RNGHUITouch *> *)touches withEvent:(UIEvent *)event
[_gestureHandler.pointerTracker touchesBegan:touches withEvent:event];

_initPosition = [self locationInView:self.view];
startTime = mach_absolute_time();
startTime = CACurrentMediaTime();
[_gestureHandler reset];
[self triggerAction];
}
Expand Down Expand Up @@ -109,13 +107,7 @@ - (void)reset

- (NSUInteger)getDuration
{
static mach_timebase_info_data_t sTimebaseInfo;

if (sTimebaseInfo.denom == 0) {
mach_timebase_info(&sTimebaseInfo);
}

return (NSUInteger)(((previousTime - startTime) * sTimebaseInfo.numer / (sTimebaseInfo.denom * 1000000)));
return (previousTime - startTime) * 1000;
}

@end
Expand Down
Loading