@zeey4d/react-native-gesture-engine 1.0.1 → 1.0.2
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.
- package/dist/index.d.mts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +77 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Gesture } from 'react-native-gesture-handler';
|
|
1
2
|
import { Accelerometer, Gyroscope } from 'expo-sensors';
|
|
2
3
|
import { DeviceEventEmitter, Vibration, AccessibilityInfo } from 'react-native';
|
|
3
4
|
import * as Haptics from 'expo-haptics';
|
|
@@ -114,12 +115,11 @@ var EventChannel = /* @__PURE__ */ ((EventChannel2) => {
|
|
|
114
115
|
function generateId() {
|
|
115
116
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
116
117
|
}
|
|
117
|
-
|
|
118
|
-
// src/input/TouchInputProvider.ts
|
|
119
118
|
var TouchInputProvider = class {
|
|
120
119
|
constructor(eventBus) {
|
|
121
120
|
this.eventBus = eventBus;
|
|
122
121
|
this._isActive = false;
|
|
122
|
+
this.gesture = this.buildGesture();
|
|
123
123
|
}
|
|
124
124
|
get isActive() {
|
|
125
125
|
return this._isActive;
|
|
@@ -217,6 +217,79 @@ var TouchInputProvider = class {
|
|
|
217
217
|
};
|
|
218
218
|
this.eventBus.emit("input:raw" /* InputRaw */, event);
|
|
219
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Build the composed gesture.
|
|
222
|
+
*/
|
|
223
|
+
buildGesture() {
|
|
224
|
+
const panGesture = Gesture.Pan().onUpdate((e) => {
|
|
225
|
+
this.onPan({
|
|
226
|
+
x: e.x,
|
|
227
|
+
y: e.y,
|
|
228
|
+
translationX: e.translationX,
|
|
229
|
+
translationY: e.translationY,
|
|
230
|
+
velocityX: e.velocityX,
|
|
231
|
+
velocityY: e.velocityY,
|
|
232
|
+
numberOfPointers: e.numberOfPointers
|
|
233
|
+
});
|
|
234
|
+
}).onEnd((e) => {
|
|
235
|
+
this.onPan({
|
|
236
|
+
x: e.x,
|
|
237
|
+
y: e.y,
|
|
238
|
+
translationX: e.translationX,
|
|
239
|
+
translationY: e.translationY,
|
|
240
|
+
velocityX: e.velocityX,
|
|
241
|
+
velocityY: e.velocityY,
|
|
242
|
+
numberOfPointers: e.numberOfPointers
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
const tapGesture = Gesture.Tap().onEnd((e) => {
|
|
246
|
+
this.onTap({
|
|
247
|
+
x: e.x,
|
|
248
|
+
y: e.y,
|
|
249
|
+
numberOfPointers: e.numberOfPointers
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
const pinchGesture = Gesture.Pinch().onUpdate((e) => {
|
|
253
|
+
this.onPinch({
|
|
254
|
+
scale: e.scale,
|
|
255
|
+
focalX: e.focalX,
|
|
256
|
+
focalY: e.focalY,
|
|
257
|
+
velocity: e.velocity,
|
|
258
|
+
numberOfPointers: e.numberOfPointers
|
|
259
|
+
});
|
|
260
|
+
}).onEnd((e) => {
|
|
261
|
+
this.onPinch({
|
|
262
|
+
scale: e.scale,
|
|
263
|
+
focalX: e.focalX,
|
|
264
|
+
focalY: e.focalY,
|
|
265
|
+
velocity: e.velocity,
|
|
266
|
+
numberOfPointers: e.numberOfPointers
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
const rotationGesture = Gesture.Rotation().onUpdate((e) => {
|
|
270
|
+
this.onRotation({
|
|
271
|
+
rotation: e.rotation,
|
|
272
|
+
anchorX: e.anchorX,
|
|
273
|
+
anchorY: e.anchorY,
|
|
274
|
+
velocity: e.velocity,
|
|
275
|
+
numberOfPointers: e.numberOfPointers
|
|
276
|
+
});
|
|
277
|
+
}).onEnd((e) => {
|
|
278
|
+
this.onRotation({
|
|
279
|
+
rotation: e.rotation,
|
|
280
|
+
anchorX: e.anchorX,
|
|
281
|
+
anchorY: e.anchorY,
|
|
282
|
+
velocity: e.velocity,
|
|
283
|
+
numberOfPointers: e.numberOfPointers
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
return Gesture.Simultaneous(
|
|
287
|
+
panGesture,
|
|
288
|
+
tapGesture,
|
|
289
|
+
pinchGesture,
|
|
290
|
+
rotationGesture
|
|
291
|
+
);
|
|
292
|
+
}
|
|
220
293
|
};
|
|
221
294
|
var SensorInputProvider = class {
|
|
222
295
|
constructor(eventBus, updateIntervalMs = 100) {
|
|
@@ -2241,7 +2314,8 @@ function useGestureEngine(config = {}) {
|
|
|
2241
2314
|
}, []);
|
|
2242
2315
|
return {
|
|
2243
2316
|
engine: engineRef.current,
|
|
2244
|
-
isReady
|
|
2317
|
+
isReady,
|
|
2318
|
+
gestures: engineRef.current?.touchInput.gesture
|
|
2245
2319
|
};
|
|
2246
2320
|
}
|
|
2247
2321
|
function useShakeGesture(config) {
|