@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.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ComposedGesture } from 'react-native-gesture-handler';
|
|
2
|
+
|
|
1
3
|
/** Classification of input sources feeding into the pipeline */
|
|
2
4
|
declare enum InputType {
|
|
3
5
|
Touch = "touch",
|
|
@@ -422,6 +424,11 @@ declare class EventBus implements IEventBus {
|
|
|
422
424
|
declare class TouchInputProvider implements IInputProvider {
|
|
423
425
|
private eventBus;
|
|
424
426
|
private _isActive;
|
|
427
|
+
/**
|
|
428
|
+
* Extracted composed RNGH Gesture.
|
|
429
|
+
* Consumers should wrap their app/screen in <GestureDetector gesture={gesture}>
|
|
430
|
+
*/
|
|
431
|
+
readonly gesture: ComposedGesture;
|
|
425
432
|
constructor(eventBus: IEventBus);
|
|
426
433
|
get isActive(): boolean;
|
|
427
434
|
start(): void;
|
|
@@ -469,6 +476,10 @@ declare class TouchInputProvider implements IInputProvider {
|
|
|
469
476
|
}): void;
|
|
470
477
|
/** Emit a normalized InputEvent onto the EventBus */
|
|
471
478
|
private emitInput;
|
|
479
|
+
/**
|
|
480
|
+
* Build the composed gesture.
|
|
481
|
+
*/
|
|
482
|
+
private buildGesture;
|
|
472
483
|
}
|
|
473
484
|
|
|
474
485
|
/**
|
|
@@ -1331,6 +1342,11 @@ interface UseGestureEngineResult {
|
|
|
1331
1342
|
engine: GestureEngine | null;
|
|
1332
1343
|
/** Whether the engine is initialized and running */
|
|
1333
1344
|
isReady: boolean;
|
|
1345
|
+
/**
|
|
1346
|
+
* RNGH Composed Gesture.
|
|
1347
|
+
* Pass this to `<GestureDetector gesture={gestures}>` to enable touch inputs.
|
|
1348
|
+
*/
|
|
1349
|
+
gestures?: ComposedGesture;
|
|
1334
1350
|
}
|
|
1335
1351
|
/**
|
|
1336
1352
|
* React hook that creates, configures, and manages a GestureEngine lifecycle.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ComposedGesture } from 'react-native-gesture-handler';
|
|
2
|
+
|
|
1
3
|
/** Classification of input sources feeding into the pipeline */
|
|
2
4
|
declare enum InputType {
|
|
3
5
|
Touch = "touch",
|
|
@@ -422,6 +424,11 @@ declare class EventBus implements IEventBus {
|
|
|
422
424
|
declare class TouchInputProvider implements IInputProvider {
|
|
423
425
|
private eventBus;
|
|
424
426
|
private _isActive;
|
|
427
|
+
/**
|
|
428
|
+
* Extracted composed RNGH Gesture.
|
|
429
|
+
* Consumers should wrap their app/screen in <GestureDetector gesture={gesture}>
|
|
430
|
+
*/
|
|
431
|
+
readonly gesture: ComposedGesture;
|
|
425
432
|
constructor(eventBus: IEventBus);
|
|
426
433
|
get isActive(): boolean;
|
|
427
434
|
start(): void;
|
|
@@ -469,6 +476,10 @@ declare class TouchInputProvider implements IInputProvider {
|
|
|
469
476
|
}): void;
|
|
470
477
|
/** Emit a normalized InputEvent onto the EventBus */
|
|
471
478
|
private emitInput;
|
|
479
|
+
/**
|
|
480
|
+
* Build the composed gesture.
|
|
481
|
+
*/
|
|
482
|
+
private buildGesture;
|
|
472
483
|
}
|
|
473
484
|
|
|
474
485
|
/**
|
|
@@ -1331,6 +1342,11 @@ interface UseGestureEngineResult {
|
|
|
1331
1342
|
engine: GestureEngine | null;
|
|
1332
1343
|
/** Whether the engine is initialized and running */
|
|
1333
1344
|
isReady: boolean;
|
|
1345
|
+
/**
|
|
1346
|
+
* RNGH Composed Gesture.
|
|
1347
|
+
* Pass this to `<GestureDetector gesture={gestures}>` to enable touch inputs.
|
|
1348
|
+
*/
|
|
1349
|
+
gestures?: ComposedGesture;
|
|
1334
1350
|
}
|
|
1335
1351
|
/**
|
|
1336
1352
|
* React hook that creates, configures, and manages a GestureEngine lifecycle.
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var reactNativeGestureHandler = require('react-native-gesture-handler');
|
|
3
4
|
var expoSensors = require('expo-sensors');
|
|
4
5
|
var reactNative = require('react-native');
|
|
5
6
|
var Haptics = require('expo-haptics');
|
|
@@ -136,12 +137,11 @@ var EventChannel = /* @__PURE__ */ ((EventChannel2) => {
|
|
|
136
137
|
function generateId() {
|
|
137
138
|
return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
138
139
|
}
|
|
139
|
-
|
|
140
|
-
// src/input/TouchInputProvider.ts
|
|
141
140
|
var TouchInputProvider = class {
|
|
142
141
|
constructor(eventBus) {
|
|
143
142
|
this.eventBus = eventBus;
|
|
144
143
|
this._isActive = false;
|
|
144
|
+
this.gesture = this.buildGesture();
|
|
145
145
|
}
|
|
146
146
|
get isActive() {
|
|
147
147
|
return this._isActive;
|
|
@@ -239,6 +239,79 @@ var TouchInputProvider = class {
|
|
|
239
239
|
};
|
|
240
240
|
this.eventBus.emit("input:raw" /* InputRaw */, event);
|
|
241
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Build the composed gesture.
|
|
244
|
+
*/
|
|
245
|
+
buildGesture() {
|
|
246
|
+
const panGesture = reactNativeGestureHandler.Gesture.Pan().onUpdate((e) => {
|
|
247
|
+
this.onPan({
|
|
248
|
+
x: e.x,
|
|
249
|
+
y: e.y,
|
|
250
|
+
translationX: e.translationX,
|
|
251
|
+
translationY: e.translationY,
|
|
252
|
+
velocityX: e.velocityX,
|
|
253
|
+
velocityY: e.velocityY,
|
|
254
|
+
numberOfPointers: e.numberOfPointers
|
|
255
|
+
});
|
|
256
|
+
}).onEnd((e) => {
|
|
257
|
+
this.onPan({
|
|
258
|
+
x: e.x,
|
|
259
|
+
y: e.y,
|
|
260
|
+
translationX: e.translationX,
|
|
261
|
+
translationY: e.translationY,
|
|
262
|
+
velocityX: e.velocityX,
|
|
263
|
+
velocityY: e.velocityY,
|
|
264
|
+
numberOfPointers: e.numberOfPointers
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
const tapGesture = reactNativeGestureHandler.Gesture.Tap().onEnd((e) => {
|
|
268
|
+
this.onTap({
|
|
269
|
+
x: e.x,
|
|
270
|
+
y: e.y,
|
|
271
|
+
numberOfPointers: e.numberOfPointers
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
const pinchGesture = reactNativeGestureHandler.Gesture.Pinch().onUpdate((e) => {
|
|
275
|
+
this.onPinch({
|
|
276
|
+
scale: e.scale,
|
|
277
|
+
focalX: e.focalX,
|
|
278
|
+
focalY: e.focalY,
|
|
279
|
+
velocity: e.velocity,
|
|
280
|
+
numberOfPointers: e.numberOfPointers
|
|
281
|
+
});
|
|
282
|
+
}).onEnd((e) => {
|
|
283
|
+
this.onPinch({
|
|
284
|
+
scale: e.scale,
|
|
285
|
+
focalX: e.focalX,
|
|
286
|
+
focalY: e.focalY,
|
|
287
|
+
velocity: e.velocity,
|
|
288
|
+
numberOfPointers: e.numberOfPointers
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
const rotationGesture = reactNativeGestureHandler.Gesture.Rotation().onUpdate((e) => {
|
|
292
|
+
this.onRotation({
|
|
293
|
+
rotation: e.rotation,
|
|
294
|
+
anchorX: e.anchorX,
|
|
295
|
+
anchorY: e.anchorY,
|
|
296
|
+
velocity: e.velocity,
|
|
297
|
+
numberOfPointers: e.numberOfPointers
|
|
298
|
+
});
|
|
299
|
+
}).onEnd((e) => {
|
|
300
|
+
this.onRotation({
|
|
301
|
+
rotation: e.rotation,
|
|
302
|
+
anchorX: e.anchorX,
|
|
303
|
+
anchorY: e.anchorY,
|
|
304
|
+
velocity: e.velocity,
|
|
305
|
+
numberOfPointers: e.numberOfPointers
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
return reactNativeGestureHandler.Gesture.Simultaneous(
|
|
309
|
+
panGesture,
|
|
310
|
+
tapGesture,
|
|
311
|
+
pinchGesture,
|
|
312
|
+
rotationGesture
|
|
313
|
+
);
|
|
314
|
+
}
|
|
242
315
|
};
|
|
243
316
|
var SensorInputProvider = class {
|
|
244
317
|
constructor(eventBus, updateIntervalMs = 100) {
|
|
@@ -2263,7 +2336,8 @@ function useGestureEngine(config = {}) {
|
|
|
2263
2336
|
}, []);
|
|
2264
2337
|
return {
|
|
2265
2338
|
engine: engineRef.current,
|
|
2266
|
-
isReady
|
|
2339
|
+
isReady,
|
|
2340
|
+
gestures: engineRef.current?.touchInput.gesture
|
|
2267
2341
|
};
|
|
2268
2342
|
}
|
|
2269
2343
|
function useShakeGesture(config) {
|