Skip to content

Commit

Permalink
fix: taphandler with doubletaphandler
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Jan 13, 2020
1 parent d2c9c8f commit 6c3ed76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src-native/ios/GestureHandler/TapHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
#import "GestureHandler.h"

@interface TapGestureHandler : GestureHandler
-(void)resetStored;
@end
25 changes: 23 additions & 2 deletions src-native/ios/GestureHandler/TapHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ - (id)initWithGestureHandler:(GestureHandler*)gestureHandler;
@end

@implementation BetterTapGestureRecognizer {
__weak GestureHandler *_gestureHandler;
__weak TapGestureHandler *_gestureHandler;
NSUInteger _tapsSoFar;
CGPoint _initPosition;
NSInteger _maxNumberOfTouches;
Expand Down Expand Up @@ -66,6 +66,7 @@ - (void)cancel

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
[_gestureHandler resetStored];
[super touchesBegan:touches withEvent:event];
if (_tapsSoFar == 0) {
_initPosition = [self locationInView:self.view];
Expand Down Expand Up @@ -166,7 +167,10 @@ - (void)reset

@end

@implementation TapGestureHandler
@implementation TapGestureHandler {
__weak NSMutableDictionary *_lastExtraEventData;
}


- (instancetype)initWithTag:(NSNumber *)tag
{
Expand Down Expand Up @@ -203,5 +207,22 @@ - (void)configure:(NSDictionary *)config
}
}

- (void)resetStored
{
_lastExtraEventData = NULL;
}
- (NSMutableDictionary *)eventExtraData:(UIGestureRecognizer *)recognizer
{
if (recognizer.numberOfTouches == 0 && _lastExtraEventData != NULL) {
return _lastExtraEventData;
}
NSMutableDictionary *result = [super eventExtraData:recognizer];
if (recognizer.numberOfTouches != 0)
{
_lastExtraEventData = result;
}
return result;
}

@end

0 comments on commit 6c3ed76

Please sign in to comment.