react-native-gesture-handler 2.19.0 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/android/build.gradle +7 -12
  2. package/android/fabric/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +1 -1
  3. package/android/paper/src/main/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +1 -1
  4. package/android/src/main/java/com/swmansion/gesturehandler/core/GestureUtils.kt +1 -0
  5. package/android/src/main/java/com/swmansion/gesturehandler/core/HoverGestureHandler.kt +11 -0
  6. package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +8 -0
  7. package/android/src/main/java/com/swmansion/gesturehandler/core/StylusData.kt +103 -0
  8. package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +24 -15
  9. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt +7 -0
  10. package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt +7 -0
  11. package/android/src/main/jni/CMakeLists.txt +18 -9
  12. package/apple/Handlers/RNLongPressHandler.m +2 -0
  13. package/apple/Handlers/RNPanHandler.m +57 -7
  14. package/apple/Handlers/RNRotationHandler.m +1 -1
  15. package/apple/RNGHStylusData.h +77 -0
  16. package/apple/RNGHStylusData.m +37 -0
  17. package/apple/RNGestureHandlerButtonComponentView.mm +35 -0
  18. package/apple/RNGestureHandlerEvents.h +3 -1
  19. package/apple/RNGestureHandlerEvents.m +11 -3
  20. package/lib/commonjs/components/GestureButtons.js +5 -1
  21. package/lib/commonjs/components/GestureButtons.js.map +1 -1
  22. package/lib/commonjs/components/GestureComponents.js.map +1 -1
  23. package/lib/commonjs/components/Pressable/Pressable.js +5 -14
  24. package/lib/commonjs/components/Pressable/Pressable.js.map +1 -1
  25. package/lib/commonjs/components/Pressable/utils.js +1 -23
  26. package/lib/commonjs/components/Pressable/utils.js.map +1 -1
  27. package/lib/commonjs/handlers/GestureHandlerEventPayload.js +4 -0
  28. package/lib/commonjs/handlers/createHandler.js +2 -1
  29. package/lib/commonjs/handlers/createHandler.js.map +1 -1
  30. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  31. package/lib/commonjs/handlers/gestures/hoverGesture.js.map +1 -1
  32. package/lib/commonjs/jestUtils/jestUtils.js +12 -4
  33. package/lib/commonjs/jestUtils/jestUtils.js.map +1 -1
  34. package/lib/commonjs/web/handlers/GestureHandler.js +1 -3
  35. package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
  36. package/lib/commonjs/web/handlers/HoverGestureHandler.js +18 -1
  37. package/lib/commonjs/web/handlers/HoverGestureHandler.js.map +1 -1
  38. package/lib/commonjs/web/handlers/PanGestureHandler.js +8 -1
  39. package/lib/commonjs/web/handlers/PanGestureHandler.js.map +1 -1
  40. package/lib/commonjs/web/interfaces.js.map +1 -1
  41. package/lib/commonjs/web/tools/EventManager.js.map +1 -1
  42. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js +0 -3
  43. package/lib/commonjs/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  44. package/lib/commonjs/web/tools/PointerEventManager.js +3 -37
  45. package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
  46. package/lib/commonjs/web/utils.js +173 -0
  47. package/lib/commonjs/web/utils.js.map +1 -1
  48. package/lib/module/components/GestureButtons.js +5 -1
  49. package/lib/module/components/GestureButtons.js.map +1 -1
  50. package/lib/module/components/GestureComponents.js.map +1 -1
  51. package/lib/module/components/Pressable/Pressable.js +7 -14
  52. package/lib/module/components/Pressable/Pressable.js.map +1 -1
  53. package/lib/module/components/Pressable/utils.js +1 -22
  54. package/lib/module/components/Pressable/utils.js.map +1 -1
  55. package/lib/module/handlers/GestureHandlerEventPayload.js +1 -1
  56. package/lib/module/handlers/createHandler.js +2 -1
  57. package/lib/module/handlers/createHandler.js.map +1 -1
  58. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  59. package/lib/module/handlers/gestures/hoverGesture.js.map +1 -1
  60. package/lib/module/jestUtils/jestUtils.js +12 -4
  61. package/lib/module/jestUtils/jestUtils.js.map +1 -1
  62. package/lib/module/web/handlers/GestureHandler.js +1 -3
  63. package/lib/module/web/handlers/GestureHandler.js.map +1 -1
  64. package/lib/module/web/handlers/HoverGestureHandler.js +18 -1
  65. package/lib/module/web/handlers/HoverGestureHandler.js.map +1 -1
  66. package/lib/module/web/handlers/PanGestureHandler.js +8 -1
  67. package/lib/module/web/handlers/PanGestureHandler.js.map +1 -1
  68. package/lib/module/web/interfaces.js.map +1 -1
  69. package/lib/module/web/tools/EventManager.js.map +1 -1
  70. package/lib/module/web/tools/GestureHandlerWebDelegate.js +0 -2
  71. package/lib/module/web/tools/GestureHandlerWebDelegate.js.map +1 -1
  72. package/lib/module/web/tools/PointerEventManager.js +4 -38
  73. package/lib/module/web/tools/PointerEventManager.js.map +1 -1
  74. package/lib/module/web/utils.js +170 -0
  75. package/lib/module/web/utils.js.map +1 -1
  76. package/lib/typescript/components/GestureComponents.d.ts +1 -1
  77. package/lib/typescript/components/Pressable/utils.d.ts +3 -5
  78. package/lib/typescript/handlers/GestureHandlerEventPayload.d.ts +35 -0
  79. package/lib/typescript/handlers/gestures/gesture.d.ts +2 -2
  80. package/lib/typescript/handlers/gestures/hoverGesture.d.ts +1 -6
  81. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -1
  82. package/lib/typescript/jestUtils/jestUtils.d.ts +1 -1
  83. package/lib/typescript/web/handlers/HoverGestureHandler.d.ts +2 -0
  84. package/lib/typescript/web/handlers/PanGestureHandler.d.ts +3 -1
  85. package/lib/typescript/web/interfaces.d.ts +8 -3
  86. package/lib/typescript/web/tools/EventManager.d.ts +2 -2
  87. package/lib/typescript/web/utils.d.ts +2 -1
  88. package/package.json +1 -1
  89. package/src/components/GestureButtons.tsx +2 -1
  90. package/src/components/GestureComponents.tsx +1 -1
  91. package/src/components/Pressable/Pressable.tsx +16 -29
  92. package/src/components/Pressable/utils.ts +5 -49
  93. package/src/handlers/GestureHandlerEventPayload.ts +42 -0
  94. package/src/handlers/createHandler.tsx +1 -0
  95. package/src/handlers/gestures/gesture.ts +3 -1
  96. package/src/handlers/gestures/hoverGesture.ts +1 -7
  97. package/src/jestUtils/jestUtils.ts +9 -1
  98. package/src/web/handlers/GestureHandler.ts +1 -1
  99. package/src/web/handlers/HoverGestureHandler.ts +16 -2
  100. package/src/web/handlers/PanGestureHandler.ts +10 -1
  101. package/src/web/interfaces.ts +9 -3
  102. package/src/web/tools/EventManager.ts +2 -4
  103. package/src/web/tools/GestureHandlerWebDelegate.ts +0 -2
  104. package/src/web/tools/PointerEventManager.ts +2 -38
  105. package/src/web/utils.ts +174 -1
  106. package/lib/commonjs/web/tools/TouchEventManager.js +0 -164
  107. package/lib/commonjs/web/tools/TouchEventManager.js.map +0 -1
  108. package/lib/module/web/tools/TouchEventManager.js +0 -149
  109. package/lib/module/web/tools/TouchEventManager.js.map +0 -1
  110. package/lib/typescript/web/tools/TouchEventManager.d.ts +0 -11
  111. package/src/web/tools/TouchEventManager.ts +0 -175
@@ -39,4 +39,174 @@ export function calculateViewScale(view) {
39
39
 
40
40
  return resultScales;
41
41
  }
42
+ export function tryExtractStylusData(event) {
43
+ const pointerType = PointerTypeMapping.get(event.pointerType);
44
+
45
+ if (pointerType !== PointerType.STYLUS) {
46
+ return;
47
+ } // @ts-ignore This property exists (https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent#instance_properties)
48
+
49
+
50
+ const eventAzimuthAngle = event.azimuthAngle; // @ts-ignore This property exists (https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent#instance_properties)
51
+
52
+ const eventAltitudeAngle = event.altitudeAngle;
53
+
54
+ if (event.tiltX === 0 && event.tiltY === 0) {
55
+ // If we are in this branch, it means that either tilt properties are not supported and we have to calculate them from altitude and azimuth angles,
56
+ // or stylus is perpendicular to the screen and we can use altitude / azimuth instead of tilt
57
+ // If azimuth and altitude are undefined in this branch, it means that we are either perpendicular to the screen,
58
+ // or that none of the position sets is supported. In that case, we can treat stylus as perpendicular
59
+ if (eventAzimuthAngle === undefined || eventAltitudeAngle === undefined) {
60
+ return {
61
+ tiltX: 0,
62
+ tiltY: 0,
63
+ azimuthAngle: Math.PI / 2,
64
+ altitudeAngle: Math.PI / 2,
65
+ pressure: event.pressure
66
+ };
67
+ }
68
+
69
+ const {
70
+ tiltX,
71
+ tiltY
72
+ } = spherical2tilt(eventAltitudeAngle, eventAzimuthAngle);
73
+ return {
74
+ tiltX,
75
+ tiltY,
76
+ azimuthAngle: eventAzimuthAngle,
77
+ altitudeAngle: eventAltitudeAngle,
78
+ pressure: event.pressure
79
+ };
80
+ }
81
+
82
+ const {
83
+ altitudeAngle,
84
+ azimuthAngle
85
+ } = tilt2spherical(event.tiltX, event.tiltY);
86
+ return {
87
+ tiltX: event.tiltX,
88
+ tiltY: event.tiltY,
89
+ azimuthAngle,
90
+ altitudeAngle,
91
+ pressure: event.pressure
92
+ };
93
+ } // `altitudeAngle` and `azimuthAngle` are experimental properties, which are not supported on Firefox and Safari.
94
+ // Given that, we use `tilt` properties and algorithm that converts one value to another.
95
+ //
96
+ // Source: https://w3c.github.io/pointerevents/#converting-between-tiltx-tilty-and-altitudeangle-azimuthangle
97
+
98
+ function tilt2spherical(tiltX, tiltY) {
99
+ const tiltXrad = tiltX * Math.PI / 180;
100
+ const tiltYrad = tiltY * Math.PI / 180; // calculate azimuth angle
101
+
102
+ let azimuthAngle = 0;
103
+
104
+ if (tiltX === 0) {
105
+ if (tiltY > 0) {
106
+ azimuthAngle = Math.PI / 2;
107
+ } else if (tiltY < 0) {
108
+ azimuthAngle = 3 * Math.PI / 2;
109
+ }
110
+ } else if (tiltY === 0) {
111
+ if (tiltX < 0) {
112
+ azimuthAngle = Math.PI;
113
+ }
114
+ } else if (Math.abs(tiltX) === 90 || Math.abs(tiltY) === 90) {
115
+ // not enough information to calculate azimuth
116
+ azimuthAngle = 0;
117
+ } else {
118
+ // Non-boundary case: neither tiltX nor tiltY is equal to 0 or +-90
119
+ const tanX = Math.tan(tiltXrad);
120
+ const tanY = Math.tan(tiltYrad);
121
+ azimuthAngle = Math.atan2(tanY, tanX);
122
+
123
+ if (azimuthAngle < 0) {
124
+ azimuthAngle += 2 * Math.PI;
125
+ }
126
+ } // calculate altitude angle
127
+
128
+
129
+ let altitudeAngle = 0;
130
+
131
+ if (Math.abs(tiltX) === 90 || Math.abs(tiltY) === 90) {
132
+ altitudeAngle = 0;
133
+ } else if (tiltX === 0) {
134
+ altitudeAngle = Math.PI / 2 - Math.abs(tiltYrad);
135
+ } else if (tiltY === 0) {
136
+ altitudeAngle = Math.PI / 2 - Math.abs(tiltXrad);
137
+ } else {
138
+ // Non-boundary case: neither tiltX nor tiltY is equal to 0 or +-90
139
+ altitudeAngle = Math.atan(1.0 / Math.sqrt(Math.pow(Math.tan(tiltXrad), 2) + Math.pow(Math.tan(tiltYrad), 2)));
140
+ }
141
+
142
+ return {
143
+ altitudeAngle: altitudeAngle,
144
+ azimuthAngle: azimuthAngle
145
+ };
146
+ } // If we are on a platform that doesn't support `tiltX` and `tiltY`, we have to calculate them from `altitude` and `azimuth` angles.
147
+ //
148
+ // Source: https://w3c.github.io/pointerevents/#converting-between-tiltx-tilty-and-altitudeangle-azimuthangle
149
+
150
+
151
+ function spherical2tilt(altitudeAngle, azimuthAngle) {
152
+ const radToDeg = 180 / Math.PI;
153
+ let tiltXrad = 0;
154
+ let tiltYrad = 0;
155
+
156
+ if (altitudeAngle === 0) {
157
+ // the pen is in the X-Y plane
158
+ if (azimuthAngle === 0 || azimuthAngle === 2 * Math.PI) {
159
+ // pen is on positive X axis
160
+ tiltXrad = Math.PI / 2;
161
+ }
162
+
163
+ if (azimuthAngle === Math.PI / 2) {
164
+ // pen is on positive Y axis
165
+ tiltYrad = Math.PI / 2;
166
+ }
167
+
168
+ if (azimuthAngle === Math.PI) {
169
+ // pen is on negative X axis
170
+ tiltXrad = -Math.PI / 2;
171
+ }
172
+
173
+ if (azimuthAngle === 3 * Math.PI / 2) {
174
+ // pen is on negative Y axis
175
+ tiltYrad = -Math.PI / 2;
176
+ }
177
+
178
+ if (azimuthAngle > 0 && azimuthAngle < Math.PI / 2) {
179
+ tiltXrad = Math.PI / 2;
180
+ tiltYrad = Math.PI / 2;
181
+ }
182
+
183
+ if (azimuthAngle > Math.PI / 2 && azimuthAngle < Math.PI) {
184
+ tiltXrad = -Math.PI / 2;
185
+ tiltYrad = Math.PI / 2;
186
+ }
187
+
188
+ if (azimuthAngle > Math.PI && azimuthAngle < 3 * Math.PI / 2) {
189
+ tiltXrad = -Math.PI / 2;
190
+ tiltYrad = -Math.PI / 2;
191
+ }
192
+
193
+ if (azimuthAngle > 3 * Math.PI / 2 && azimuthAngle < 2 * Math.PI) {
194
+ tiltXrad = Math.PI / 2;
195
+ tiltYrad = -Math.PI / 2;
196
+ }
197
+ }
198
+
199
+ if (altitudeAngle !== 0) {
200
+ const tanAlt = Math.tan(altitudeAngle);
201
+ tiltXrad = Math.atan(Math.cos(azimuthAngle) / tanAlt);
202
+ tiltYrad = Math.atan(Math.sin(azimuthAngle) / tanAlt);
203
+ }
204
+
205
+ const tiltX = Math.round(tiltXrad * radToDeg);
206
+ const tiltY = Math.round(tiltYrad * radToDeg);
207
+ return {
208
+ tiltX,
209
+ tiltY
210
+ };
211
+ }
42
212
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["utils.ts"],"names":["PointerType","isPointerInBounds","view","x","y","rect","getBoundingClientRect","left","right","top","bottom","PointerTypeMapping","Map","MOUSE","TOUCH","STYLUS","OTHER","degToRad","degrees","Math","PI","coneToDeviation","cos","calculateViewScale","styles","getComputedStyle","resultScales","scaleX","scaleY","scale","undefined","scales","split","parseFloat","matrixElements","RegExp","exec","transform","matrixElementsArray"],"mappings":"AAAA,SAASA,WAAT,QAA4B,gBAA5B;AAGA,OAAO,SAASC,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,CAAV,EAAe;AACbL,MAAAA,YAAY,CAACC,MAAb,GAAsBM,UAAU,CAACF,MAAM,CAAC,CAAD,CAAP,CAAhC;AACD;;AAEDL,IAAAA,YAAY,CAACE,MAAb,GAAsBG,MAAM,CAAC,CAAD,CAAN,GAClBE,UAAU,CAACF,MAAM,CAAC,CAAD,CAAP,CADQ,GAElBE,UAAU,CAACF,MAAM,CAAC,CAAD,CAAP,CAFd;AAGD,GAnBmD,CAqBpD;;;AACA,QAAMG,cAAc,mBAAG,IAAIC,MAAJ,CAAW,gBAAX,EAA6BC,IAA7B,CACrBZ,MAAM,CAACa,SADc,CAAH,iDAAG,aAEnB,CAFmB,CAAvB;;AAIA,MAAIH,cAAJ,EAAoB;AAClB,UAAMI,mBAAmB,GAAGJ,cAAc,CAACF,KAAf,CAAqB,IAArB,CAA5B;AAEAN,IAAAA,YAAY,CAACC,MAAb,IAAuBM,UAAU,CAACK,mBAAmB,CAAC,CAAD,CAApB,CAAjC;AACAZ,IAAAA,YAAY,CAACE,MAAb,IAAuBK,UAAU,CAACK,mBAAmB,CAAC,CAAD,CAApB,CAAjC;AACD;;AAED,SAAOZ,YAAP;AACD","sourcesContent":["import { PointerType } from '../PointerType';\nimport { Point } from './interfaces';\n\nexport function isPointerInBounds(view: HTMLElement, { x, y }: Point): boolean {\n const rect: DOMRect = view.getBoundingClientRect();\n\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n}\n\nexport const PointerTypeMapping = new Map<string, PointerType>([\n ['mouse', PointerType.MOUSE],\n ['touch', PointerType.TOUCH],\n ['pen', PointerType.STYLUS],\n ['none', PointerType.OTHER],\n]);\n\nexport const degToRad = (degrees: number) => (degrees * Math.PI) / 180;\n\nexport const coneToDeviation = (degrees: number) =>\n Math.cos(degToRad(degrees / 2));\n\nexport function calculateViewScale(view: HTMLElement) {\n const styles = getComputedStyle(view);\n\n const resultScales = {\n scaleX: 1,\n scaleY: 1,\n };\n\n // Get scales from scale property\n if (styles.scale !== undefined && styles.scale !== 'none') {\n const scales = styles.scale.split(' ');\n\n if (scales[0]) {\n resultScales.scaleX = parseFloat(scales[0]);\n }\n\n resultScales.scaleY = scales[1]\n ? parseFloat(scales[1])\n : parseFloat(scales[0]);\n }\n\n // Get scales from transform property\n const matrixElements = new RegExp(/matrix\\((.+)\\)/).exec(\n styles.transform\n )?.[1];\n\n if (matrixElements) {\n const matrixElementsArray = matrixElements.split(', ');\n\n resultScales.scaleX *= parseFloat(matrixElementsArray[0]);\n resultScales.scaleY *= parseFloat(matrixElementsArray[3]);\n }\n\n return resultScales;\n}\n"]}
1
+ {"version":3,"sources":["utils.ts"],"names":["PointerType","isPointerInBounds","view","x","y","rect","getBoundingClientRect","left","right","top","bottom","PointerTypeMapping","Map","MOUSE","TOUCH","STYLUS","OTHER","degToRad","degrees","Math","PI","coneToDeviation","cos","calculateViewScale","styles","getComputedStyle","resultScales","scaleX","scaleY","scale","undefined","scales","split","parseFloat","matrixElements","RegExp","exec","transform","matrixElementsArray","tryExtractStylusData","event","pointerType","get","eventAzimuthAngle","azimuthAngle","eventAltitudeAngle","altitudeAngle","tiltX","tiltY","pressure","spherical2tilt","tilt2spherical","tiltXrad","tiltYrad","abs","tanX","tan","tanY","atan2","atan","sqrt","pow","radToDeg","tanAlt","sin","round"],"mappings":"AAAA,SAASA,WAAT,QAA4B,gBAA5B;AAGA,OAAO,SAASC,iBAAT,CAA2BC,IAA3B,EAA8C;AAAEC,EAAAA,CAAF;AAAKC,EAAAA;AAAL,CAA9C,EAAwE;AAC7E,QAAMC,IAAa,GAAGH,IAAI,CAACI,qBAAL,EAAtB;AAEA,SAAOH,CAAC,IAAIE,IAAI,CAACE,IAAV,IAAkBJ,CAAC,IAAIE,IAAI,CAACG,KAA5B,IAAqCJ,CAAC,IAAIC,IAAI,CAACI,GAA/C,IAAsDL,CAAC,IAAIC,IAAI,CAACK,MAAvE;AACD;AAED,OAAO,MAAMC,kBAAkB,GAAG,IAAIC,GAAJ,CAA6B,CAC7D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AAT,GAAP;AACD","sourcesContent":["import { PointerType } from '../PointerType';\nimport type { Point, StylusData } from './interfaces';\n\nexport function isPointerInBounds(view: HTMLElement, { x, y }: Point): boolean {\n const rect: DOMRect = view.getBoundingClientRect();\n\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n}\n\nexport const PointerTypeMapping = new Map<string, PointerType>([\n ['mouse', PointerType.MOUSE],\n ['touch', PointerType.TOUCH],\n ['pen', PointerType.STYLUS],\n ['none', PointerType.OTHER],\n]);\n\nexport const degToRad = (degrees: number) => (degrees * Math.PI) / 180;\n\nexport const coneToDeviation = (degrees: number) =>\n Math.cos(degToRad(degrees / 2));\n\nexport function calculateViewScale(view: HTMLElement) {\n const styles = getComputedStyle(view);\n\n const resultScales = {\n scaleX: 1,\n scaleY: 1,\n };\n\n // Get scales from scale property\n if (styles.scale !== undefined && styles.scale !== 'none') {\n const scales = styles.scale.split(' ');\n\n if (scales[0]) {\n resultScales.scaleX = parseFloat(scales[0]);\n }\n\n resultScales.scaleY = scales[1]\n ? parseFloat(scales[1])\n : parseFloat(scales[0]);\n }\n\n // Get scales from transform property\n const matrixElements = new RegExp(/matrix\\((.+)\\)/).exec(\n styles.transform\n )?.[1];\n\n if (matrixElements) {\n const matrixElementsArray = matrixElements.split(', ');\n\n resultScales.scaleX *= parseFloat(matrixElementsArray[0]);\n resultScales.scaleY *= parseFloat(matrixElementsArray[3]);\n }\n\n return resultScales;\n}\n\nexport function tryExtractStylusData(\n event: PointerEvent\n): StylusData | undefined {\n const pointerType = PointerTypeMapping.get(event.pointerType);\n\n if (pointerType !== PointerType.STYLUS) {\n return;\n }\n\n // @ts-ignore This property exists (https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent#instance_properties)\n const eventAzimuthAngle: number | undefined = event.azimuthAngle;\n // @ts-ignore This property exists (https://developer.mozilla.org/en-US/docs/Web/API/PointerEvent#instance_properties)\n const eventAltitudeAngle: number | undefined = event.altitudeAngle;\n\n if (event.tiltX === 0 && event.tiltY === 0) {\n // If we are in this branch, it means that either tilt properties are not supported and we have to calculate them from altitude and azimuth angles,\n // or stylus is perpendicular to the screen and we can use altitude / azimuth instead of tilt\n\n // If azimuth and altitude are undefined in this branch, it means that we are either perpendicular to the screen,\n // or that none of the position sets is supported. In that case, we can treat stylus as perpendicular\n if (eventAzimuthAngle === undefined || eventAltitudeAngle === undefined) {\n return {\n tiltX: 0,\n tiltY: 0,\n azimuthAngle: Math.PI / 2,\n altitudeAngle: Math.PI / 2,\n pressure: event.pressure,\n };\n }\n\n const { tiltX, tiltY } = spherical2tilt(\n eventAltitudeAngle,\n eventAzimuthAngle\n );\n\n return {\n tiltX,\n tiltY,\n azimuthAngle: eventAzimuthAngle,\n altitudeAngle: eventAltitudeAngle,\n pressure: event.pressure,\n };\n }\n\n const { altitudeAngle, azimuthAngle } = tilt2spherical(\n event.tiltX,\n event.tiltY\n );\n\n return {\n tiltX: event.tiltX,\n tiltY: event.tiltY,\n azimuthAngle,\n altitudeAngle,\n pressure: event.pressure,\n };\n}\n\n// `altitudeAngle` and `azimuthAngle` are experimental properties, which are not supported on Firefox and Safari.\n// Given that, we use `tilt` properties and algorithm that converts one value to another.\n//\n// Source: https://w3c.github.io/pointerevents/#converting-between-tiltx-tilty-and-altitudeangle-azimuthangle\nfunction tilt2spherical(tiltX: number, tiltY: number) {\n const tiltXrad = (tiltX * Math.PI) / 180;\n const tiltYrad = (tiltY * Math.PI) / 180;\n\n // calculate azimuth angle\n let azimuthAngle = 0;\n\n if (tiltX === 0) {\n if (tiltY > 0) {\n azimuthAngle = Math.PI / 2;\n } else if (tiltY < 0) {\n azimuthAngle = (3 * Math.PI) / 2;\n }\n } else if (tiltY === 0) {\n if (tiltX < 0) {\n azimuthAngle = Math.PI;\n }\n } else if (Math.abs(tiltX) === 90 || Math.abs(tiltY) === 90) {\n // not enough information to calculate azimuth\n azimuthAngle = 0;\n } else {\n // Non-boundary case: neither tiltX nor tiltY is equal to 0 or +-90\n const tanX = Math.tan(tiltXrad);\n const tanY = Math.tan(tiltYrad);\n\n azimuthAngle = Math.atan2(tanY, tanX);\n if (azimuthAngle < 0) {\n azimuthAngle += 2 * Math.PI;\n }\n }\n\n // calculate altitude angle\n let altitudeAngle = 0;\n\n if (Math.abs(tiltX) === 90 || Math.abs(tiltY) === 90) {\n altitudeAngle = 0;\n } else if (tiltX === 0) {\n altitudeAngle = Math.PI / 2 - Math.abs(tiltYrad);\n } else if (tiltY === 0) {\n altitudeAngle = Math.PI / 2 - Math.abs(tiltXrad);\n } else {\n // Non-boundary case: neither tiltX nor tiltY is equal to 0 or +-90\n altitudeAngle = Math.atan(\n 1.0 /\n Math.sqrt(\n Math.pow(Math.tan(tiltXrad), 2) + Math.pow(Math.tan(tiltYrad), 2)\n )\n );\n }\n\n return { altitudeAngle: altitudeAngle, azimuthAngle: azimuthAngle };\n}\n\n// If we are on a platform that doesn't support `tiltX` and `tiltY`, we have to calculate them from `altitude` and `azimuth` angles.\n//\n// Source: https://w3c.github.io/pointerevents/#converting-between-tiltx-tilty-and-altitudeangle-azimuthangle\nfunction spherical2tilt(altitudeAngle: number, azimuthAngle: number) {\n const radToDeg = 180 / Math.PI;\n\n let tiltXrad = 0;\n let tiltYrad = 0;\n\n if (altitudeAngle === 0) {\n // the pen is in the X-Y plane\n if (azimuthAngle === 0 || azimuthAngle === 2 * Math.PI) {\n // pen is on positive X axis\n tiltXrad = Math.PI / 2;\n }\n if (azimuthAngle === Math.PI / 2) {\n // pen is on positive Y axis\n tiltYrad = Math.PI / 2;\n }\n if (azimuthAngle === Math.PI) {\n // pen is on negative X axis\n tiltXrad = -Math.PI / 2;\n }\n if (azimuthAngle === (3 * Math.PI) / 2) {\n // pen is on negative Y axis\n tiltYrad = -Math.PI / 2;\n }\n if (azimuthAngle > 0 && azimuthAngle < Math.PI / 2) {\n tiltXrad = Math.PI / 2;\n tiltYrad = Math.PI / 2;\n }\n if (azimuthAngle > Math.PI / 2 && azimuthAngle < Math.PI) {\n tiltXrad = -Math.PI / 2;\n tiltYrad = Math.PI / 2;\n }\n if (azimuthAngle > Math.PI && azimuthAngle < (3 * Math.PI) / 2) {\n tiltXrad = -Math.PI / 2;\n tiltYrad = -Math.PI / 2;\n }\n if (azimuthAngle > (3 * Math.PI) / 2 && azimuthAngle < 2 * Math.PI) {\n tiltXrad = Math.PI / 2;\n tiltYrad = -Math.PI / 2;\n }\n }\n\n if (altitudeAngle !== 0) {\n const tanAlt = Math.tan(altitudeAngle);\n\n tiltXrad = Math.atan(Math.cos(azimuthAngle) / tanAlt);\n tiltYrad = Math.atan(Math.sin(azimuthAngle) / tanAlt);\n }\n\n const tiltX = Math.round(tiltXrad * radToDeg);\n const tiltY = Math.round(tiltYrad * radToDeg);\n\n return { tiltX, tiltY };\n}\n"]}
@@ -17,6 +17,6 @@ export declare const DrawerLayoutAndroid: React.ForwardRefExoticComponent<RNDraw
17
17
  children?: React.ReactNode;
18
18
  } & NativeViewGestureHandlerProps & React.RefAttributes<React.ComponentType<any>>>;
19
19
  export type DrawerLayoutAndroid = typeof DrawerLayoutAndroid & RNDrawerLayoutAndroid;
20
- export declare const FlatList: <ItemT = any>(props: React.PropsWithChildren<RNFlatListProps<ItemT> & React.RefAttributes<FlatList<ItemT>> & NativeViewGestureHandlerProps>, ref: React.ForwardedRef<FlatList<ItemT>>) => ReactElement | null;
20
+ export declare const FlatList: <ItemT = any>(props: React.PropsWithChildren<Omit<RNFlatListProps<ItemT>, "renderScrollComponent"> & React.RefAttributes<FlatList<ItemT>> & NativeViewGestureHandlerProps>, ref: React.ForwardedRef<FlatList<ItemT>>) => ReactElement | null;
21
21
  export type FlatList<ItemT = any> = typeof FlatList & RNFlatList<ItemT>;
22
22
  export {};
@@ -1,7 +1,6 @@
1
- import { Insets, ViewStyle } from 'react-native';
2
- import { LongPressGestureHandlerEventPayload } from '../../handlers/GestureHandlerEventPayload';
1
+ import { Insets } from 'react-native';
2
+ import { HoverGestureHandlerEventPayload, LongPressGestureHandlerEventPayload } from '../../handlers/GestureHandlerEventPayload';
3
3
  import { TouchData, GestureStateChangeEvent, GestureTouchEvent } from '../../handlers/gestureHandlerCommon';
4
- import { HoverGestureHandlerEventPayload } from '../../handlers/gestures/hoverGesture';
5
4
  import { PressableEvent } from './PressableProps';
6
5
  declare const numberAsInset: (value: number) => Insets;
7
6
  declare const addInsets: (a: Insets, b: Insets) => Insets;
@@ -11,5 +10,4 @@ declare const isTouchWithinInset: (dimensions: {
11
10
  }, inset: Insets, touch?: TouchData) => boolean;
12
11
  declare const gestureToPressableEvent: (event: GestureStateChangeEvent<HoverGestureHandlerEventPayload | LongPressGestureHandlerEventPayload>) => PressableEvent;
13
12
  declare const gestureTouchToPressableEvent: (event: GestureTouchEvent) => PressableEvent;
14
- declare const splitStyles: (from: ViewStyle) => [ViewStyle, ViewStyle];
15
- export { numberAsInset, addInsets, isTouchWithinInset, gestureToPressableEvent, gestureTouchToPressableEvent, splitStyles, };
13
+ export { numberAsInset, addInsets, isTouchWithinInset, gestureToPressableEvent, gestureTouchToPressableEvent, };
@@ -1,3 +1,4 @@
1
+ import { StylusData } from '../web/interfaces';
1
2
  export type FlingGestureHandlerEventPayload = {
2
3
  x: number;
3
4
  y: number;
@@ -104,6 +105,10 @@ export type PanGestureHandlerEventPayload = {
104
105
  * value is expressed in point units per second.
105
106
  */
106
107
  velocityY: number;
108
+ /**
109
+ * Object containing additional stylus data.
110
+ */
111
+ stylusData: StylusData | undefined;
107
112
  };
108
113
  export type PinchGestureHandlerEventPayload = {
109
114
  /**
@@ -157,3 +162,33 @@ export type RotationGestureHandlerEventPayload = {
157
162
  */
158
163
  velocity: number;
159
164
  };
165
+ export type HoverGestureHandlerEventPayload = {
166
+ /**
167
+ * X coordinate of the current position of the pointer relative to the view
168
+ * attached to the handler. Expressed in point units.
169
+ */
170
+ x: number;
171
+ /**
172
+ * Y coordinate of the current position of the pointer relative to the view
173
+ * attached to the handler. Expressed in point units.
174
+ */
175
+ y: number;
176
+ /**
177
+ * X coordinate of the current position of the pointer relative to the window.
178
+ * The value is expressed in point units. It is recommended to use it instead
179
+ * of `x` in cases when the original view can be transformed as an
180
+ * effect of the gesture.
181
+ */
182
+ absoluteX: number;
183
+ /**
184
+ * Y coordinate of the current position of the pointer relative to the window.
185
+ * The value is expressed in point units. It is recommended to use it instead
186
+ * of `y` in cases when the original view can be transformed as an
187
+ * effect of the gesture.
188
+ */
189
+ absoluteY: number;
190
+ /**
191
+ * Object containing additional stylus data.
192
+ */
193
+ stylusData: StylusData | undefined;
194
+ };
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { HitSlop, CommonGestureConfig, GestureTouchEvent, GestureStateChangeEvent, GestureUpdateEvent, ActiveCursor, MouseButton } from '../gestureHandlerCommon';
3
3
  import { GestureStateManagerType } from './gestureStateManager';
4
- import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, PanGestureHandlerEventPayload, PinchGestureHandlerEventPayload, RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, NativeViewGestureHandlerPayload } from '../GestureHandlerEventPayload';
5
- export type GestureType = BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<FlingGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload>;
4
+ import type { FlingGestureHandlerEventPayload, ForceTouchGestureHandlerEventPayload, LongPressGestureHandlerEventPayload, PanGestureHandlerEventPayload, PinchGestureHandlerEventPayload, RotationGestureHandlerEventPayload, TapGestureHandlerEventPayload, NativeViewGestureHandlerPayload, HoverGestureHandlerEventPayload } from '../GestureHandlerEventPayload';
5
+ export type GestureType = BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<FlingGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload> | BaseGesture<HoverGestureHandlerEventPayload>;
6
6
  export type GestureRef = number | GestureType | React.RefObject<GestureType | undefined> | React.RefObject<React.ComponentType | undefined>;
7
7
  export interface BaseGestureConfig extends CommonGestureConfig, Record<string, unknown> {
8
8
  ref?: React.MutableRefObject<GestureType | undefined>;
@@ -1,11 +1,6 @@
1
1
  import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
2
2
  import { GestureUpdateEvent } from '../gestureHandlerCommon';
3
- export type HoverGestureHandlerEventPayload = {
4
- x: number;
5
- y: number;
6
- absoluteX: number;
7
- absoluteY: number;
8
- };
3
+ import type { HoverGestureHandlerEventPayload } from '../GestureHandlerEventPayload';
9
4
  export type HoverGestureChangeEventPayload = {
10
5
  changeX: number;
11
6
  changeY: number;
@@ -6,7 +6,7 @@ export declare function registerOldGestureHandler(handlerTag: number, handler: G
6
6
  export declare function unregisterHandler(handlerTag: number, testID?: string): void;
7
7
  export declare function findHandler(handlerTag: number): GestureType | undefined;
8
8
  export declare function findOldGestureHandler(handlerTag: number): GestureHandlerCallbacks | undefined;
9
- export declare function findHandlerByTestID(testID: string): import("./gestures/gesture").BaseGesture<Record<string, unknown>> | import("./gestures/gesture").BaseGesture<Record<string, never>> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").TapGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").PanGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").LongPressGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").RotationGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").PinchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").ForceTouchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").NativeViewGestureHandlerPayload> | null;
9
+ export declare function findHandlerByTestID(testID: string): import("./gestures/gesture").BaseGesture<Record<string, unknown>> | import("./gestures/gesture").BaseGesture<Record<string, never>> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").TapGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").PanGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").LongPressGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").RotationGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").PinchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").ForceTouchGestureHandlerEventPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").NativeViewGestureHandlerPayload> | import("./gestures/gesture").BaseGesture<import("./GestureHandlerEventPayload").HoverGestureHandlerEventPayload> | null;
10
10
  export interface GestureHandlerCallbacks {
11
11
  onGestureEvent: (event: GestureEvent<any>) => void;
12
12
  onGestureStateChange: (event: HandlerStateChangeEvent<any>) => void;
@@ -26,5 +26,5 @@ type ClassComponentConstructor<P> = new (props: P) => React.Component<P, any, an
26
26
  type ExtractPayloadFromProps<T> = T extends BaseGestureHandlerProps<infer TPayload> ? TPayload : never;
27
27
  type ExtractConfig<T> = T extends BaseGesture<infer TGesturePayload> ? TGesturePayload : T extends ClassComponentConstructor<infer THandlerProps> ? ExtractPayloadFromProps<THandlerProps> : Record<string, unknown>;
28
28
  export declare function fireGestureHandler<THandler extends AllGestures | AllHandlers>(componentOrGesture: ReactTestInstance | GestureType, eventList?: Partial<GestureHandlerTestEvent<ExtractConfig<THandler>>>[]): void;
29
- export declare function getByGestureTestId(testID: string): BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload>;
29
+ export declare function getByGestureTestId(testID: string): BaseGesture<Record<string, unknown>> | BaseGesture<Record<string, never>> | BaseGesture<TapGestureHandlerEventPayload> | BaseGesture<PanGestureHandlerEventPayload> | BaseGesture<LongPressGestureHandlerEventPayload> | BaseGesture<RotationGestureHandlerEventPayload> | BaseGesture<PinchGestureHandlerEventPayload> | BaseGesture<ForceTouchGestureHandlerEventPayload> | BaseGesture<NativeViewGestureHandlerPayload> | BaseGesture<import("../handlers/GestureHandlerEventPayload").HoverGestureHandlerEventPayload>;
30
30
  export {};
@@ -2,7 +2,9 @@
2
2
  import { AdaptedEvent, Config } from '../interfaces';
3
3
  import GestureHandler from './GestureHandler';
4
4
  export default class HoverGestureHandler extends GestureHandler {
5
+ private stylusData;
5
6
  init(ref: number, propsRef: React.RefObject<unknown>): void;
7
+ protected transformNativeEvent(): Record<string, unknown>;
6
8
  updateGestureConfig({ enabled, ...props }: Config): void;
7
9
  protected onPointerMoveOver(event: AdaptedEvent): void;
8
10
  protected onPointerMoveOut(event: AdaptedEvent): void;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { AdaptedEvent, Config } from '../interfaces';
2
+ import { AdaptedEvent, Config, StylusData } from '../interfaces';
3
3
  import GestureHandler from './GestureHandler';
4
4
  export default class PanGestureHandler extends GestureHandler {
5
5
  private readonly customActivationProperties;
@@ -25,6 +25,7 @@ export default class PanGestureHandler extends GestureHandler {
25
25
  private offsetY;
26
26
  private lastX;
27
27
  private lastY;
28
+ private stylusData;
28
29
  private activateAfterLongPress;
29
30
  private activationTimeout;
30
31
  init(ref: number, propsRef: React.RefObject<unknown>): void;
@@ -35,6 +36,7 @@ export default class PanGestureHandler extends GestureHandler {
35
36
  translationY: number;
36
37
  velocityX: number;
37
38
  velocityY: number;
39
+ stylusData: StylusData | undefined;
38
40
  };
39
41
  private getTranslationX;
40
42
  private getTranslationY;
@@ -102,6 +102,13 @@ export interface PropsRef {
102
102
  onGestureHandlerEvent: () => void;
103
103
  onGestureHandlerStateChange: () => void;
104
104
  }
105
+ export interface StylusData {
106
+ tiltX: number;
107
+ tiltY: number;
108
+ azimuthAngle: number;
109
+ altitudeAngle: number;
110
+ pressure: number;
111
+ }
105
112
  export interface AdaptedEvent {
106
113
  x: number;
107
114
  y: number;
@@ -112,9 +119,7 @@ export interface AdaptedEvent {
112
119
  pointerType: PointerType;
113
120
  time: number;
114
121
  button?: MouseButton;
115
- allTouches?: TouchList;
116
- changedTouches?: TouchList;
117
- touchEventType?: TouchEventType;
122
+ stylusData?: StylusData;
118
123
  }
119
124
  export declare enum EventTypes {
120
125
  DOWN = 0,
@@ -1,4 +1,4 @@
1
- import { AdaptedEvent, EventTypes, TouchEventType } from '../interfaces';
1
+ import { AdaptedEvent, EventTypes } from '../interfaces';
2
2
  type PointerEventCallback = (event: AdaptedEvent) => void;
3
3
  export default abstract class EventManager<T> {
4
4
  protected readonly view: T;
@@ -7,7 +7,7 @@ export default abstract class EventManager<T> {
7
7
  constructor(view: T);
8
8
  abstract registerListeners(): void;
9
9
  abstract unregisterListeners(): void;
10
- protected abstract mapEvent(event: Event, eventType: EventTypes, index?: number, touchEventType?: TouchEventType): AdaptedEvent;
10
+ protected abstract mapEvent(event: Event, eventType: EventTypes): AdaptedEvent;
11
11
  protected onPointerDown(_event: AdaptedEvent): void;
12
12
  protected onPointerAdd(_event: AdaptedEvent): void;
13
13
  protected onPointerUp(_event: AdaptedEvent): void;
@@ -1,5 +1,5 @@
1
1
  import { PointerType } from '../PointerType';
2
- import { Point } from './interfaces';
2
+ import type { Point, StylusData } from './interfaces';
3
3
  export declare function isPointerInBounds(view: HTMLElement, { x, y }: Point): boolean;
4
4
  export declare const PointerTypeMapping: Map<string, PointerType>;
5
5
  export declare const degToRad: (degrees: number) => number;
@@ -8,3 +8,4 @@ export declare function calculateViewScale(view: HTMLElement): {
8
8
  scaleX: number;
9
9
  scaleY: number;
10
10
  };
11
+ export declare function tryExtractStylusData(event: PointerEvent): StylusData | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gesture-handler",
3
- "version": "2.19.0",
3
+ "version": "2.20.0",
4
4
  "description": "Experimental implementation of a new declarative API for gesture handling in react-native",
5
5
  "scripts": {
6
6
  "prepare": "bob build && husky install",
@@ -120,12 +120,13 @@ class InnerBaseButton extends React.Component<BaseButtonWithRefProps> {
120
120
  };
121
121
 
122
122
  render() {
123
- const { rippleColor, ...rest } = this.props;
123
+ const { rippleColor, style, ...rest } = this.props;
124
124
 
125
125
  return (
126
126
  <RawButton
127
127
  ref={this.props.innerRef}
128
128
  rippleColor={processColor(rippleColor)}
129
+ style={[style, Platform.OS === 'ios' && { cursor: undefined }]}
129
130
  {...rest}
130
131
  onGestureEvent={this.onGestureEvent}
131
132
  onHandlerStateChange={this.onHandlerStateChange}
@@ -138,7 +138,7 @@ export const FlatList = React.forwardRef((props, ref) => {
138
138
  );
139
139
  }) as <ItemT = any>(
140
140
  props: PropsWithChildren<
141
- RNFlatListProps<ItemT> &
141
+ Omit<RNFlatListProps<ItemT>, 'renderScrollComponent'> &
142
142
  RefAttributes<FlatList<ItemT>> &
143
143
  NativeViewGestureHandlerProps
144
144
  >,
@@ -9,7 +9,6 @@ import {
9
9
  View,
10
10
  ViewStyle,
11
11
  processColor,
12
- StyleSheet,
13
12
  } from 'react-native';
14
13
  import NativeButton from '../GestureHandlerButton';
15
14
  import {
@@ -18,7 +17,6 @@ import {
18
17
  isTouchWithinInset,
19
18
  gestureTouchToPressableEvent,
20
19
  addInsets,
21
- splitStyles,
22
20
  } from './utils';
23
21
  import { PressabilityDebugView } from '../../handlers/PressabilityDebugView';
24
22
  import { GestureTouchEvent } from '../../handlers/gestureHandlerCommon';
@@ -386,33 +384,22 @@ export default function Pressable(props: PressableProps) {
386
384
  ? children({ pressed: pressedState })
387
385
  : children;
388
386
 
389
- const flattenedStyles = StyleSheet.flatten(styleProp ?? {});
390
-
391
- const [innerStyles, outerStyles] = splitStyles(flattenedStyles);
392
-
393
387
  return (
394
- <View {...remainingProps} style={outerStyles}>
395
- <GestureDetector gesture={gesture}>
396
- <NativeButton
397
- ref={pressableRef}
398
- hitSlop={appliedHitSlop}
399
- enabled={isPressableEnabled}
400
- touchSoundDisabled={android_disableSound ?? undefined}
401
- rippleColor={processColor(
402
- android_ripple?.color ?? defaultRippleColor
403
- )}
404
- rippleRadius={android_ripple?.radius ?? undefined}
405
- style={[
406
- { width: '100%', height: '100%' },
407
- pointerStyle,
408
- innerStyles,
409
- ]}>
410
- {childrenProp}
411
- {__DEV__ ? (
412
- <PressabilityDebugView color="red" hitSlop={normalizedHitSlop} />
413
- ) : null}
414
- </NativeButton>
415
- </GestureDetector>
416
- </View>
388
+ <GestureDetector gesture={gesture}>
389
+ <NativeButton
390
+ {...remainingProps}
391
+ ref={pressableRef}
392
+ hitSlop={appliedHitSlop}
393
+ enabled={isPressableEnabled}
394
+ touchSoundDisabled={android_disableSound ?? undefined}
395
+ rippleColor={processColor(android_ripple?.color ?? defaultRippleColor)}
396
+ rippleRadius={android_ripple?.radius ?? undefined}
397
+ style={[pointerStyle, styleProp]}>
398
+ {childrenProp}
399
+ {__DEV__ ? (
400
+ <PressabilityDebugView color="red" hitSlop={normalizedHitSlop} />
401
+ ) : null}
402
+ </NativeButton>
403
+ </GestureDetector>
417
404
  );
418
405
  }
@@ -1,11 +1,13 @@
1
- import { Insets, ViewStyle } from 'react-native';
2
- import { LongPressGestureHandlerEventPayload } from '../../handlers/GestureHandlerEventPayload';
1
+ import { Insets } from 'react-native';
2
+ import {
3
+ HoverGestureHandlerEventPayload,
4
+ LongPressGestureHandlerEventPayload,
5
+ } from '../../handlers/GestureHandlerEventPayload';
3
6
  import {
4
7
  TouchData,
5
8
  GestureStateChangeEvent,
6
9
  GestureTouchEvent,
7
10
  } from '../../handlers/gestureHandlerCommon';
8
- import { HoverGestureHandlerEventPayload } from '../../handlers/gestures/hoverGesture';
9
11
  import { InnerPressableEvent, PressableEvent } from './PressableProps';
10
12
 
11
13
  const numberAsInset = (value: number): Insets => ({
@@ -125,56 +127,10 @@ const gestureTouchToPressableEvent = (
125
127
  };
126
128
  };
127
129
 
128
- type StylePropKeys = (keyof ViewStyle)[];
129
-
130
- // Source:
131
- // - From ViewStyle extracted FlexStyle sub-interface which contains all of the box-model manipulating props.
132
- // - From FlexStyle handpicked those styles, which act on the inner part of the box-model.
133
- const innerStyleKeys = new Set([
134
- 'alignContent',
135
- 'alignItems',
136
- 'flexBasis',
137
- 'flexDirection',
138
- 'flexWrap',
139
- 'rowGap',
140
- 'gap',
141
- 'columnGap',
142
- 'justifyContent',
143
- 'overflow',
144
- 'padding',
145
- 'paddingBottom',
146
- 'paddingEnd',
147
- 'paddingHorizontal',
148
- 'paddingLeft',
149
- 'paddingRight',
150
- 'paddingStart',
151
- 'paddingTop',
152
- 'paddingVertical',
153
- 'start',
154
- 'end',
155
- 'direction', // iOS only
156
- ] as StylePropKeys);
157
-
158
- const splitStyles = (from: ViewStyle): [ViewStyle, ViewStyle] => {
159
- const outerStyles: Record<string, unknown> = {};
160
- const innerStyles: Record<string, unknown> = {};
161
-
162
- for (const key in from) {
163
- if (innerStyleKeys.has(key as keyof ViewStyle)) {
164
- innerStyles[key] = from[key as keyof ViewStyle];
165
- } else {
166
- outerStyles[key] = from[key as keyof ViewStyle];
167
- }
168
- }
169
-
170
- return [innerStyles, outerStyles];
171
- };
172
-
173
130
  export {
174
131
  numberAsInset,
175
132
  addInsets,
176
133
  isTouchWithinInset,
177
134
  gestureToPressableEvent,
178
135
  gestureTouchToPressableEvent,
179
- splitStyles,
180
136
  };