mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
PointerEvents: Fix x/y coordinate system for PointerEvents, set some properties for "mouse" pointerType
Summary: Changelog: [Internal] - Fix more pointer event platform tests. * Fix the coordinate system to use DIP * Set some properties for when pointerType="mouse" Reviewed By: vincentriemer Differential Revision: D39184713 fbshipit-source-id: d86f798f3e0a377ff1c159fb308329a2c9ae03ff
This commit is contained in:
committed by
Facebook GitHub Bot
parent
64ae12e553
commit
b09821591c
@@ -172,8 +172,9 @@ public class PointerEvent extends Event<PointerEvent> {
|
||||
// https://www.w3.org/TR/pointerevents/#pointerevent-interface
|
||||
pointerEvent.putDouble("pointerId", pointerId);
|
||||
pointerEvent.putDouble("pressure", mMotionEvent.getPressure(index));
|
||||
pointerEvent.putString(
|
||||
"pointerType", PointerEventHelper.getW3CPointerType(mMotionEvent.getToolType(index)));
|
||||
|
||||
String pointerType = PointerEventHelper.getW3CPointerType(mMotionEvent.getToolType(index));
|
||||
pointerEvent.putString("pointerType", pointerType);
|
||||
|
||||
pointerEvent.putBoolean(
|
||||
"isPrimary", PointerEventHelper.isPrimary(pointerId, mPrimaryPointerId, mMotionEvent));
|
||||
@@ -181,8 +182,8 @@ public class PointerEvent extends Event<PointerEvent> {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent
|
||||
// Client refers to upper left edge of the content area (viewport)
|
||||
// We define the viewport to be ReactRootView
|
||||
double clientX = mMotionEvent.getX(index);
|
||||
double clientY = mMotionEvent.getX(index);
|
||||
double clientX = PixelUtil.toDIPFromPixel(mMotionEvent.getX(index));
|
||||
double clientY = PixelUtil.toDIPFromPixel(mMotionEvent.getY(index));
|
||||
pointerEvent.putDouble("clientX", clientX);
|
||||
pointerEvent.putDouble("clientY", clientY);
|
||||
|
||||
@@ -201,6 +202,13 @@ public class PointerEvent extends Event<PointerEvent> {
|
||||
pointerEvent.putInt("target", this.getViewTag());
|
||||
pointerEvent.putDouble("timestamp", this.getTimestampMs());
|
||||
|
||||
if (pointerType.equals(PointerEventHelper.POINTER_TYPE_MOUSE)) {
|
||||
pointerEvent.putDouble("width", 1);
|
||||
pointerEvent.putDouble("height", 1);
|
||||
pointerEvent.putDouble("tiltX", 0);
|
||||
pointerEvent.putDouble("tiltY", 0);
|
||||
}
|
||||
|
||||
return pointerEvent;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user