Skip to content

Commit 5c2b30f

Browse files
committed
Use middle point
1 parent d90b06a commit 5c2b30f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/react-native-gesture-handler/apple/Handlers/RNNativeViewHandler.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ - (RNGestureHandlerEventExtraData *)extraDataForView:(UIView *)sender
203203
{
204204
RNGHUITouch *touch = [[event allTouches] anyObject];
205205
CGPoint position = touch ? [touch locationInView:sender] : CGPointZero;
206-
CGPoint absolutePosition = touch ? [touch locationInView:nil] : CGPointZero;
206+
CGPoint absolutePosition = touch ? [touch locationInView:nil] : [sender convertPoint:CGPointZero toView:nil];
207207

208208
return [RNGestureHandlerEventExtraData forPointerInside:pointerInside
209209
withPosition:position
@@ -223,10 +223,12 @@ - (void)sendActiveStateEventIfChangedForView:(UIView *)sender extraData:(RNGestu
223223

224224
- (void)handleSwitch:(UIView *)sender
225225
{
226+
CGPoint center = CGPointMake(CGRectGetMidX(sender.bounds), CGRectGetMidY(sender.bounds));
227+
CGPoint absoluteCenter = [sender convertPoint:center toView:nil];
226228
RNGestureHandlerEventExtraData * (^extraData)(void) = ^{
227229
return [RNGestureHandlerEventExtraData forPointerInside:YES
228-
withPosition:CGPointZero
229-
withAbsolutePosition:CGPointZero
230+
withPosition:center
231+
withAbsolutePosition:absoluteCenter
230232
withNumberOfTouches:1
231233
withPointerType:self->_pointerType];
232234
};

0 commit comments

Comments
 (0)