Skip to content

Commit

Permalink
Prevent native wrapper recognizer to stay around.
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagiera committed Jul 28, 2017
1 parent a2ad73b commit bc80d6b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
22 changes: 22 additions & 0 deletions ios/Handlers/RNGestureHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@ @interface RNDummyGestureRecognizer : UIGestureRecognizer


@implementation RNDummyGestureRecognizer

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
self.state = UIGestureRecognizerStateFailed;
[self reset];
}

- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
self.state = UIGestureRecognizerStateCancelled;
[self reset];
}

@end


Expand Down Expand Up @@ -735,6 +748,15 @@ @implementation RNRootViewGestureRecognizer
BOOL _active;
}

- (instancetype)init
{
if (self = [super init]) {
self.delaysTouchesEnded = NO;
self.delaysTouchesBegan = NO;
}
return self;
}

- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer
{
return ![preventedGestureRecognizer isKindOfClass:[RCTTouchHandler class]];
Expand Down
11 changes: 6 additions & 5 deletions ios/RNGestureHandlerManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ - (void)dropGestureHandlersForView:(NSNumber *)viewTag

- (void)handleSetJSResponder:(NSNumber *)viewTag blockNativeResponder:(NSNumber *)blockNativeResponder
{
NSLog(@"SET JS RESP");
for (RCTRootView *rootView in _rootViews) {
for (UIGestureRecognizer *recognizer in rootView.gestureRecognizers) {
if ([recognizer isKindOfClass:[RNRootViewGestureRecognizer class]]) {
[(RNRootViewGestureRecognizer *)recognizer blockOtherRecognizers];
if ([blockNativeResponder boolValue]) {
for (RCTRootView *rootView in _rootViews) {
for (UIGestureRecognizer *recognizer in rootView.gestureRecognizers) {
if ([recognizer isKindOfClass:[RNRootViewGestureRecognizer class]]) {
[(RNRootViewGestureRecognizer *)recognizer blockOtherRecognizers];
}
}
}
}
Expand Down

0 comments on commit bc80d6b

Please sign in to comment.