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

Add number of touches on Android and iOS if needed #152

Merged
merged 6 commits into from
May 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
CR fixes
  • Loading branch information
osdnk committed May 7, 2018
commit 81920ccc024f49aaa3371385bfe8e6fa52a47890
14 changes: 7 additions & 7 deletions ios/Handlers/RNNativeViewHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,21 +99,21 @@ - (void)handleTouchDown:(UIView *)sender forEvent:(UIEvent *)event

[self sendEventsInState:RNGestureHandlerStateActive
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES]];
}

- (void)handleTouchUpOutside:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
}

- (void)handleTouchUpInside:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES]];
}

- (void)handleDragExit:(UIView *)sender forEvent:(UIEvent *)event
Expand All @@ -124,26 +124,26 @@ - (void)handleDragExit:(UIView *)sender forEvent:(UIEvent *)event
[control cancelTrackingWithEvent:event];
[self sendEventsInState:RNGestureHandlerStateEnd
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
} else {
[self sendEventsInState:RNGestureHandlerStateActive
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
}
}

- (void)handleDragEnter:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateActive
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:YES]];
}

- (void)handleTouchCancel:(UIView *)sender forEvent:(UIEvent *)event
{
[self sendEventsInState:RNGestureHandlerStateCancelled
forViewWithTag:sender.reactTag
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO withNumberOfTouches:_recognizer.numberOfTouches]];
withExtraData:[RNGestureHandlerEventExtraData forPointerInside:NO]];
}

@end
5 changes: 1 addition & 4 deletions ios/RNGestureHandlerEvents.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
withFocalPoint:(CGPoint)focalPoint
withVelocity:(CGFloat)velocity
withNumberOfTouches:(NSUInteger)numberOfTouches;
+ (RNGestureHandlerEventExtraData *)withNumberOfTouches:(NSUInteger)numberOfTouches
withDirection:(UISwipeGestureRecognizerDirection)direction;
+ (RNGestureHandlerEventExtraData *)forRotation:(CGFloat)rotation
withAnchorPoint:(CGPoint)anchorPoint
withVelocity:(CGFloat)velocity
withNumberOfTouches:(NSUInteger)numberOfTouches;
+ (RNGestureHandlerEventExtraData *)forPointerInside:(BOOL)pointerInside
withNumberOfTouches:(NSUInteger)numberOfTouches;
+ (RNGestureHandlerEventExtraData *)forPointerInside:(BOOL)pointerInside;
@end

@interface RNGestureHandlerEvent : NSObject <RCTEvent>
Expand Down
10 changes: 1 addition & 9 deletions ios/RNGestureHandlerEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,9 @@ + (RNGestureHandlerEventExtraData *)forRotation:(CGFloat)rotation
}

+ (RNGestureHandlerEventExtraData *)forPointerInside:(BOOL)pointerInside
withNumberOfTouches:(NSUInteger)numberOfTouches
{
return [[RNGestureHandlerEventExtraData alloc]
initWithData:@{@"pointerInside": @(pointerInside),
@"numberOfPointers": @(numberOfTouches)}];
}

+ (RNGestureHandlerEventExtraData *)withNumberOfTouches:(NSUInteger)numberOfTouches
{
return [[RNGestureHandlerEventExtraData alloc]
initWithData:@{@"numberOfPointers": @(numberOfTouches)}];
initWithData:@{@"pointerInside": @(pointerInside)}];
}

@end
Expand Down