react-native-gesture-handler 2.1.2 → 2.2.1
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/README.md +3 -2
- package/android/build.gradle +1 -1
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +42 -11
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +36 -2
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +7 -4
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PinchGestureHandler.kt +6 -4
- package/android/lib/src/main/java/com/swmansion/gesturehandler/RotationGestureHandler.kt +6 -4
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +8 -8
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +19 -0
- package/lib/commonjs/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/GestureDetector.js +37 -13
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/eventReceiver.js +1 -0
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/commonjs/index.js +0 -106
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/web/GestureHandler.js +4 -1
- package/lib/commonjs/web/GestureHandler.js.map +1 -1
- package/lib/module/handlers/LongPressGestureHandler.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +35 -13
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/eventReceiver.js +1 -2
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/module/index.js +0 -11
- package/lib/module/index.js.map +1 -1
- package/lib/module/web/GestureHandler.js +4 -1
- package/lib/module/web/GestureHandler.js.map +1 -1
- package/lib/typescript/handlers/LongPressGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -2
- package/lib/typescript/handlers/gestures/eventReceiver.d.ts +2 -0
- package/lib/typescript/index.d.ts +11 -11
- package/lib/typescript/web/GestureHandler.d.ts +1 -1
- package/package.json +1 -1
- package/src/handlers/LongPressGestureHandler.ts +2 -2
- package/src/handlers/PanGestureHandler.ts +2 -2
- package/src/handlers/gestures/GestureDetector.tsx +48 -11
- package/src/handlers/gestures/eventReceiver.ts +1 -1
- package/src/index.ts +11 -11
- package/src/web/GestureHandler.ts +7 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["GestureHandler.ts"],"names":["Hammer","findNodeHandle","State","EventMap","NodeManager","gestureInstances","GestureHandler","id","name","gestureInstance","isDiscrete","shouldEnableGestureOnSetup","Error","constructor","UNDETERMINED","Array","isArray","config","waitFor","gesture","removePendingGesture","clearSelfAsPending","hammer","stop","destroy","x","y","rect","view","getBoundingClientRect","pointerInside","left","right","top","bottom","nativeEvent","onGestureHandlerEvent","onGestureHandlerStateChange","propsRef","current","event","transformEventData","invokeNullableMethod","lastSentState","state","get","enable","recognizer","inputData","enabled","isGestureRunning","hasGestureFailed","options","maxPointers","_stillWaiting","_getPendingGestures","length","hasCustomActivationCriteria","deltaRotation","initialRotation","rotation","success","failed","isGestureEnabledForEvent","getConfig","simulateCancelEvent","params","getHammerConfig","set","onWaitingEnded","_gesture","pendingGestures","addPendingGesture","_config","_recognizer","_event","NativeGestureClass","updateHasCustomActivationCriteria","updateGestureConfig","props","ensureConfig","sync","getState","type","eventType","numberOfPointers","changedTouch","changedPointers","isPointInView","clientX","clientY","previousState","oldState","transformNativeEvent","handlerTag","target","ref","timeStamp","Date","now","cancelPendingGestures","Object","values","cancelEvent","notifyPendingGestures","onGestureEnded","forceInvalidate","sendEvent","INPUT_CANCEL","isFinal","onRawEvent","isFirst","setView","Manager","add","on","ev","setTimeout","setupEvents","onStart","onGestureActivated","deltaX","deltaY","__initialX","__initialY","onSuccess","stillWaiting","filter","pointers","minPointers","_inputData","method","__getHandler","handler","argMapping","__nodeConfig","index","key","value","entries","nativeValue","setValue","minDist","minDistSq","minVelocity","minVelocitySq","maxDist","maxDistSq","asArray","map","getHandler","v","configProps","forEach","prop","Number","NaN"],"mappings":";;AAAA;;AACA;AACA,OAAOA,MAAP,MAAmB,gBAAnB;AACA,SAASC,cAAT,QAA+B,cAA/B;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,QAAT,QAAyB,aAAzB;AACA,OAAO,KAAKC,WAAZ,MAA6B,eAA7B,C,CAEA;;AA0BA,IAAIC,gBAAgB,GAAG,CAAvB;;AAEA,MAAeC,cAAf,CAA8B;AAsBtB,MAAFC,EAAE,GAAG;AACP,WAAQ,GAAE,KAAKC,IAAK,GAAE,KAAKC,eAAgB,EAA3C;AACD;;AAEa,MAAVC,UAAU,GAAG;AACf,WAAO,KAAP;AACD;;AAE6B,MAA1BC,0BAA0B,GAAY;AACxC,UAAM,IAAIC,KAAJ,CAAU,yDAAV,CAAN;AACD;;AAEDC,EAAAA,WAAW,GAAG;AAAA;;AAAA,8CAhCY,KAgCZ;;AAAA,kCA/Be,IA+Bf;;AAAA;;AAAA,8CA7Be,KA6Bf;;AAAA,oCA5B2B,IA4B3B;;AAAA,6CA3B6B,IA2B7B;;AAAA;;AAAA;;AAAA,oCAxBa,EAwBb;;AAAA,2CAvBmBX,KAAK,CAACY,YAuBzB;;AAAA,6CAtBkC,EAsBlC;;AAAA,sCArBYZ,KAAK,CAACY,YAqBlB;;AAAA,2CApBwB,IAoBxB;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,gDAmCO,MAAM;AACzB,UAAIC,KAAK,CAACC,OAAN,CAAc,KAAKC,MAAL,CAAYC,OAA1B,CA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Content":["/* eslint-disable eslint-comments/no-unlimited-disable */\n/* eslint-disable */\nimport Hammer from '@egjs/hammerjs';\nimport { findNodeHandle } from 'react-native';\n\nimport { State } from '../State';\nimport { EventMap } from './constants';\nimport * as NodeManager from './NodeManager';\n\n// TODO(TS) Replace with HammerInput if https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438/files is merged\nexport type HammerInputExt = Omit<HammerInput, 'destroy' | 'handler' | 'init'>;\n\nexport type Config = Partial<{\n enabled: boolean;\n minPointers: number;\n maxPointers: number;\n minDist: number;\n minDistSq: number;\n minVelocity: number;\n minVelocitySq: number;\n maxDist: number;\n maxDistSq: number;\n failOffsetXStart: number;\n failOffsetYStart: number;\n failOffsetXEnd: number;\n failOffsetYEnd: number;\n activeOffsetXStart: number;\n activeOffsetXEnd: number;\n activeOffsetYStart: number;\n activeOffsetYEnd: number;\n waitFor: any[] | null;\n}>;\n\ntype NativeEvent = ReturnType<GestureHandler['transformEventData']>;\n\nlet gestureInstances = 0;\n\nabstract class GestureHandler {\n public handlerTag: any;\n public isGestureRunning = false;\n public view: number | null = null;\n protected hasCustomActivationCriteria: boolean;\n protected hasGestureFailed = false;\n protected hammer: HammerManager | null = null;\n protected initialRotation: number | null = null;\n protected __initialX: any;\n protected __initialY: any;\n protected config: Config = {};\n protected previousState: State = State.UNDETERMINED;\n private pendingGestures: Record<string, this> = {};\n private oldState: State = State.UNDETERMINED;\n private lastSentState: State | null = null;\n private gestureInstance: number;\n private _stillWaiting: any;\n private propsRef: any;\n private ref: any;\n\n abstract get name(): string;\n\n get id() {\n return `${this.name}${this.gestureInstance}`;\n }\n\n get isDiscrete() {\n return false;\n }\n\n get shouldEnableGestureOnSetup(): boolean {\n throw new Error('Must override GestureHandler.shouldEnableGestureOnSetup');\n }\n\n constructor() {\n this.gestureInstance = gestureInstances++;\n this.hasCustomActivationCriteria = false;\n }\n\n getConfig() {\n return this.config;\n }\n\n onWaitingEnded(_gesture: this) {}\n\n removePendingGesture(id: string) {\n delete this.pendingGestures[id];\n }\n\n addPendingGesture(gesture: this) {\n this.pendingGestures[gesture.id] = gesture;\n }\n\n isGestureEnabledForEvent(\n _config: any,\n _recognizer: any,\n _event: any\n ): { failed?: boolean; success?: boolean } {\n return { success: true };\n }\n\n get NativeGestureClass(): RecognizerStatic {\n throw new Error('Must override GestureHandler.NativeGestureClass');\n }\n\n updateHasCustomActivationCriteria(_config: Config) {\n return true;\n }\n\n clearSelfAsPending = () => {\n if (Array.isArray(this.config.waitFor)) {\n for (const gesture of this.config.waitFor) {\n gesture.removePendingGesture(this.id);\n }\n }\n };\n\n updateGestureConfig({ enabled = true, ...props }) {\n this.clearSelfAsPending();\n\n this.config = ensureConfig({ enabled, ...props });\n this.hasCustomActivationCriteria = this.updateHasCustomActivationCriteria(\n this.config\n );\n if (Array.isArray(this.config.waitFor)) {\n for (const gesture of this.config.waitFor) {\n gesture.addPendingGesture(this);\n }\n }\n\n if (this.hammer) {\n this.sync();\n }\n return this.config;\n }\n\n destroy = () => {\n this.clearSelfAsPending();\n\n if (this.hammer) {\n this.hammer.stop(false);\n this.hammer.destroy();\n }\n this.hammer = null;\n };\n\n isPointInView = ({ x, y }: { x: number; y: number }) => {\n // @ts-ignore FIXME(TS)\n const rect = this.view!.getBoundingClientRect();\n const pointerInside =\n x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n return pointerInside;\n };\n\n getState(type: keyof typeof EventMap): State {\n // @ts-ignore TODO(TS) check if this is needed\n if (type == 0) {\n return 0;\n }\n return EventMap[type];\n }\n\n transformEventData(event: HammerInputExt) {\n const { eventType, maxPointers: numberOfPointers } = event;\n // const direction = DirectionMap[ev.direction];\n const changedTouch = event.changedPointers[0];\n const pointerInside = this.isPointInView({\n x: changedTouch.clientX,\n y: changedTouch.clientY,\n });\n\n // TODO(TS) Remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50966 is merged.\n const state = this.getState(eventType as 1 | 2 | 4 | 8);\n if (state !== this.previousState) {\n this.oldState = this.previousState;\n this.previousState = state;\n }\n\n return {\n nativeEvent: {\n numberOfPointers,\n state,\n pointerInside,\n ...this.transformNativeEvent(event),\n // onHandlerStateChange only\n handlerTag: this.handlerTag,\n target: this.ref,\n oldState: this.oldState,\n },\n timeStamp: Date.now(),\n };\n }\n\n transformNativeEvent(_event: HammerInputExt) {\n return {};\n }\n\n sendEvent = (nativeEvent: HammerInputExt) => {\n const {\n onGestureHandlerEvent,\n onGestureHandlerStateChange,\n } = this.propsRef.current;\n\n const event = this.transformEventData(nativeEvent);\n\n invokeNullableMethod(onGestureHandlerEvent, event);\n if (this.lastSentState !== event.nativeEvent.state) {\n this.lastSentState = event.nativeEvent.state as State;\n invokeNullableMethod(onGestureHandlerStateChange, event);\n }\n };\n\n cancelPendingGestures(event: HammerInputExt) {\n for (const gesture of Object.values(this.pendingGestures)) {\n if (gesture && gesture.isGestureRunning) {\n gesture.hasGestureFailed = true;\n gesture.cancelEvent(event);\n }\n }\n }\n\n notifyPendingGestures() {\n for (const gesture of Object.values(this.pendingGestures)) {\n if (gesture) {\n gesture.onWaitingEnded(this);\n }\n }\n }\n\n // FIXME event is undefined in runtime when firstly invoked (see Draggable example), check other functions taking event as input\n onGestureEnded(event: HammerInputExt) {\n this.isGestureRunning = false;\n this.cancelPendingGestures(event);\n }\n\n forceInvalidate(event: HammerInputExt) {\n if (this.isGestureRunning) {\n this.hasGestureFailed = true;\n this.cancelEvent(event);\n }\n }\n\n cancelEvent(event: HammerInputExt) {\n this.notifyPendingGestures();\n this.sendEvent({\n ...event,\n eventType: Hammer.INPUT_CANCEL,\n isFinal: true,\n });\n this.onGestureEnded(event);\n }\n\n onRawEvent({ isFirst }: HammerInputExt) {\n if (isFirst) {\n this.hasGestureFailed = false;\n }\n }\n\n setView(ref: Parameters<typeof findNodeHandle>['0'], propsRef: any) {\n if (ref == null) {\n this.destroy();\n this.view = null;\n return;\n }\n\n this.propsRef = propsRef;\n this.ref = ref;\n\n this.view = findNodeHandle(ref);\n this.hammer = new Hammer.Manager(this.view as any);\n\n this.oldState = State.UNDETERMINED;\n this.previousState = State.UNDETERMINED;\n this.lastSentState = null;\n\n const { NativeGestureClass } = this;\n // @ts-ignore TODO(TS)\n const gesture = new NativeGestureClass(this.getHammerConfig());\n this.hammer.add(gesture);\n\n this.hammer.on('hammer.input', (ev: HammerInput) => {\n if (!this.config.enabled) {\n this.hasGestureFailed = false;\n this.isGestureRunning = false;\n return;\n }\n\n this.onRawEvent((ev as unknown) as HammerInputExt);\n\n // TODO: Bacon: Check against something other than null\n // The isFirst value is not called when the first rotation is calculated.\n if (this.initialRotation === null && ev.rotation !== 0) {\n this.initialRotation = ev.rotation;\n }\n if (ev.isFinal) {\n // in favor of a willFail otherwise the last frame of the gesture will be captured.\n setTimeout(() => {\n this.initialRotation = null;\n this.hasGestureFailed = false;\n });\n }\n });\n\n this.setupEvents();\n this.sync();\n }\n\n setupEvents() {\n // TODO(TS) Hammer types aren't exactly that what we get in runtime\n if (!this.isDiscrete) {\n this.hammer!.on(`${this.name}start`, (event: HammerInput) =>\n this.onStart((event as unknown) as HammerInputExt)\n );\n this.hammer!.on(\n `${this.name}end ${this.name}cancel`,\n (event: HammerInput) => {\n this.onGestureEnded((event as unknown) as HammerInputExt);\n }\n );\n }\n this.hammer!.on(this.name, (ev: HammerInput) =>\n this.onGestureActivated((ev as unknown) as HammerInputExt)\n ); // TODO(TS) remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438 is merged\n }\n\n onStart({ deltaX, deltaY, rotation }: HammerInputExt) {\n // Reset the state for the next gesture\n this.oldState = State.UNDETERMINED;\n this.previousState = State.UNDETERMINED;\n this.lastSentState = null;\n\n this.isGestureRunning = true;\n this.__initialX = deltaX;\n this.__initialY = deltaY;\n this.initialRotation = rotation;\n }\n\n onGestureActivated(ev: HammerInputExt) {\n this.sendEvent(ev);\n }\n\n onSuccess() {}\n\n _getPendingGestures() {\n if (Array.isArray(this.config.waitFor) && this.config.waitFor.length) {\n // Get the list of gestures that this gesture is still waiting for.\n // Use `=== false` in case a ref that isn't a gesture handler is used.\n const stillWaiting = this.config.waitFor.filter(\n ({ hasGestureFailed }) => hasGestureFailed === false\n );\n return stillWaiting;\n }\n return [];\n }\n\n getHammerConfig() {\n const pointers =\n this.config.minPointers === this.config.maxPointers\n ? this.config.minPointers\n : 0;\n return {\n pointers,\n };\n }\n\n sync = () => {\n const gesture = this.hammer!.get(this.name);\n if (!gesture) return;\n\n const enable = (recognizer: any, inputData: any) => {\n if (!this.config.enabled) {\n this.isGestureRunning = false;\n this.hasGestureFailed = false;\n return false;\n }\n\n // Prevent events before the system is ready.\n if (\n !inputData ||\n !recognizer.options ||\n typeof inputData.maxPointers === 'undefined'\n ) {\n return this.shouldEnableGestureOnSetup;\n }\n\n if (this.hasGestureFailed) {\n return false;\n }\n\n if (!this.isDiscrete) {\n if (this.isGestureRunning) {\n return true;\n }\n // The built-in hammer.js \"waitFor\" doesn't work across multiple views.\n // Only process if there are views to wait for.\n this._stillWaiting = this._getPendingGestures();\n // This gesture should continue waiting.\n if (this._stillWaiting.length) {\n // Check to see if one of the gestures you're waiting for has started.\n // If it has then the gesture should fail.\n for (const gesture of this._stillWaiting) {\n // When the target gesture has started, this gesture must force fail.\n if (!gesture.isDiscrete && gesture.isGestureRunning) {\n this.hasGestureFailed = true;\n this.isGestureRunning = false;\n return false;\n }\n }\n // This gesture shouldn't start until the others have finished.\n return false;\n }\n }\n\n // Use default behaviour\n if (!this.hasCustomActivationCriteria) {\n return true;\n }\n\n const deltaRotation =\n this.initialRotation == null\n ? 0\n : inputData.rotation - this.initialRotation;\n // @ts-ignore FIXME(TS)\n const { success, failed } = this.isGestureEnabledForEvent(\n this.getConfig(),\n recognizer,\n {\n ...inputData,\n deltaRotation,\n }\n );\n\n if (failed) {\n this.simulateCancelEvent(inputData);\n this.hasGestureFailed = true;\n }\n return success;\n };\n\n const params = this.getHammerConfig();\n // @ts-ignore FIXME(TS)\n gesture.set({ ...params, enable });\n };\n\n simulateCancelEvent(_inputData: any) {}\n}\n\n// TODO(TS) investigate this method\n// Used for sending data to a callback or AnimatedEvent\nfunction invokeNullableMethod(\n method:\n | ((event: NativeEvent) => void)\n | { __getHandler: () => (event: NativeEvent) => void }\n | { __nodeConfig: { argMapping: any } },\n event: NativeEvent\n) {\n if (method) {\n if (typeof method === 'function') {\n method(event);\n } else {\n // For use with reanimated's AnimatedEvent\n if (\n '__getHandler' in method &&\n typeof method.__getHandler === 'function'\n ) {\n const handler = method.__getHandler();\n invokeNullableMethod(handler, event);\n } else {\n if ('__nodeConfig' in method) {\n const { argMapping } = method.__nodeConfig;\n if (Array.isArray(argMapping)) {\n for (const [index, [key, value]] of argMapping.entries()) {\n if (key in event.nativeEvent) {\n // @ts-ignore fix method type\n const nativeValue = event.nativeEvent[key];\n if (value && value.setValue) {\n // Reanimated API\n value.setValue(nativeValue);\n } else {\n // RN Animated API\n method.__nodeConfig.argMapping[index] = [key, nativeValue];\n }\n }\n }\n }\n }\n }\n }\n }\n}\n\n// Validate the props\nfunction ensureConfig(config: Config): Required<Config> {\n const props = { ...config };\n\n // TODO(TS) We use ! to assert that if property is present then value is not empty (null, undefined)\n if ('minDist' in config) {\n props.minDist = config.minDist;\n props.minDistSq = props.minDist! * props.minDist!;\n }\n if ('minVelocity' in config) {\n props.minVelocity = config.minVelocity;\n props.minVelocitySq = props.minVelocity! * props.minVelocity!;\n }\n if ('maxDist' in config) {\n props.maxDist = config.maxDist;\n props.maxDistSq = config.maxDist! * config.maxDist!;\n }\n if ('waitFor' in config) {\n props.waitFor = asArray(config.waitFor)\n .map(({ handlerTag }: { handlerTag: number }) =>\n NodeManager.getHandler(handlerTag)\n )\n .filter((v) => v);\n } else {\n props.waitFor = null;\n }\n\n const configProps = [\n 'minPointers',\n 'maxPointers',\n 'minDist',\n 'maxDist',\n 'maxDistSq',\n 'minVelocitySq',\n 'minDistSq',\n 'minVelocity',\n 'failOffsetXStart',\n 'failOffsetYStart',\n 'failOffsetXEnd',\n 'failOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n ] as const;\n configProps.forEach((prop: typeof configProps[number]) => {\n if (typeof props[prop] === 'undefined') {\n props[prop] = Number.NaN;\n }\n });\n return props as Required<Config>; // TODO(TS) how to convince TS that props are filled?\n}\n\nfunction asArray<T>(value: T | T[]) {\n // TODO(TS) use config.waitFor type\n return value == null ? [] : Array.isArray(value) ? value : [value];\n}\n\nexport default GestureHandler;\n"]}
|
1
|
+
{"version":3,"sources":["GestureHandler.ts"],"names":["Hammer","findNodeHandle","State","EventMap","NodeManager","gestureInstances","GestureHandler","id","name","gestureInstance","isDiscrete","shouldEnableGestureOnSetup","Error","constructor","UNDETERMINED","Array","isArray","config","waitFor","gesture","removePendingGesture","clearSelfAsPending","hammer","stop","destroy","x","y","rect","view","getBoundingClientRect","pointerInside","left","right","top","bottom","nativeEvent","onGestureHandlerEvent","onGestureHandlerStateChange","propsRef","current","event","transformEventData","invokeNullableMethod","lastSentState","state","get","enable","recognizer","inputData","enabled","isGestureRunning","hasGestureFailed","options","maxPointers","_stillWaiting","_getPendingGestures","length","hasCustomActivationCriteria","deltaRotation","initialRotation","rotation","success","failed","isGestureEnabledForEvent","getConfig","simulateCancelEvent","params","getHammerConfig","set","onWaitingEnded","_gesture","pendingGestures","addPendingGesture","_config","_recognizer","_event","NativeGestureClass","updateHasCustomActivationCriteria","updateGestureConfig","props","ensureConfig","sync","getState","type","eventType","numberOfPointers","changedTouch","changedPointers","isPointInView","clientX","clientY","previousState","oldState","transformNativeEvent","handlerTag","target","ref","undefined","timeStamp","Date","now","cancelPendingGestures","Object","values","cancelEvent","notifyPendingGestures","onGestureEnded","forceInvalidate","sendEvent","INPUT_CANCEL","isFinal","onRawEvent","isFirst","setView","Manager","add","on","ev","setTimeout","setupEvents","onStart","onGestureActivated","deltaX","deltaY","__initialX","__initialY","onSuccess","stillWaiting","filter","pointers","minPointers","_inputData","method","__getHandler","handler","argMapping","__nodeConfig","index","key","value","entries","nativeValue","setValue","minDist","minDistSq","minVelocity","minVelocitySq","maxDist","maxDistSq","asArray","map","getHandler","v","configProps","forEach","prop","Number","NaN"],"mappings":";;AAAA;;AACA;AACA,OAAOA,MAAP,MAAmB,gBAAnB;AACA,SAASC,cAAT,QAA+B,cAA/B;AAEA,SAASC,KAAT,QAAsB,UAAtB;AACA,SAASC,QAAT,QAAyB,aAAzB;AACA,OAAO,KAAKC,WAAZ,MAA6B,eAA7B,C,CAEA;;AA0BA,IAAIC,gBAAgB,GAAG,CAAvB;;AAEA,MAAeC,cAAf,CAA8B;AAsBtB,MAAFC,EAAE,GAAG;AACP,WAAQ,GAAE,KAAKC,IAAK,GAAE,KAAKC,eAAgB,EAA3C;AACD;;AAEa,MAAVC,UAAU,GAAG;AACf,WAAO,KAAP;AACD;;AAE6B,MAA1BC,0BAA0B,GAAY;AACxC,UAAM,IAAIC,KAAJ,CAAU,yDAAV,CAAN;AACD;;AAEDC,EAAAA,WAAW,GAAG;AAAA;;AAAA,8CAhCY,KAgCZ;;AAAA,kCA/Be,IA+Bf;;AAAA;;AAAA,8CA7Be,KA6Bf;;AAAA,oCA5B2B,IA4B3B;;AAAA,6CA3B6B,IA2B7B;;AAAA;;AAAA;;AAAA,oCAxBa,EAwBb;;AAAA,2CAvBmBX,KAAK,CAACY,YAuBzB;;AAAA,6CAtBkC,EAsBlC;;AAAA,sCArBYZ,KAAK,CAACY,YAqBlB;;AAAA,2CApBwB,IAoBxB;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,gDAmCO,MAAM;AACzB,UAAIC,KAAK,CAACC,OAAN,CAAc,KAAKC,MAAL,CAAYC,OAA1B,CAAJ,EAAwC;AACtC,aAAK,MAAMC,OAAX,IAAsB,KAAKF,MAAL,CAAYC,OAAlC,EAA2C;AACzCC,UAAAA,OAAO,CAACC,oBAAR,CAA6B,KAAKb,EAAlC;AACD;AACF;AACF,KAzCa;;AAAA,qCA8DJ,MAAM;AAC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AK,CAACqE,SAAN,GAAkBnI,MAAM,CAACkI,OAAP,GAAkBlI,MAAM,CAACkI,OAA3C;AACD;;AACD,MAAI,aAAalI,MAAjB,EAAyB;AACvB8D,IAAAA,KAAK,CAAC7D,OAAN,GAAgBmI,OAAO,CAACpI,MAAM,CAACC,OAAR,CAAP,CACboI,GADa,CACT,CAAC;AAAExD,MAAAA;AAAF,KAAD,KACH1F,WAAW,CAACmJ,UAAZ,CAAuBzD,UAAvB,CAFY,EAIbkC,MAJa,CAILwB,CAAD,IAAOA,CAJD,CAAhB;AAKD,GAND,MAMO;AACLzE,IAAAA,KAAK,CAAC7D,OAAN,GAAgB,IAAhB;AACD;;AAED,QAAMuI,WAAW,GAAG,CAClB,aADkB,EAElB,aAFkB,EAGlB,SAHkB,EAIlB,SAJkB,EAKlB,WALkB,EAMlB,eANkB,EAOlB,WAPkB,EAQlB,aARkB,EASlB,kBATkB,EAUlB,kBAVkB,EAWlB,gBAXkB,EAYlB,gBAZkB,EAalB,oBAbkB,EAclB,kBAdkB,EAelB,oBAfkB,EAgBlB,kBAhBkB,CAApB;AAkBAA,EAAAA,WAAW,CAACC,OAAZ,CAAqBC,IAAD,IAAsC;AACxD,QAAI,OAAO5E,KAAK,CAAC4E,IAAD,CAAZ,KAAuB,WAA3B,EAAwC;AACtC5E,MAAAA,KAAK,CAAC4E,IAAD,CAAL,GAAcC,MAAM,CAACC,GAArB;AACD;AACF,GAJD;AAKA,SAAO9E,KAAP,CAjDsD,CAiDpB;AACnC;;AAED,SAASsE,OAAT,CAAoBV,KAApB,EAAoC;AAClC;AACA,SAAOA,KAAK,IAAI,IAAT,GAAgB,EAAhB,GAAqB5H,KAAK,CAACC,OAAN,CAAc2H,KAAd,IAAuBA,KAAvB,GAA+B,CAACA,KAAD,CAA3D;AACD;;AAED,eAAerI,cAAf","sourcesContent":["/* eslint-disable eslint-comments/no-unlimited-disable */\n/* eslint-disable */\nimport Hammer from '@egjs/hammerjs';\nimport { findNodeHandle } from 'react-native';\n\nimport { State } from '../State';\nimport { EventMap } from './constants';\nimport * as NodeManager from './NodeManager';\n\n// TODO(TS) Replace with HammerInput if https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438/files is merged\nexport type HammerInputExt = Omit<HammerInput, 'destroy' | 'handler' | 'init'>;\n\nexport type Config = Partial<{\n enabled: boolean;\n minPointers: number;\n maxPointers: number;\n minDist: number;\n minDistSq: number;\n minVelocity: number;\n minVelocitySq: number;\n maxDist: number;\n maxDistSq: number;\n failOffsetXStart: number;\n failOffsetYStart: number;\n failOffsetXEnd: number;\n failOffsetYEnd: number;\n activeOffsetXStart: number;\n activeOffsetXEnd: number;\n activeOffsetYStart: number;\n activeOffsetYEnd: number;\n waitFor: any[] | null;\n}>;\n\ntype NativeEvent = ReturnType<GestureHandler['transformEventData']>;\n\nlet gestureInstances = 0;\n\nabstract class GestureHandler {\n public handlerTag: any;\n public isGestureRunning = false;\n public view: number | null = null;\n protected hasCustomActivationCriteria: boolean;\n protected hasGestureFailed = false;\n protected hammer: HammerManager | null = null;\n protected initialRotation: number | null = null;\n protected __initialX: any;\n protected __initialY: any;\n protected config: Config = {};\n protected previousState: State = State.UNDETERMINED;\n private pendingGestures: Record<string, this> = {};\n private oldState: State = State.UNDETERMINED;\n private lastSentState: State | null = null;\n private gestureInstance: number;\n private _stillWaiting: any;\n private propsRef: any;\n private ref: any;\n\n abstract get name(): string;\n\n get id() {\n return `${this.name}${this.gestureInstance}`;\n }\n\n get isDiscrete() {\n return false;\n }\n\n get shouldEnableGestureOnSetup(): boolean {\n throw new Error('Must override GestureHandler.shouldEnableGestureOnSetup');\n }\n\n constructor() {\n this.gestureInstance = gestureInstances++;\n this.hasCustomActivationCriteria = false;\n }\n\n getConfig() {\n return this.config;\n }\n\n onWaitingEnded(_gesture: this) {}\n\n removePendingGesture(id: string) {\n delete this.pendingGestures[id];\n }\n\n addPendingGesture(gesture: this) {\n this.pendingGestures[gesture.id] = gesture;\n }\n\n isGestureEnabledForEvent(\n _config: any,\n _recognizer: any,\n _event: any\n ): { failed?: boolean; success?: boolean } {\n return { success: true };\n }\n\n get NativeGestureClass(): RecognizerStatic {\n throw new Error('Must override GestureHandler.NativeGestureClass');\n }\n\n updateHasCustomActivationCriteria(_config: Config) {\n return true;\n }\n\n clearSelfAsPending = () => {\n if (Array.isArray(this.config.waitFor)) {\n for (const gesture of this.config.waitFor) {\n gesture.removePendingGesture(this.id);\n }\n }\n };\n\n updateGestureConfig({ enabled = true, ...props }) {\n this.clearSelfAsPending();\n\n this.config = ensureConfig({ enabled, ...props });\n this.hasCustomActivationCriteria = this.updateHasCustomActivationCriteria(\n this.config\n );\n if (Array.isArray(this.config.waitFor)) {\n for (const gesture of this.config.waitFor) {\n gesture.addPendingGesture(this);\n }\n }\n\n if (this.hammer) {\n this.sync();\n }\n return this.config;\n }\n\n destroy = () => {\n this.clearSelfAsPending();\n\n if (this.hammer) {\n this.hammer.stop(false);\n this.hammer.destroy();\n }\n this.hammer = null;\n };\n\n isPointInView = ({ x, y }: { x: number; y: number }) => {\n // @ts-ignore FIXME(TS)\n const rect = this.view!.getBoundingClientRect();\n const pointerInside =\n x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n return pointerInside;\n };\n\n getState(type: keyof typeof EventMap): State {\n // @ts-ignore TODO(TS) check if this is needed\n if (type == 0) {\n return 0;\n }\n return EventMap[type];\n }\n\n transformEventData(event: HammerInputExt) {\n const { eventType, maxPointers: numberOfPointers } = event;\n // const direction = DirectionMap[ev.direction];\n const changedTouch = event.changedPointers[0];\n const pointerInside = this.isPointInView({\n x: changedTouch.clientX,\n y: changedTouch.clientY,\n });\n\n // TODO(TS) Remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50966 is merged.\n const state = this.getState(eventType as 1 | 2 | 4 | 8);\n if (state !== this.previousState) {\n this.oldState = this.previousState;\n this.previousState = state;\n }\n\n return {\n nativeEvent: {\n numberOfPointers,\n state,\n pointerInside,\n ...this.transformNativeEvent(event),\n // onHandlerStateChange only\n handlerTag: this.handlerTag,\n target: this.ref,\n // send oldState only when the state was changed, or is different than ACTIVE\n // GestureDetector relies on the presence of `oldState` to differentiate between\n // update events and state change events\n oldState:\n state !== this.previousState || state != 4\n ? this.oldState\n : undefined,\n },\n timeStamp: Date.now(),\n };\n }\n\n transformNativeEvent(_event: HammerInputExt) {\n return {};\n }\n\n sendEvent = (nativeEvent: HammerInputExt) => {\n const {\n onGestureHandlerEvent,\n onGestureHandlerStateChange,\n } = this.propsRef.current;\n\n const event = this.transformEventData(nativeEvent);\n\n invokeNullableMethod(onGestureHandlerEvent, event);\n if (this.lastSentState !== event.nativeEvent.state) {\n this.lastSentState = event.nativeEvent.state as State;\n invokeNullableMethod(onGestureHandlerStateChange, event);\n }\n };\n\n cancelPendingGestures(event: HammerInputExt) {\n for (const gesture of Object.values(this.pendingGestures)) {\n if (gesture && gesture.isGestureRunning) {\n gesture.hasGestureFailed = true;\n gesture.cancelEvent(event);\n }\n }\n }\n\n notifyPendingGestures() {\n for (const gesture of Object.values(this.pendingGestures)) {\n if (gesture) {\n gesture.onWaitingEnded(this);\n }\n }\n }\n\n // FIXME event is undefined in runtime when firstly invoked (see Draggable example), check other functions taking event as input\n onGestureEnded(event: HammerInputExt) {\n this.isGestureRunning = false;\n this.cancelPendingGestures(event);\n }\n\n forceInvalidate(event: HammerInputExt) {\n if (this.isGestureRunning) {\n this.hasGestureFailed = true;\n this.cancelEvent(event);\n }\n }\n\n cancelEvent(event: HammerInputExt) {\n this.notifyPendingGestures();\n this.sendEvent({\n ...event,\n eventType: Hammer.INPUT_CANCEL,\n isFinal: true,\n });\n this.onGestureEnded(event);\n }\n\n onRawEvent({ isFirst }: HammerInputExt) {\n if (isFirst) {\n this.hasGestureFailed = false;\n }\n }\n\n setView(ref: Parameters<typeof findNodeHandle>['0'], propsRef: any) {\n if (ref == null) {\n this.destroy();\n this.view = null;\n return;\n }\n\n this.propsRef = propsRef;\n this.ref = ref;\n\n this.view = findNodeHandle(ref);\n this.hammer = new Hammer.Manager(this.view as any);\n\n this.oldState = State.UNDETERMINED;\n this.previousState = State.UNDETERMINED;\n this.lastSentState = null;\n\n const { NativeGestureClass } = this;\n // @ts-ignore TODO(TS)\n const gesture = new NativeGestureClass(this.getHammerConfig());\n this.hammer.add(gesture);\n\n this.hammer.on('hammer.input', (ev: HammerInput) => {\n if (!this.config.enabled) {\n this.hasGestureFailed = false;\n this.isGestureRunning = false;\n return;\n }\n\n this.onRawEvent((ev as unknown) as HammerInputExt);\n\n // TODO: Bacon: Check against something other than null\n // The isFirst value is not called when the first rotation is calculated.\n if (this.initialRotation === null && ev.rotation !== 0) {\n this.initialRotation = ev.rotation;\n }\n if (ev.isFinal) {\n // in favor of a willFail otherwise the last frame of the gesture will be captured.\n setTimeout(() => {\n this.initialRotation = null;\n this.hasGestureFailed = false;\n });\n }\n });\n\n this.setupEvents();\n this.sync();\n }\n\n setupEvents() {\n // TODO(TS) Hammer types aren't exactly that what we get in runtime\n if (!this.isDiscrete) {\n this.hammer!.on(`${this.name}start`, (event: HammerInput) =>\n this.onStart((event as unknown) as HammerInputExt)\n );\n this.hammer!.on(\n `${this.name}end ${this.name}cancel`,\n (event: HammerInput) => {\n this.onGestureEnded((event as unknown) as HammerInputExt);\n }\n );\n }\n this.hammer!.on(this.name, (ev: HammerInput) =>\n this.onGestureActivated((ev as unknown) as HammerInputExt)\n ); // TODO(TS) remove cast after https://github.com/DefinitelyTyped/DefinitelyTyped/pull/50438 is merged\n }\n\n onStart({ deltaX, deltaY, rotation }: HammerInputExt) {\n // Reset the state for the next gesture\n this.oldState = State.UNDETERMINED;\n this.previousState = State.UNDETERMINED;\n this.lastSentState = null;\n\n this.isGestureRunning = true;\n this.__initialX = deltaX;\n this.__initialY = deltaY;\n this.initialRotation = rotation;\n }\n\n onGestureActivated(ev: HammerInputExt) {\n this.sendEvent(ev);\n }\n\n onSuccess() {}\n\n _getPendingGestures() {\n if (Array.isArray(this.config.waitFor) && this.config.waitFor.length) {\n // Get the list of gestures that this gesture is still waiting for.\n // Use `=== false` in case a ref that isn't a gesture handler is used.\n const stillWaiting = this.config.waitFor.filter(\n ({ hasGestureFailed }) => hasGestureFailed === false\n );\n return stillWaiting;\n }\n return [];\n }\n\n getHammerConfig() {\n const pointers =\n this.config.minPointers === this.config.maxPointers\n ? this.config.minPointers\n : 0;\n return {\n pointers,\n };\n }\n\n sync = () => {\n const gesture = this.hammer!.get(this.name);\n if (!gesture) return;\n\n const enable = (recognizer: any, inputData: any) => {\n if (!this.config.enabled) {\n this.isGestureRunning = false;\n this.hasGestureFailed = false;\n return false;\n }\n\n // Prevent events before the system is ready.\n if (\n !inputData ||\n !recognizer.options ||\n typeof inputData.maxPointers === 'undefined'\n ) {\n return this.shouldEnableGestureOnSetup;\n }\n\n if (this.hasGestureFailed) {\n return false;\n }\n\n if (!this.isDiscrete) {\n if (this.isGestureRunning) {\n return true;\n }\n // The built-in hammer.js \"waitFor\" doesn't work across multiple views.\n // Only process if there are views to wait for.\n this._stillWaiting = this._getPendingGestures();\n // This gesture should continue waiting.\n if (this._stillWaiting.length) {\n // Check to see if one of the gestures you're waiting for has started.\n // If it has then the gesture should fail.\n for (const gesture of this._stillWaiting) {\n // When the target gesture has started, this gesture must force fail.\n if (!gesture.isDiscrete && gesture.isGestureRunning) {\n this.hasGestureFailed = true;\n this.isGestureRunning = false;\n return false;\n }\n }\n // This gesture shouldn't start until the others have finished.\n return false;\n }\n }\n\n // Use default behaviour\n if (!this.hasCustomActivationCriteria) {\n return true;\n }\n\n const deltaRotation =\n this.initialRotation == null\n ? 0\n : inputData.rotation - this.initialRotation;\n // @ts-ignore FIXME(TS)\n const { success, failed } = this.isGestureEnabledForEvent(\n this.getConfig(),\n recognizer,\n {\n ...inputData,\n deltaRotation,\n }\n );\n\n if (failed) {\n this.simulateCancelEvent(inputData);\n this.hasGestureFailed = true;\n }\n return success;\n };\n\n const params = this.getHammerConfig();\n // @ts-ignore FIXME(TS)\n gesture.set({ ...params, enable });\n };\n\n simulateCancelEvent(_inputData: any) {}\n}\n\n// TODO(TS) investigate this method\n// Used for sending data to a callback or AnimatedEvent\nfunction invokeNullableMethod(\n method:\n | ((event: NativeEvent) => void)\n | { __getHandler: () => (event: NativeEvent) => void }\n | { __nodeConfig: { argMapping: any } },\n event: NativeEvent\n) {\n if (method) {\n if (typeof method === 'function') {\n method(event);\n } else {\n // For use with reanimated's AnimatedEvent\n if (\n '__getHandler' in method &&\n typeof method.__getHandler === 'function'\n ) {\n const handler = method.__getHandler();\n invokeNullableMethod(handler, event);\n } else {\n if ('__nodeConfig' in method) {\n const { argMapping } = method.__nodeConfig;\n if (Array.isArray(argMapping)) {\n for (const [index, [key, value]] of argMapping.entries()) {\n if (key in event.nativeEvent) {\n // @ts-ignore fix method type\n const nativeValue = event.nativeEvent[key];\n if (value && value.setValue) {\n // Reanimated API\n value.setValue(nativeValue);\n } else {\n // RN Animated API\n method.__nodeConfig.argMapping[index] = [key, nativeValue];\n }\n }\n }\n }\n }\n }\n }\n }\n}\n\n// Validate the props\nfunction ensureConfig(config: Config): Required<Config> {\n const props = { ...config };\n\n // TODO(TS) We use ! to assert that if property is present then value is not empty (null, undefined)\n if ('minDist' in config) {\n props.minDist = config.minDist;\n props.minDistSq = props.minDist! * props.minDist!;\n }\n if ('minVelocity' in config) {\n props.minVelocity = config.minVelocity;\n props.minVelocitySq = props.minVelocity! * props.minVelocity!;\n }\n if ('maxDist' in config) {\n props.maxDist = config.maxDist;\n props.maxDistSq = config.maxDist! * config.maxDist!;\n }\n if ('waitFor' in config) {\n props.waitFor = asArray(config.waitFor)\n .map(({ handlerTag }: { handlerTag: number }) =>\n NodeManager.getHandler(handlerTag)\n )\n .filter((v) => v);\n } else {\n props.waitFor = null;\n }\n\n const configProps = [\n 'minPointers',\n 'maxPointers',\n 'minDist',\n 'maxDist',\n 'maxDistSq',\n 'minVelocitySq',\n 'minDistSq',\n 'minVelocity',\n 'failOffsetXStart',\n 'failOffsetYStart',\n 'failOffsetXEnd',\n 'failOffsetYEnd',\n 'activeOffsetXStart',\n 'activeOffsetXEnd',\n 'activeOffsetYStart',\n 'activeOffsetYEnd',\n ] as const;\n configProps.forEach((prop: typeof configProps[number]) => {\n if (typeof props[prop] === 'undefined') {\n props[prop] = Number.NaN;\n }\n });\n return props as Required<Config>; // TODO(TS) how to convince TS that props are filled?\n}\n\nfunction asArray<T>(value: T | T[]) {\n // TODO(TS) use config.waitFor type\n return value == null ? [] : Array.isArray(value) ? value : [value];\n}\n\nexport default GestureHandler;\n"]}
|
@@ -16,7 +16,7 @@ export declare type LongPressGestureHandlerEventPayload = {
|
|
16
16
|
/**
|
17
17
|
* X coordinate, expressed in points, of the current position of the pointer
|
18
18
|
* (finger or a leading pointer when there are multiple fingers placed)
|
19
|
-
* relative to the
|
19
|
+
* relative to the window. It is recommended to use `absoluteX` instead of
|
20
20
|
* `x` in cases when the view attached to the handler can be transformed as an
|
21
21
|
* effect of the gesture.
|
22
22
|
*/
|
@@ -24,7 +24,7 @@ export declare type LongPressGestureHandlerEventPayload = {
|
|
24
24
|
/**
|
25
25
|
* Y coordinate, expressed in points, of the current position of the pointer
|
26
26
|
* (finger or a leading pointer when there are multiple fingers placed)
|
27
|
-
* relative to the
|
27
|
+
* relative to the window. It is recommended to use `absoluteY` instead of
|
28
28
|
* `y` in cases when the view attached to the handler can be transformed as an
|
29
29
|
* effect of the gesture.
|
30
30
|
*/
|
@@ -16,7 +16,7 @@ export declare type PanGestureHandlerEventPayload = {
|
|
16
16
|
y: number;
|
17
17
|
/**
|
18
18
|
* X coordinate of the current position of the pointer (finger or a leading
|
19
|
-
* pointer when there are multiple fingers placed) relative to the
|
19
|
+
* pointer when there are multiple fingers placed) relative to the window.
|
20
20
|
* The value is expressed in point units. It is recommended to use it instead
|
21
21
|
* of `x` in cases when the original view can be transformed as an effect of
|
22
22
|
* the gesture.
|
@@ -24,7 +24,7 @@ export declare type PanGestureHandlerEventPayload = {
|
|
24
24
|
absoluteX: number;
|
25
25
|
/**
|
26
26
|
* Y coordinate of the current position of the pointer (finger or a leading
|
27
|
-
* pointer when there are multiple fingers placed) relative to the
|
27
|
+
* pointer when there are multiple fingers placed) relative to the window.
|
28
28
|
* The value is expressed in point units. It is recommended to use it instead
|
29
29
|
* of `y` in cases when the original view can be transformed as an
|
30
30
|
* effect of the gesture.
|
@@ -1,2 +1,4 @@
|
|
1
|
+
import { GestureTouchEvent, GestureUpdateEvent, GestureStateChangeEvent } from '../gestureHandlerCommon';
|
2
|
+
export declare function onGestureHandlerEvent(event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent): void;
|
1
3
|
export declare function startListening(): void;
|
2
4
|
export declare function stopListening(): void;
|
@@ -22,17 +22,17 @@ export { default as createNativeWrapper } from './handlers/createNativeWrapper';
|
|
22
22
|
export type { NativeViewGestureHandlerPayload, NativeViewGestureHandlerProps, } from './handlers/NativeViewGestureHandler';
|
23
23
|
export { GestureDetector } from './handlers/gestures/GestureDetector';
|
24
24
|
export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';
|
25
|
-
export { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';
|
26
|
-
export { PanGestureType as PanGesture } from './handlers/gestures/panGesture';
|
27
|
-
export { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';
|
28
|
-
export { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';
|
29
|
-
export { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';
|
30
|
-
export { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';
|
31
|
-
export { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';
|
32
|
-
export { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';
|
33
|
-
export { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';
|
34
|
-
export { ComposedGestureType as ComposedGesture, RaceGestureType as RaceGesture, SimultaneousGestureType as SimultaneousGesture, ExclusiveGestureType as ExclusiveGesture, } from './handlers/gestures/gestureComposition';
|
35
|
-
export { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';
|
25
|
+
export type { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';
|
26
|
+
export type { PanGestureType as PanGesture } from './handlers/gestures/panGesture';
|
27
|
+
export type { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';
|
28
|
+
export type { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';
|
29
|
+
export type { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';
|
30
|
+
export type { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';
|
31
|
+
export type { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';
|
32
|
+
export type { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';
|
33
|
+
export type { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';
|
34
|
+
export type { ComposedGestureType as ComposedGesture, RaceGestureType as RaceGesture, SimultaneousGestureType as SimultaneousGesture, ExclusiveGestureType as ExclusiveGesture, } from './handlers/gestures/gestureComposition';
|
35
|
+
export type { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';
|
36
36
|
export { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler';
|
37
37
|
export type { RawButtonProps, BaseButtonProps, RectButtonProps, BorderlessButtonProps, } from './components/GestureButtons';
|
38
38
|
export { RawButton, BaseButton, RectButton, BorderlessButton, } from './components/GestureButtons';
|
package/package.json
CHANGED
@@ -27,7 +27,7 @@ export type LongPressGestureHandlerEventPayload = {
|
|
27
27
|
/**
|
28
28
|
* X coordinate, expressed in points, of the current position of the pointer
|
29
29
|
* (finger or a leading pointer when there are multiple fingers placed)
|
30
|
-
* relative to the
|
30
|
+
* relative to the window. It is recommended to use `absoluteX` instead of
|
31
31
|
* `x` in cases when the view attached to the handler can be transformed as an
|
32
32
|
* effect of the gesture.
|
33
33
|
*/
|
@@ -36,7 +36,7 @@ export type LongPressGestureHandlerEventPayload = {
|
|
36
36
|
/**
|
37
37
|
* Y coordinate, expressed in points, of the current position of the pointer
|
38
38
|
* (finger or a leading pointer when there are multiple fingers placed)
|
39
|
-
* relative to the
|
39
|
+
* relative to the window. It is recommended to use `absoluteY` instead of
|
40
40
|
* `y` in cases when the view attached to the handler can be transformed as an
|
41
41
|
* effect of the gesture.
|
42
42
|
*/
|
@@ -47,7 +47,7 @@ export type PanGestureHandlerEventPayload = {
|
|
47
47
|
|
48
48
|
/**
|
49
49
|
* X coordinate of the current position of the pointer (finger or a leading
|
50
|
-
* pointer when there are multiple fingers placed) relative to the
|
50
|
+
* pointer when there are multiple fingers placed) relative to the window.
|
51
51
|
* The value is expressed in point units. It is recommended to use it instead
|
52
52
|
* of `x` in cases when the original view can be transformed as an effect of
|
53
53
|
* the gesture.
|
@@ -56,7 +56,7 @@ export type PanGestureHandlerEventPayload = {
|
|
56
56
|
|
57
57
|
/**
|
58
58
|
* Y coordinate of the current position of the pointer (finger or a leading
|
59
|
-
* pointer when there are multiple fingers placed) relative to the
|
59
|
+
* pointer when there are multiple fingers placed) relative to the window.
|
60
60
|
* The value is expressed in point units. It is recommended to use it instead
|
61
61
|
* of `y` in cases when the original view can be transformed as an
|
62
62
|
* effect of the gesture.
|
@@ -16,6 +16,7 @@ import {
|
|
16
16
|
GestureTouchEvent,
|
17
17
|
GestureUpdateEvent,
|
18
18
|
GestureStateChangeEvent,
|
19
|
+
HandlerStateChangeEvent,
|
19
20
|
} from '../gestureHandlerCommon';
|
20
21
|
import {
|
21
22
|
GestureStateManager,
|
@@ -32,6 +33,9 @@ import { tapGestureHandlerProps } from '../TapGestureHandler';
|
|
32
33
|
import { State } from '../../State';
|
33
34
|
import { EventType } from '../../EventType';
|
34
35
|
import { ComposedGesture } from './gestureComposition';
|
36
|
+
import { Platform } from 'react-native';
|
37
|
+
import type RNGestureHandlerModuleWeb from '../../RNGestureHandlerModule.web';
|
38
|
+
import { onGestureHandlerEvent } from './eventReceiver';
|
35
39
|
|
36
40
|
const ALLOWED_PROPS = [
|
37
41
|
...baseGestureHandlerWithMonitorProps,
|
@@ -79,12 +83,17 @@ function dropHandlers(preparedGesture: GestureConfigReference) {
|
|
79
83
|
}
|
80
84
|
}
|
81
85
|
|
86
|
+
interface WebEventHandler {
|
87
|
+
onGestureHandlerEvent: (event: HandlerStateChangeEvent<unknown>) => void;
|
88
|
+
}
|
89
|
+
|
82
90
|
interface AttachHandlersConfig {
|
83
91
|
preparedGesture: GestureConfigReference;
|
84
92
|
gestureConfig: ComposedGesture | GestureType | undefined;
|
85
93
|
gesture: GestureType[];
|
86
94
|
viewTag: number;
|
87
95
|
useAnimated: boolean;
|
96
|
+
webEventHandlersRef: React.RefObject<WebEventHandler>;
|
88
97
|
}
|
89
98
|
|
90
99
|
function attachHandlers({
|
@@ -93,6 +102,7 @@ function attachHandlers({
|
|
93
102
|
gesture,
|
94
103
|
viewTag,
|
95
104
|
useAnimated,
|
105
|
+
webEventHandlersRef,
|
96
106
|
}: AttachHandlersConfig) {
|
97
107
|
if (!preparedGesture.firstExecution) {
|
98
108
|
gestureConfig?.initialize();
|
@@ -142,11 +152,20 @@ function attachHandlers({
|
|
142
152
|
preparedGesture.config = gesture;
|
143
153
|
|
144
154
|
for (const gesture of preparedGesture.config) {
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
155
|
+
if (Platform.OS === 'web') {
|
156
|
+
(RNGestureHandlerModule.attachGestureHandler as typeof RNGestureHandlerModuleWeb.attachGestureHandler)(
|
157
|
+
gesture.handlerTag,
|
158
|
+
viewTag,
|
159
|
+
!useAnimated, // send direct events when using animatedGesture, device events otherwise
|
160
|
+
webEventHandlersRef
|
161
|
+
);
|
162
|
+
} else {
|
163
|
+
RNGestureHandlerModule.attachGestureHandler(
|
164
|
+
gesture.handlerTag,
|
165
|
+
viewTag,
|
166
|
+
!useAnimated // send direct events when using animatedGesture, device events otherwise
|
167
|
+
);
|
168
|
+
}
|
150
169
|
}
|
151
170
|
|
152
171
|
if (preparedGesture.animatedHandlers) {
|
@@ -166,8 +185,12 @@ function updateHandlers(
|
|
166
185
|
for (let i = 0; i < gesture.length; i++) {
|
167
186
|
const handler = preparedGesture.config[i];
|
168
187
|
|
169
|
-
|
170
|
-
gesture
|
188
|
+
// only update handlerTag when it's actually different, it may be the same
|
189
|
+
// if gesture config object is wrapped with useMemo
|
190
|
+
if (gesture[i].handlerTag !== handler.handlerTag) {
|
191
|
+
gesture[i].handlerTag = handler.handlerTag;
|
192
|
+
gesture[i].handlers.handlerTag = handler.handlerTag;
|
193
|
+
}
|
171
194
|
}
|
172
195
|
|
173
196
|
// use setImmediate to extract handlerTags, because when it's ran, all refs should be updated
|
@@ -179,7 +202,6 @@ function updateHandlers(
|
|
179
202
|
|
180
203
|
handler.config = gesture[i].config;
|
181
204
|
handler.handlers = gesture[i].handlers;
|
182
|
-
handler.handlers.handlerTag = handler.handlerTag;
|
183
205
|
|
184
206
|
const requireToFail = extractValidHandlerTags(
|
185
207
|
handler.config.requireToFail
|
@@ -224,7 +246,10 @@ function needsToReattach(
|
|
224
246
|
return false;
|
225
247
|
}
|
226
248
|
|
227
|
-
function useAnimatedGesture(
|
249
|
+
function useAnimatedGesture(
|
250
|
+
preparedGesture: GestureConfigReference,
|
251
|
+
needsRebuild: boolean
|
252
|
+
) {
|
228
253
|
if (!Reanimated) {
|
229
254
|
return;
|
230
255
|
}
|
@@ -401,7 +426,7 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
401
426
|
const event = Reanimated.useEvent(
|
402
427
|
callback,
|
403
428
|
['onGestureHandlerStateChange', 'onGestureHandlerEvent'],
|
404
|
-
|
429
|
+
needsRebuild
|
405
430
|
);
|
406
431
|
|
407
432
|
preparedGesture.animatedEventHandler = event;
|
@@ -422,6 +447,11 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
422
447
|
) != null;
|
423
448
|
const viewRef = useRef(null);
|
424
449
|
const firstRenderRef = useRef(true);
|
450
|
+
const webEventHandlersRef = useRef<WebEventHandler>({
|
451
|
+
onGestureHandlerEvent: (e: HandlerStateChangeEvent<unknown>) => {
|
452
|
+
onGestureHandlerEvent(e.nativeEvent);
|
453
|
+
},
|
454
|
+
});
|
425
455
|
|
426
456
|
const preparedGesture = React.useRef<GestureConfigReference>({
|
427
457
|
config: gesture,
|
@@ -437,6 +467,11 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
437
467
|
);
|
438
468
|
}
|
439
469
|
|
470
|
+
// Reanimated event should be rebuilt only when gestures are reattached, otherwise
|
471
|
+
// config update will be enough as all necessary items are stored in shared values anyway
|
472
|
+
const needsToRebuildReanimatedEvent =
|
473
|
+
preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture);
|
474
|
+
|
440
475
|
if (preparedGesture.firstExecution) {
|
441
476
|
gestureConfig?.initialize?.();
|
442
477
|
}
|
@@ -445,7 +480,7 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
445
480
|
// Whether animatedGesture or gesture is used shouldn't change
|
446
481
|
// during while an app is running
|
447
482
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
448
|
-
useAnimatedGesture(preparedGesture);
|
483
|
+
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
|
449
484
|
}
|
450
485
|
|
451
486
|
useEffect(() => {
|
@@ -457,6 +492,7 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
457
492
|
gesture,
|
458
493
|
viewTag,
|
459
494
|
useAnimated,
|
495
|
+
webEventHandlersRef,
|
460
496
|
});
|
461
497
|
|
462
498
|
return () => {
|
@@ -476,6 +512,7 @@ export const GestureDetector: React.FunctionComponent<GestureDetectorProps> = (
|
|
476
512
|
gesture,
|
477
513
|
viewTag,
|
478
514
|
useAnimated,
|
515
|
+
webEventHandlersRef,
|
479
516
|
});
|
480
517
|
} else {
|
481
518
|
updateHandlers(preparedGesture, gestureConfig, gesture);
|
@@ -51,7 +51,7 @@ function isTouchEvent(
|
|
51
51
|
return event.eventType != null;
|
52
52
|
}
|
53
53
|
|
54
|
-
function onGestureHandlerEvent(
|
54
|
+
export function onGestureHandlerEvent(
|
55
55
|
event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent
|
56
56
|
) {
|
57
57
|
const handler = findHandler(event.handlerTag) as BaseGesture<
|
package/src/index.ts
CHANGED
@@ -61,22 +61,22 @@ export type {
|
|
61
61
|
} from './handlers/NativeViewGestureHandler';
|
62
62
|
export { GestureDetector } from './handlers/gestures/GestureDetector';
|
63
63
|
export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';
|
64
|
-
export { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';
|
65
|
-
export { PanGestureType as PanGesture } from './handlers/gestures/panGesture';
|
66
|
-
export { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';
|
67
|
-
export { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';
|
68
|
-
export { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';
|
69
|
-
export { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';
|
70
|
-
export { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';
|
71
|
-
export { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';
|
72
|
-
export { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';
|
73
|
-
export {
|
64
|
+
export type { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';
|
65
|
+
export type { PanGestureType as PanGesture } from './handlers/gestures/panGesture';
|
66
|
+
export type { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';
|
67
|
+
export type { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';
|
68
|
+
export type { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';
|
69
|
+
export type { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';
|
70
|
+
export type { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';
|
71
|
+
export type { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';
|
72
|
+
export type { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';
|
73
|
+
export type {
|
74
74
|
ComposedGestureType as ComposedGesture,
|
75
75
|
RaceGestureType as RaceGesture,
|
76
76
|
SimultaneousGestureType as SimultaneousGesture,
|
77
77
|
ExclusiveGestureType as ExclusiveGesture,
|
78
78
|
} from './handlers/gestures/gestureComposition';
|
79
|
-
export { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';
|
79
|
+
export type { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';
|
80
80
|
export { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler';
|
81
81
|
export type {
|
82
82
|
RawButtonProps,
|
@@ -182,7 +182,13 @@ abstract class GestureHandler {
|
|
182
182
|
// onHandlerStateChange only
|
183
183
|
handlerTag: this.handlerTag,
|
184
184
|
target: this.ref,
|
185
|
-
oldState
|
185
|
+
// send oldState only when the state was changed, or is different than ACTIVE
|
186
|
+
// GestureDetector relies on the presence of `oldState` to differentiate between
|
187
|
+
// update events and state change events
|
188
|
+
oldState:
|
189
|
+
state !== this.previousState || state != 4
|
190
|
+
? this.oldState
|
191
|
+
: undefined,
|
186
192
|
},
|
187
193
|
timeStamp: Date.now(),
|
188
194
|
};
|