Add 3dTouch props to touch events

Summary:
This adds the first of the three 3dTouch API types, that found on the touch event.

It adds the `force` prop to touch events when running on iOS 9 devices:
Closes https://github.com/facebook/react-native/pull/3055

Reviewed By: svcscm

Differential Revision: D2860540

Pulled By: nicklockwood

fb-gh-sync-id: 95a3eb433837c844f755b3ed4a3dfcb28452c284
This commit is contained in:
Matt Apperson 2016-01-27 07:13:14 -08:00 committed by facebook-github-bot-9
parent 4bf418a0e7
commit fff5dc3943
1 changed files with 7 additions and 1 deletions

View File

@ -108,7 +108,7 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) {
}
// Create touch
NSMutableDictionary *reactTouch = [[NSMutableDictionary alloc] initWithCapacity:9];
NSMutableDictionary *reactTouch = [[NSMutableDictionary alloc] initWithCapacity:11];
reactTouch[@"target"] = reactTag;
reactTouch[@"identifier"] = @(touchID);
reactTouch[@"touches"] = (id)kCFNull; // We hijack this touchObj to serve both as an event
@ -150,6 +150,12 @@ typedef NS_ENUM(NSInteger, RCTTouchEventType) {
reactTouch[@"locationX"] = @(touchViewLocation.x);
reactTouch[@"locationY"] = @(touchViewLocation.y);
reactTouch[@"timestamp"] = @(nativeTouch.timestamp * 1000); // in ms, for JS
if ([nativeTouch.view respondsToSelector:@selector(traitCollection)] &&
[nativeTouch.view.traitCollection respondsToSelector:@selector(forceTouchCapability)]) {
reactTouch[@"force"] = @(RCTZeroIfNaN(nativeTouch.force/nativeTouch.maximumPossibleForce));
}
}
/**