react-native-gesture-handler 2.13.3 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- package/RNGestureHandler.podspec +19 -25
- package/android/build.gradle +3 -2
- package/android/gradle.properties +2 -2
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +36 -72
- package/android/src/main/java/com/swmansion/gesturehandler/react/Extensions.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +13 -9
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEvent.kt +12 -14
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerInteractionManager.kt +8 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +34 -88
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt +18 -12
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/FlingGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/GestureHandlerEventDataBuilder.kt +22 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/HoverGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/LongPressGestureHandlerEventDataBuilder.kt +33 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/ManualGestureHandlerEventDataBuilder.kt +5 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/NativeGestureHandlerEventDataBuilder.kt +18 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PanGestureHandlerEventDataBuilder.kt +42 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/PinchGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/RotationGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/TapGestureHandlerEventDataBuilder.kt +30 -0
- package/android/src/main/jni/CMakeLists.txt +14 -2
- package/ios/Handlers/RNHoverHandler.m +15 -14
- package/ios/RNGestureHandler.m +11 -0
- package/ios/RNGestureHandlerButtonComponentView.mm +2 -0
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/commonjs/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/commonjs/getReactNativeVersion.js +22 -0
- package/lib/commonjs/getReactNativeVersion.js.map +1 -0
- package/lib/commonjs/getReactNativeVersion.web.js +11 -0
- package/lib/commonjs/getReactNativeVersion.web.js.map +1 -0
- package/lib/commonjs/handlers/gestureHandlerCommon.js +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +13 -3
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +8 -0
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/utils.js +0 -13
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +4 -15
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/InteractionManager.js +27 -29
- package/lib/commonjs/web/tools/InteractionManager.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +11 -3
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js +1 -1
- package/lib/module/components/touchables/TouchableNativeFeedback.android.js.map +1 -1
- package/lib/module/getReactNativeVersion.js +10 -0
- package/lib/module/getReactNativeVersion.js.map +1 -0
- package/lib/module/getReactNativeVersion.web.js +4 -0
- package/lib/module/getReactNativeVersion.web.js.map +1 -0
- package/lib/module/handlers/gestureHandlerCommon.js +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +12 -3
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +8 -0
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/utils.js +0 -6
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +4 -15
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/InteractionManager.js +27 -29
- package/lib/module/web/tools/InteractionManager.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +11 -3
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/typescript/ActionType.d.ts +1 -1
- package/lib/typescript/Directions.d.ts +1 -1
- package/lib/typescript/PlatformConstants.d.ts +1 -1
- package/lib/typescript/RNGestureHandlerModule.d.ts +1 -1
- package/lib/typescript/State.d.ts +1 -1
- package/lib/typescript/TouchEventType.d.ts +1 -1
- package/lib/typescript/components/DrawerLayout.d.ts +9 -9
- package/lib/typescript/components/GestureButtons.d.ts +3 -3
- package/lib/typescript/components/GestureComponents.d.ts +6 -6
- package/lib/typescript/components/GestureComponents.web.d.ts +1 -1
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +2 -1
- package/lib/typescript/components/GestureHandlerRootView.d.ts +2 -1
- package/lib/typescript/components/GestureHandlerRootView.web.d.ts +2 -1
- package/lib/typescript/components/Swipeable.d.ts +4 -4
- package/lib/typescript/components/touchables/GenericTouchable.d.ts +4 -3
- package/lib/typescript/components/touchables/TouchableHighlight.d.ts +4 -3
- package/lib/typescript/components/touchables/TouchableNativeFeedback.android.d.ts +7 -6
- package/lib/typescript/components/touchables/TouchableOpacity.d.ts +3 -2
- package/lib/typescript/components/touchables/TouchableWithoutFeedback.d.ts +1 -1
- package/lib/typescript/getReactNativeVersion.d.ts +4 -0
- package/lib/typescript/getReactNativeVersion.web.d.ts +1 -0
- package/lib/typescript/handlers/FlingGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/NativeViewGestureHandler.d.ts +3 -3
- package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/PinchGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/RotationGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/TapGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/createHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +11 -10
- package/lib/typescript/handlers/gestureHandlerTypesCompat.d.ts +32 -32
- package/lib/typescript/handlers/gestures/GestureDetector.d.ts +2 -2
- package/lib/typescript/handlers/gestures/flingGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/gesture.d.ts +7 -5
- package/lib/typescript/handlers/gestures/gestureComposition.d.ts +4 -4
- package/lib/typescript/handlers/gestures/hoverGesture.d.ts +3 -3
- package/lib/typescript/handlers/gestures/longPressGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/nativeGesture.d.ts +1 -1
- package/lib/typescript/handlers/gestures/panGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +2 -2
- package/lib/typescript/handlers/gestures/tapGesture.d.ts +1 -1
- package/lib/typescript/jestUtils/jestUtils.d.ts +6 -6
- package/lib/typescript/typeUtils.d.ts +1 -1
- package/lib/typescript/utils.d.ts +1 -5
- package/lib/typescript/web/interfaces.d.ts +4 -3
- package/lib/typescript/web/tools/GestureHandlerOrchestrator.d.ts +0 -1
- package/lib/typescript/web/tools/InteractionManager.d.ts +2 -1
- package/lib/typescript/web_hammer/GestureHandler.d.ts +2 -2
- package/package.json +7 -7
- package/src/components/touchables/TouchableNativeFeedback.android.tsx +2 -1
- package/src/getReactNativeVersion.ts +11 -0
- package/src/getReactNativeVersion.web.ts +3 -0
- package/src/handlers/gestureHandlerCommon.ts +6 -1
- package/src/handlers/gestures/GestureDetector.tsx +9 -6
- package/src/handlers/gestures/gesture.ts +9 -1
- package/src/utils.ts +0 -8
- package/src/web/handlers/GestureHandler.ts +1 -1
- package/src/web/interfaces.ts +1 -0
- package/src/web/tools/GestureHandlerOrchestrator.ts +4 -13
- package/src/web/tools/InteractionManager.ts +37 -30
- package/src/web/tools/PointerEventManager.ts +12 -3
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerEventDataExtractor.kt +0 -8
- /package/android/{src/fabric → fabric/src/main}/java/com/swmansion/gesturehandler/RNGestureHandlerComponentsRegistry.java +0 -0
- /package/android/{src/fabric → fabric/src/main}/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerDelegate.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/facebook/react/viewmanagers/RNGestureHandlerRootViewManagerInterface.java +0 -0
- /package/android/{src/paper → paper/src/main}/java/com/swmansion/gesturehandler/ReactContextExtensions.kt +0 -0
@@ -30,6 +30,16 @@ import com.swmansion.gesturehandler.core.PinchGestureHandler
|
|
30
30
|
import com.swmansion.gesturehandler.core.RotationGestureHandler
|
31
31
|
import com.swmansion.gesturehandler.core.TapGestureHandler
|
32
32
|
import com.swmansion.gesturehandler.dispatchEvent
|
33
|
+
import com.swmansion.gesturehandler.react.eventbuilders.FlingGestureHandlerEventDataBuilder
|
34
|
+
import com.swmansion.gesturehandler.react.eventbuilders.GestureHandlerEventDataBuilder
|
35
|
+
import com.swmansion.gesturehandler.react.eventbuilders.HoverGestureHandlerEventDataBuilder
|
36
|
+
import com.swmansion.gesturehandler.react.eventbuilders.LongPressGestureHandlerEventDataBuilder
|
37
|
+
import com.swmansion.gesturehandler.react.eventbuilders.ManualGestureHandlerEventDataBuilder
|
38
|
+
import com.swmansion.gesturehandler.react.eventbuilders.NativeGestureHandlerEventDataBuilder
|
39
|
+
import com.swmansion.gesturehandler.react.eventbuilders.PanGestureHandlerEventDataBuilder
|
40
|
+
import com.swmansion.gesturehandler.react.eventbuilders.PinchGestureHandlerEventDataBuilder
|
41
|
+
import com.swmansion.gesturehandler.react.eventbuilders.RotationGestureHandlerEventDataBuilder
|
42
|
+
import com.swmansion.gesturehandler.react.eventbuilders.TapGestureHandlerEventDataBuilder
|
33
43
|
|
34
44
|
// NativeModule.onCatalystInstanceDestroy() was deprecated in favor of NativeModule.invalidate()
|
35
45
|
// ref: https://github.com/facebook/react-native/commit/18c8417290823e67e211bde241ae9dde27b72f17
|
@@ -40,7 +50,7 @@ import com.swmansion.gesturehandler.dispatchEvent
|
|
40
50
|
@ReactModule(name = RNGestureHandlerModule.MODULE_NAME)
|
41
51
|
class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
42
52
|
ReactContextBaseJavaModule(reactContext), GestureHandlerStateManager {
|
43
|
-
private abstract class HandlerFactory<T : GestureHandler<T>>
|
53
|
+
private abstract class HandlerFactory<T : GestureHandler<T>> {
|
44
54
|
abstract val type: Class<T>
|
45
55
|
abstract val name: String
|
46
56
|
abstract fun create(context: Context?): T
|
@@ -63,9 +73,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
63
73
|
}
|
64
74
|
}
|
65
75
|
|
66
|
-
|
67
|
-
eventData.putDouble("numberOfPointers", handler.numberOfPointers.toDouble())
|
68
|
-
}
|
76
|
+
abstract fun createEventBuilder(handler: T): GestureHandlerEventDataBuilder<T>
|
69
77
|
}
|
70
78
|
|
71
79
|
private class NativeViewGestureHandlerFactory : HandlerFactory<NativeViewGestureHandler>() {
|
@@ -88,10 +96,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
88
96
|
}
|
89
97
|
}
|
90
98
|
|
91
|
-
override fun
|
92
|
-
super.extractEventData(handler, eventData)
|
93
|
-
eventData.putBoolean("pointerInside", handler.isWithinBounds)
|
94
|
-
}
|
99
|
+
override fun createEventBuilder(handler: NativeViewGestureHandler) = NativeGestureHandlerEventDataBuilder(handler)
|
95
100
|
}
|
96
101
|
|
97
102
|
private class TapGestureHandlerFactory : HandlerFactory<TapGestureHandler>() {
|
@@ -127,15 +132,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
127
132
|
}
|
128
133
|
}
|
129
134
|
|
130
|
-
override fun
|
131
|
-
super.extractEventData(handler, eventData)
|
132
|
-
with(eventData) {
|
133
|
-
putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
|
134
|
-
putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
|
135
|
-
putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
|
136
|
-
putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
|
137
|
-
}
|
138
|
-
}
|
135
|
+
override fun createEventBuilder(handler: TapGestureHandler) = TapGestureHandlerEventDataBuilder(handler)
|
139
136
|
}
|
140
137
|
|
141
138
|
private class LongPressGestureHandlerFactory : HandlerFactory<LongPressGestureHandler>() {
|
@@ -156,16 +153,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
156
153
|
}
|
157
154
|
}
|
158
155
|
|
159
|
-
override fun
|
160
|
-
super.extractEventData(handler, eventData)
|
161
|
-
with(eventData) {
|
162
|
-
putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
|
163
|
-
putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
|
164
|
-
putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
|
165
|
-
putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
|
166
|
-
putInt("duration", handler.duration)
|
167
|
-
}
|
168
|
-
}
|
156
|
+
override fun createEventBuilder(handler: LongPressGestureHandler) = LongPressGestureHandlerEventDataBuilder(handler)
|
169
157
|
}
|
170
158
|
|
171
159
|
private class PanGestureHandlerFactory : HandlerFactory<PanGestureHandler>() {
|
@@ -247,19 +235,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
247
235
|
}
|
248
236
|
}
|
249
237
|
|
250
|
-
override fun
|
251
|
-
super.extractEventData(handler, eventData)
|
252
|
-
with(eventData) {
|
253
|
-
putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
|
254
|
-
putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
|
255
|
-
putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
|
256
|
-
putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
|
257
|
-
putDouble("translationX", PixelUtil.toDIPFromPixel(handler.translationX).toDouble())
|
258
|
-
putDouble("translationY", PixelUtil.toDIPFromPixel(handler.translationY).toDouble())
|
259
|
-
putDouble("velocityX", PixelUtil.toDIPFromPixel(handler.velocityX).toDouble())
|
260
|
-
putDouble("velocityY", PixelUtil.toDIPFromPixel(handler.velocityY).toDouble())
|
261
|
-
}
|
262
|
-
}
|
238
|
+
override fun createEventBuilder(handler: PanGestureHandler) = PanGestureHandlerEventDataBuilder(handler)
|
263
239
|
}
|
264
240
|
|
265
241
|
private class PinchGestureHandlerFactory : HandlerFactory<PinchGestureHandler>() {
|
@@ -270,15 +246,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
270
246
|
return PinchGestureHandler()
|
271
247
|
}
|
272
248
|
|
273
|
-
override fun
|
274
|
-
super.extractEventData(handler, eventData)
|
275
|
-
with(eventData) {
|
276
|
-
putDouble("scale", handler.scale)
|
277
|
-
putDouble("focalX", PixelUtil.toDIPFromPixel(handler.focalPointX).toDouble())
|
278
|
-
putDouble("focalY", PixelUtil.toDIPFromPixel(handler.focalPointY).toDouble())
|
279
|
-
putDouble("velocity", handler.velocity)
|
280
|
-
}
|
281
|
-
}
|
249
|
+
override fun createEventBuilder(handler: PinchGestureHandler) = PinchGestureHandlerEventDataBuilder(handler)
|
282
250
|
}
|
283
251
|
|
284
252
|
private class FlingGestureHandlerFactory : HandlerFactory<FlingGestureHandler>() {
|
@@ -299,15 +267,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
299
267
|
}
|
300
268
|
}
|
301
269
|
|
302
|
-
override fun
|
303
|
-
super.extractEventData(handler, eventData)
|
304
|
-
with(eventData) {
|
305
|
-
putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
|
306
|
-
putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
|
307
|
-
putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
|
308
|
-
putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
|
309
|
-
}
|
310
|
-
}
|
270
|
+
override fun createEventBuilder(handler: FlingGestureHandler) = FlingGestureHandlerEventDataBuilder(handler)
|
311
271
|
}
|
312
272
|
|
313
273
|
private class RotationGestureHandlerFactory : HandlerFactory<RotationGestureHandler>() {
|
@@ -318,15 +278,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
318
278
|
return RotationGestureHandler()
|
319
279
|
}
|
320
280
|
|
321
|
-
override fun
|
322
|
-
super.extractEventData(handler, eventData)
|
323
|
-
with(eventData) {
|
324
|
-
putDouble("rotation", handler.rotation)
|
325
|
-
putDouble("anchorX", PixelUtil.toDIPFromPixel(handler.anchorX).toDouble())
|
326
|
-
putDouble("anchorY", PixelUtil.toDIPFromPixel(handler.anchorY).toDouble())
|
327
|
-
putDouble("velocity", handler.velocity)
|
328
|
-
}
|
329
|
-
}
|
281
|
+
override fun createEventBuilder(handler: RotationGestureHandler) = RotationGestureHandlerEventDataBuilder(handler)
|
330
282
|
}
|
331
283
|
|
332
284
|
private class ManualGestureHandlerFactory : HandlerFactory<ManualGestureHandler>() {
|
@@ -336,6 +288,8 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
336
288
|
override fun create(context: Context?): ManualGestureHandler {
|
337
289
|
return ManualGestureHandler()
|
338
290
|
}
|
291
|
+
|
292
|
+
override fun createEventBuilder(handler: ManualGestureHandler) = ManualGestureHandlerEventDataBuilder(handler)
|
339
293
|
}
|
340
294
|
|
341
295
|
private class HoverGestureHandlerFactory : HandlerFactory<HoverGestureHandler>() {
|
@@ -346,15 +300,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
346
300
|
return HoverGestureHandler()
|
347
301
|
}
|
348
302
|
|
349
|
-
override fun
|
350
|
-
super.extractEventData(handler, eventData)
|
351
|
-
with(eventData) {
|
352
|
-
putDouble("x", PixelUtil.toDIPFromPixel(handler.lastRelativePositionX).toDouble())
|
353
|
-
putDouble("y", PixelUtil.toDIPFromPixel(handler.lastRelativePositionY).toDouble())
|
354
|
-
putDouble("absoluteX", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowX).toDouble())
|
355
|
-
putDouble("absoluteY", PixelUtil.toDIPFromPixel(handler.lastPositionInWindowY).toDouble())
|
356
|
-
}
|
357
|
-
}
|
303
|
+
override fun createEventBuilder(handler: HoverGestureHandler) = HoverGestureHandlerEventDataBuilder(handler)
|
358
304
|
}
|
359
305
|
|
360
306
|
private val eventListener = object : OnTouchEventListener {
|
@@ -466,7 +412,7 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
466
412
|
fun install(): Boolean {
|
467
413
|
return try {
|
468
414
|
SoLoader.loadLibrary("gesturehandler")
|
469
|
-
val jsContext = reactApplicationContext.javaScriptContextHolder
|
415
|
+
val jsContext = reactApplicationContext.javaScriptContextHolder!!
|
470
416
|
decorateRuntime(jsContext.get())
|
471
417
|
true
|
472
418
|
} catch (exception: Exception) {
|
@@ -551,32 +497,32 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
551
497
|
return
|
552
498
|
}
|
553
499
|
if (handler.state == GestureHandler.STATE_ACTIVE) {
|
554
|
-
val handlerFactory = findFactoryForHandler(handler)
|
500
|
+
val handlerFactory = findFactoryForHandler(handler) ?: return
|
555
501
|
|
556
502
|
if (handler.actionType == GestureHandler.ACTION_TYPE_REANIMATED_WORKLET) {
|
557
503
|
// Reanimated worklet
|
558
|
-
val event = RNGestureHandlerEvent.obtain(handler, handlerFactory)
|
504
|
+
val event = RNGestureHandlerEvent.obtain(handler, handlerFactory.createEventBuilder(handler))
|
559
505
|
sendEventForReanimated(event)
|
560
506
|
} else if (handler.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT) {
|
561
507
|
// Animated with useNativeDriver: true
|
562
508
|
val event = RNGestureHandlerEvent.obtain(
|
563
509
|
handler,
|
564
|
-
handlerFactory,
|
510
|
+
handlerFactory.createEventBuilder(handler),
|
565
511
|
useTopPrefixedName = BuildConfig.REACT_NATIVE_MINOR_VERSION >= 71
|
566
512
|
)
|
567
513
|
sendEventForNativeAnimatedEvent(event)
|
568
514
|
} else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API) {
|
569
515
|
// JS function, Animated.event with useNativeDriver: false using old API
|
570
516
|
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
571
|
-
val data = RNGestureHandlerEvent.createEventData(handler
|
517
|
+
val data = RNGestureHandlerEvent.createEventData(handlerFactory.createEventBuilder(handler))
|
572
518
|
sendEventForDeviceEvent(RNGestureHandlerEvent.EVENT_NAME, data)
|
573
519
|
} else {
|
574
|
-
val event = RNGestureHandlerEvent.obtain(handler, handlerFactory)
|
520
|
+
val event = RNGestureHandlerEvent.obtain(handler, handlerFactory.createEventBuilder(handler))
|
575
521
|
sendEventForDirectEvent(event)
|
576
522
|
}
|
577
523
|
} else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_NEW_API) {
|
578
524
|
// JS function, Animated.event with useNativeDriver: false using new API
|
579
|
-
val data = RNGestureHandlerEvent.createEventData(handler
|
525
|
+
val data = RNGestureHandlerEvent.createEventData(handlerFactory.createEventBuilder(handler))
|
580
526
|
sendEventForDeviceEvent(RNGestureHandlerEvent.EVENT_NAME, data)
|
581
527
|
}
|
582
528
|
}
|
@@ -589,26 +535,26 @@ class RNGestureHandlerModule(reactContext: ReactApplicationContext?) :
|
|
589
535
|
// root containers use negative tags, we don't need to dispatch events for them to the JS
|
590
536
|
return
|
591
537
|
}
|
592
|
-
val handlerFactory = findFactoryForHandler(handler)
|
538
|
+
val handlerFactory = findFactoryForHandler(handler) ?: return
|
593
539
|
|
594
540
|
if (handler.actionType == GestureHandler.ACTION_TYPE_REANIMATED_WORKLET) {
|
595
541
|
// Reanimated worklet
|
596
|
-
val event = RNGestureHandlerStateChangeEvent.obtain(handler, newState, oldState, handlerFactory)
|
542
|
+
val event = RNGestureHandlerStateChangeEvent.obtain(handler, newState, oldState, handlerFactory.createEventBuilder(handler))
|
597
543
|
sendEventForReanimated(event)
|
598
544
|
} else if (handler.actionType == GestureHandler.ACTION_TYPE_NATIVE_ANIMATED_EVENT ||
|
599
545
|
handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_OLD_API
|
600
546
|
) {
|
601
547
|
// JS function or Animated.event with useNativeDriver: false with old API
|
602
548
|
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
603
|
-
val data = RNGestureHandlerStateChangeEvent.createEventData(handler,
|
549
|
+
val data = RNGestureHandlerStateChangeEvent.createEventData(handlerFactory.createEventBuilder(handler), newState, oldState)
|
604
550
|
sendEventForDeviceEvent(RNGestureHandlerStateChangeEvent.EVENT_NAME, data)
|
605
551
|
} else {
|
606
|
-
val event = RNGestureHandlerStateChangeEvent.obtain(handler, newState, oldState, handlerFactory)
|
552
|
+
val event = RNGestureHandlerStateChangeEvent.obtain(handler, newState, oldState, handlerFactory.createEventBuilder(handler))
|
607
553
|
sendEventForDirectEvent(event)
|
608
554
|
}
|
609
555
|
} else if (handler.actionType == GestureHandler.ACTION_TYPE_JS_FUNCTION_NEW_API) {
|
610
556
|
// JS function or Animated.event with useNativeDriver: false with new API
|
611
|
-
val data = RNGestureHandlerStateChangeEvent.createEventData(handler,
|
557
|
+
val data = RNGestureHandlerStateChangeEvent.createEventData(handlerFactory.createEventBuilder(handler), newState, oldState)
|
612
558
|
sendEventForDeviceEvent(RNGestureHandlerStateChangeEvent.EVENT_NAME, data)
|
613
559
|
}
|
614
560
|
}
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootView.kt
CHANGED
@@ -40,7 +40,7 @@ class RNGestureHandlerRootView(context: Context?) : ReactViewGroup(context) {
|
|
40
40
|
override fun dispatchGenericMotionEvent(event: MotionEvent) =
|
41
41
|
if (_enabled && rootHelper!!.dispatchTouchEvent(event)) {
|
42
42
|
true
|
43
|
-
} else super.
|
43
|
+
} else super.dispatchGenericMotionEvent(event)
|
44
44
|
|
45
45
|
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
|
46
46
|
if (_enabled) {
|
package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerStateChangeEvent.kt
CHANGED
@@ -12,21 +12,29 @@ import com.facebook.react.bridge.WritableMap
|
|
12
12
|
import com.facebook.react.uimanager.events.Event
|
13
13
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
14
14
|
import com.swmansion.gesturehandler.core.GestureHandler
|
15
|
+
import com.swmansion.gesturehandler.react.eventbuilders.GestureHandlerEventDataBuilder
|
15
16
|
|
16
17
|
class RNGestureHandlerStateChangeEvent private constructor() : Event<RNGestureHandlerStateChangeEvent>() {
|
17
|
-
private var
|
18
|
+
private var dataBuilder: GestureHandlerEventDataBuilder<*>? = null
|
19
|
+
private var newState: Int = GestureHandler.STATE_UNDETERMINED
|
20
|
+
private var oldState: Int = GestureHandler.STATE_UNDETERMINED
|
21
|
+
|
18
22
|
private fun <T : GestureHandler<T>> init(
|
19
23
|
handler: T,
|
20
24
|
newState: Int,
|
21
25
|
oldState: Int,
|
22
|
-
|
26
|
+
dataBuilder: GestureHandlerEventDataBuilder<T>,
|
23
27
|
) {
|
24
28
|
super.init(handler.view!!.id)
|
25
|
-
|
29
|
+
this.dataBuilder = dataBuilder
|
30
|
+
this.newState = newState
|
31
|
+
this.oldState = oldState
|
26
32
|
}
|
27
33
|
|
28
34
|
override fun onDispose() {
|
29
|
-
|
35
|
+
dataBuilder = null
|
36
|
+
newState = GestureHandler.STATE_UNDETERMINED
|
37
|
+
oldState = GestureHandler.STATE_UNDETERMINED
|
30
38
|
EVENTS_POOL.release(this)
|
31
39
|
}
|
32
40
|
|
@@ -39,7 +47,7 @@ class RNGestureHandlerStateChangeEvent private constructor() : Event<RNGestureHa
|
|
39
47
|
override fun getCoalescingKey(): Short = 0
|
40
48
|
|
41
49
|
override fun dispatch(rctEventEmitter: RCTEventEmitter) {
|
42
|
-
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME,
|
50
|
+
rctEventEmitter.receiveEvent(viewTag, EVENT_NAME, createEventData(dataBuilder!!, newState, oldState))
|
43
51
|
}
|
44
52
|
|
45
53
|
companion object {
|
@@ -51,20 +59,18 @@ class RNGestureHandlerStateChangeEvent private constructor() : Event<RNGestureHa
|
|
51
59
|
handler: T,
|
52
60
|
newState: Int,
|
53
61
|
oldState: Int,
|
54
|
-
|
62
|
+
dataBuilder: GestureHandlerEventDataBuilder<T>,
|
55
63
|
): RNGestureHandlerStateChangeEvent =
|
56
64
|
(EVENTS_POOL.acquire() ?: RNGestureHandlerStateChangeEvent()).apply {
|
57
|
-
init(handler, newState, oldState,
|
65
|
+
init(handler, newState, oldState, dataBuilder)
|
58
66
|
}
|
59
67
|
|
60
|
-
fun
|
61
|
-
|
62
|
-
dataExtractor: RNGestureHandlerEventDataExtractor<T>?,
|
68
|
+
fun createEventData(
|
69
|
+
dataBuilder: GestureHandlerEventDataBuilder<*>,
|
63
70
|
newState: Int,
|
64
71
|
oldState: Int,
|
65
72
|
): WritableMap = Arguments.createMap().apply {
|
66
|
-
|
67
|
-
putInt("handlerTag", handler.tag)
|
73
|
+
dataBuilder.buildEventData(this)
|
68
74
|
putInt("state", newState)
|
69
75
|
putInt("oldState", oldState)
|
70
76
|
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.FlingGestureHandler
|
6
|
+
|
7
|
+
class FlingGestureHandlerEventDataBuilder(handler: FlingGestureHandler) : GestureHandlerEventDataBuilder<FlingGestureHandler>(handler) {
|
8
|
+
private val x: Float
|
9
|
+
private val y: Float
|
10
|
+
private val absoluteX: Float
|
11
|
+
private val absoluteY: Float
|
12
|
+
|
13
|
+
init {
|
14
|
+
x = handler.lastRelativePositionX
|
15
|
+
y = handler.lastRelativePositionY
|
16
|
+
absoluteX = handler.lastPositionInWindowX
|
17
|
+
absoluteY = handler.lastPositionInWindowY
|
18
|
+
}
|
19
|
+
|
20
|
+
override fun buildEventData(eventData: WritableMap) {
|
21
|
+
super.buildEventData(eventData)
|
22
|
+
|
23
|
+
with(eventData) {
|
24
|
+
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
|
25
|
+
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
|
26
|
+
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
|
27
|
+
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.swmansion.gesturehandler.core.GestureHandler
|
5
|
+
|
6
|
+
abstract class GestureHandlerEventDataBuilder<T : GestureHandler<T>>(handler: T) {
|
7
|
+
private val numberOfPointers: Int
|
8
|
+
private val handlerTag: Int
|
9
|
+
private val state: Int
|
10
|
+
|
11
|
+
init {
|
12
|
+
numberOfPointers = handler.numberOfPointers
|
13
|
+
handlerTag = handler.tag
|
14
|
+
state = handler.state
|
15
|
+
}
|
16
|
+
|
17
|
+
open fun buildEventData(eventData: WritableMap) {
|
18
|
+
eventData.putInt("numberOfPointers", numberOfPointers)
|
19
|
+
eventData.putInt("handlerTag", handlerTag)
|
20
|
+
eventData.putInt("state", state)
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.HoverGestureHandler
|
6
|
+
|
7
|
+
class HoverGestureHandlerEventDataBuilder(handler: HoverGestureHandler) : GestureHandlerEventDataBuilder<HoverGestureHandler>(handler) {
|
8
|
+
private val x: Float
|
9
|
+
private val y: Float
|
10
|
+
private val absoluteX: Float
|
11
|
+
private val absoluteY: Float
|
12
|
+
|
13
|
+
init {
|
14
|
+
x = handler.lastRelativePositionX
|
15
|
+
y = handler.lastRelativePositionY
|
16
|
+
absoluteX = handler.lastPositionInWindowX
|
17
|
+
absoluteY = handler.lastPositionInWindowY
|
18
|
+
}
|
19
|
+
|
20
|
+
override fun buildEventData(eventData: WritableMap) {
|
21
|
+
super.buildEventData(eventData)
|
22
|
+
|
23
|
+
with(eventData) {
|
24
|
+
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
|
25
|
+
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
|
26
|
+
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
|
27
|
+
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.LongPressGestureHandler
|
6
|
+
|
7
|
+
class LongPressGestureHandlerEventDataBuilder(handler: LongPressGestureHandler) : GestureHandlerEventDataBuilder<LongPressGestureHandler>(handler) {
|
8
|
+
private val x: Float
|
9
|
+
private val y: Float
|
10
|
+
private val absoluteX: Float
|
11
|
+
private val absoluteY: Float
|
12
|
+
private val duration: Int
|
13
|
+
|
14
|
+
init {
|
15
|
+
x = handler.lastRelativePositionX
|
16
|
+
y = handler.lastRelativePositionY
|
17
|
+
absoluteX = handler.lastPositionInWindowX
|
18
|
+
absoluteY = handler.lastPositionInWindowY
|
19
|
+
duration = handler.duration
|
20
|
+
}
|
21
|
+
|
22
|
+
override fun buildEventData(eventData: WritableMap) {
|
23
|
+
super.buildEventData(eventData)
|
24
|
+
|
25
|
+
with(eventData) {
|
26
|
+
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
|
27
|
+
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
|
28
|
+
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
|
29
|
+
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
|
30
|
+
putInt("duration", duration)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.swmansion.gesturehandler.core.NativeViewGestureHandler
|
5
|
+
|
6
|
+
class NativeGestureHandlerEventDataBuilder(handler: NativeViewGestureHandler) : GestureHandlerEventDataBuilder<NativeViewGestureHandler>(handler) {
|
7
|
+
private val pointerInside: Boolean
|
8
|
+
|
9
|
+
init {
|
10
|
+
pointerInside = handler.isWithinBounds
|
11
|
+
}
|
12
|
+
|
13
|
+
override fun buildEventData(eventData: WritableMap) {
|
14
|
+
super.buildEventData(eventData)
|
15
|
+
|
16
|
+
eventData.putBoolean("pointerInside", pointerInside)
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.PanGestureHandler
|
6
|
+
|
7
|
+
class PanGestureHandlerEventDataBuilder(handler: PanGestureHandler) : GestureHandlerEventDataBuilder<PanGestureHandler>(handler) {
|
8
|
+
private val x: Float
|
9
|
+
private val y: Float
|
10
|
+
private val absoluteX: Float
|
11
|
+
private val absoluteY: Float
|
12
|
+
private val translationX: Float
|
13
|
+
private val translationY: Float
|
14
|
+
private val velocityX: Float
|
15
|
+
private val velocityY: Float
|
16
|
+
|
17
|
+
init {
|
18
|
+
x = handler.lastRelativePositionX
|
19
|
+
y = handler.lastRelativePositionY
|
20
|
+
absoluteX = handler.lastPositionInWindowX
|
21
|
+
absoluteY = handler.lastPositionInWindowY
|
22
|
+
translationX = handler.translationX
|
23
|
+
translationY = handler.translationY
|
24
|
+
velocityX = handler.velocityX
|
25
|
+
velocityY = handler.velocityY
|
26
|
+
}
|
27
|
+
|
28
|
+
override fun buildEventData(eventData: WritableMap) {
|
29
|
+
super.buildEventData(eventData)
|
30
|
+
|
31
|
+
with(eventData) {
|
32
|
+
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
|
33
|
+
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
|
34
|
+
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
|
35
|
+
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
|
36
|
+
putDouble("translationX", PixelUtil.toDIPFromPixel(translationX).toDouble())
|
37
|
+
putDouble("translationY", PixelUtil.toDIPFromPixel(translationY).toDouble())
|
38
|
+
putDouble("velocityX", PixelUtil.toDIPFromPixel(velocityX).toDouble())
|
39
|
+
putDouble("velocityY", PixelUtil.toDIPFromPixel(velocityY).toDouble())
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.PinchGestureHandler
|
6
|
+
|
7
|
+
class PinchGestureHandlerEventDataBuilder(handler: PinchGestureHandler) : GestureHandlerEventDataBuilder<PinchGestureHandler>(handler) {
|
8
|
+
private val scale: Double
|
9
|
+
private val focalX: Float
|
10
|
+
private val focalY: Float
|
11
|
+
private val velocity: Double
|
12
|
+
|
13
|
+
init {
|
14
|
+
scale = handler.scale
|
15
|
+
focalX = handler.focalPointX
|
16
|
+
focalY = handler.focalPointY
|
17
|
+
velocity = handler.velocity
|
18
|
+
}
|
19
|
+
|
20
|
+
override fun buildEventData(eventData: WritableMap) {
|
21
|
+
super.buildEventData(eventData)
|
22
|
+
|
23
|
+
with(eventData) {
|
24
|
+
putDouble("scale", scale)
|
25
|
+
putDouble("focalX", PixelUtil.toDIPFromPixel(focalX).toDouble())
|
26
|
+
putDouble("focalY", PixelUtil.toDIPFromPixel(focalY).toDouble())
|
27
|
+
putDouble("velocity", velocity)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.RotationGestureHandler
|
6
|
+
|
7
|
+
class RotationGestureHandlerEventDataBuilder(handler: RotationGestureHandler) : GestureHandlerEventDataBuilder<RotationGestureHandler>(handler) {
|
8
|
+
private val rotation: Double
|
9
|
+
private val anchorX: Float
|
10
|
+
private val anchorY: Float
|
11
|
+
private val velocity: Double
|
12
|
+
|
13
|
+
init {
|
14
|
+
rotation = handler.rotation
|
15
|
+
anchorX = handler.anchorX
|
16
|
+
anchorY = handler.anchorY
|
17
|
+
velocity = handler.velocity
|
18
|
+
}
|
19
|
+
|
20
|
+
override fun buildEventData(eventData: WritableMap) {
|
21
|
+
super.buildEventData(eventData)
|
22
|
+
|
23
|
+
with(eventData) {
|
24
|
+
putDouble("rotation", rotation)
|
25
|
+
putDouble("anchorX", PixelUtil.toDIPFromPixel(anchorX).toDouble())
|
26
|
+
putDouble("anchorY", PixelUtil.toDIPFromPixel(anchorY).toDouble())
|
27
|
+
putDouble("velocity", velocity)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package com.swmansion.gesturehandler.react.eventbuilders
|
2
|
+
|
3
|
+
import com.facebook.react.bridge.WritableMap
|
4
|
+
import com.facebook.react.uimanager.PixelUtil
|
5
|
+
import com.swmansion.gesturehandler.core.TapGestureHandler
|
6
|
+
|
7
|
+
class TapGestureHandlerEventDataBuilder(handler: TapGestureHandler) : GestureHandlerEventDataBuilder<TapGestureHandler>(handler) {
|
8
|
+
private val x: Float
|
9
|
+
private val y: Float
|
10
|
+
private val absoluteX: Float
|
11
|
+
private val absoluteY: Float
|
12
|
+
|
13
|
+
init {
|
14
|
+
x = handler.lastRelativePositionX
|
15
|
+
y = handler.lastRelativePositionY
|
16
|
+
absoluteX = handler.lastPositionInWindowX
|
17
|
+
absoluteY = handler.lastPositionInWindowY
|
18
|
+
}
|
19
|
+
|
20
|
+
override fun buildEventData(eventData: WritableMap) {
|
21
|
+
super.buildEventData(eventData)
|
22
|
+
|
23
|
+
with(eventData) {
|
24
|
+
putDouble("x", PixelUtil.toDIPFromPixel(x).toDouble())
|
25
|
+
putDouble("y", PixelUtil.toDIPFromPixel(y).toDouble())
|
26
|
+
putDouble("absoluteX", PixelUtil.toDIPFromPixel(absoluteX).toDouble())
|
27
|
+
putDouble("absoluteY", PixelUtil.toDIPFromPixel(absoluteY).toDouble())
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
@@ -2,24 +2,36 @@ project(GestureHandler)
|
|
2
2
|
cmake_minimum_required(VERSION 3.9.0)
|
3
3
|
|
4
4
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
5
|
-
|
5
|
+
if(${REACT_NATIVE_MINOR_VERSION} GREATER_EQUAL 73)
|
6
|
+
set(CMAKE_CXX_STANDARD 20)
|
7
|
+
else()
|
8
|
+
set(CMAKE_CXX_STANDARD 17)
|
9
|
+
endif()
|
6
10
|
|
11
|
+
set(PACKAGE_NAME "gesturehandler")
|
7
12
|
set(REACT_ANDROID_DIR "${REACT_NATIVE_DIR}/ReactAndroid")
|
8
13
|
|
9
14
|
include(${REACT_ANDROID_DIR}/cmake-utils/folly-flags.cmake)
|
10
15
|
add_compile_options(${folly_FLAGS})
|
11
16
|
|
12
|
-
add_library(
|
17
|
+
add_library(${PACKAGE_NAME}
|
13
18
|
SHARED
|
14
19
|
cpp-adapter.cpp
|
15
20
|
)
|
16
21
|
|
22
|
+
target_include_directories(
|
23
|
+
${PACKAGE_NAME}
|
24
|
+
PRIVATE
|
25
|
+
"${REACT_NATIVE_DIR}/ReactCommon"
|
26
|
+
)
|
27
|
+
|
17
28
|
find_package(ReactAndroid REQUIRED CONFIG)
|
18
29
|
|
19
30
|
target_link_libraries(
|
20
31
|
gesturehandler
|
21
32
|
ReactAndroid::react_render_core
|
22
33
|
ReactAndroid::react_render_uimanager
|
34
|
+
ReactAndroid::react_render_graphics
|
23
35
|
ReactAndroid::jsi
|
24
36
|
ReactAndroid::react_nativemodule_core
|
25
37
|
)
|