react-native-gesture-handler 2.4.2 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +9 -5
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandlerOrchestrator.kt +6 -1
- package/android/lib/src/main/java/com/swmansion/gesturehandler/NativeViewGestureHandler.kt +103 -22
- package/android/lib/src/main/java/com/swmansion/gesturehandler/PanGestureHandler.kt +29 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt +74 -84
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +4 -0
- package/android/src/main/jni/Android.mk +1 -2
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.java +12 -9
- package/android/src/paper/java/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerInterface.java +1 -0
- package/ios/Handlers/RNFlingHandler.m +43 -1
- package/ios/Handlers/{RNNativeViewHandler.m → RNNativeViewHandler.mm} +13 -1
- package/ios/Handlers/RNPanHandler.m +27 -0
- package/ios/RNGestureHandler.h +1 -0
- package/ios/RNGestureHandler.m +22 -4
- package/ios/RNGestureHandlerManager.mm +10 -2
- package/ios/RNGestureHandlerModule.mm +4 -1
- package/ios/RNManualActivationRecognizer.m +10 -3
- package/ios/RNRootViewGestureRecognizer.m +12 -1
- package/lib/commonjs/RNGestureHandlerModule.macos.js +81 -0
- package/lib/commonjs/RNGestureHandlerModule.macos.js.map +1 -0
- package/lib/commonjs/components/GestureButtons.js.map +1 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js +4 -1
- package/lib/commonjs/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/commonjs/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js +1 -1
- package/lib/commonjs/handlers/PanGestureHandler.js.map +1 -1
- package/lib/commonjs/handlers/PressabilityDebugView.js +14 -0
- package/lib/commonjs/handlers/PressabilityDebugView.js.map +1 -0
- package/lib/commonjs/handlers/PressabilityDebugView.web.js +12 -0
- package/lib/commonjs/handlers/PressabilityDebugView.web.js.map +1 -0
- package/lib/commonjs/handlers/createHandler.js +6 -3
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gestureStateManager.js +13 -9
- package/lib/commonjs/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js +5 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/utils.js +6 -3
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/RNGestureHandlerModule.macos.js +57 -0
- package/lib/module/RNGestureHandlerModule.macos.js.map +1 -0
- package/lib/module/components/GestureButtons.js.map +1 -1
- package/lib/module/components/touchables/GenericTouchable.js +4 -1
- package/lib/module/components/touchables/GenericTouchable.js.map +1 -1
- package/lib/module/fabric/RNGestureHandlerButtonNativeComponent.js.map +1 -1
- package/lib/module/handlers/PanGestureHandler.js +1 -1
- package/lib/module/handlers/PanGestureHandler.js.map +1 -1
- package/lib/module/handlers/PressabilityDebugView.js +3 -0
- package/lib/module/handlers/PressabilityDebugView.js.map +1 -0
- package/lib/module/handlers/PressabilityDebugView.web.js +5 -0
- package/lib/module/handlers/PressabilityDebugView.web.js.map +1 -0
- package/lib/module/handlers/createHandler.js +6 -4
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestures/gestureStateManager.js +13 -9
- package/lib/module/handlers/gestures/gestureStateManager.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js +5 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/utils.js +2 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/RNGestureHandlerModule.macos.d.ts +34 -0
- package/lib/typescript/RNGestureHandlerModule.web.d.ts +1 -1
- package/lib/typescript/components/GestureButtons.d.ts +6 -0
- package/lib/typescript/fabric/RNGestureHandlerButtonNativeComponent.d.ts +1 -0
- package/lib/typescript/handlers/PanGestureHandler.d.ts +2 -1
- package/lib/typescript/handlers/PressabilityDebugView.d.ts +1 -0
- package/lib/typescript/handlers/PressabilityDebugView.web.d.ts +1 -0
- package/lib/typescript/handlers/gestures/panGesture.d.ts +1 -0
- package/lib/typescript/web/NodeManager.d.ts +2 -2
- package/package.json +1 -1
- package/src/RNGestureHandlerModule.macos.ts +62 -0
- package/src/components/GestureButtons.tsx +7 -0
- package/src/components/touchables/GenericTouchable.tsx +1 -0
- package/src/fabric/RNGestureHandlerButtonNativeComponent.ts +1 -0
- package/src/handlers/PanGestureHandler.ts +2 -0
- package/src/handlers/PressabilityDebugView.tsx +2 -0
- package/src/handlers/PressabilityDebugView.web.tsx +4 -0
- package/src/handlers/{createHandler.ts → createHandler.tsx} +7 -6
- package/src/handlers/gestures/gestureStateManager.ts +13 -8
- package/src/handlers/gestures/panGesture.ts +5 -0
- package/src/utils.ts +3 -1
- package/ios/RNGestureHandler.xcodeproj/project.xcworkspace/xcuserdata/jakubpiasecki.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/jakubpiasecki.xcuserdatad/xcschemes/xcschememanagement.plist +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["gestureStateManager.ts"],"names":["Reanimated","State","tagMessage","warningMessage","GestureStateManager","create","handlerTag","begin","
|
|
1
|
+
{"version":3,"sources":["gestureStateManager.ts"],"names":["Reanimated","State","tagMessage","warningMessage","REANIMATED_AVAILABLE","useSharedValue","undefined","setGestureState","GestureStateManager","create","handlerTag","begin","BEGAN","console","warn","activate","ACTIVE","fail","FAILED","end","END"],"mappings":"AAAA,SAASA,UAAT,QAA2B,qBAA3B;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,UAAT,QAA2B,aAA3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from './reanimatedWrapper';\nimport { State } from '../../State';\nimport { tagMessage } from '../../utils';\n\nexport interface GestureStateManagerType {\n begin: () => void;\n activate: () => void;\n fail: () => void;\n end: () => void;\n}\n\nconst warningMessage = tagMessage(\n 'react-native-reanimated is required in order to use synchronous state management'\n);\n\n// check if reanimated module is available, but look for useSharedValue as conditional\n// require of reanimated can sometimes return content of `utils.ts` file (?)\nconst REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined;\nconst setGestureState = Reanimated?.setGestureState;\n\nexport const GestureStateManager = {\n create(handlerTag: number): GestureStateManagerType {\n 'worklet';\n return {\n begin: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.BEGAN);\n } else {\n console.warn(warningMessage);\n }\n },\n\n activate: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.ACTIVE);\n } else {\n console.warn(warningMessage);\n }\n },\n\n fail: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.FAILED);\n } else {\n console.warn(warningMessage);\n }\n },\n\n end: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.END);\n } else {\n console.warn(warningMessage);\n }\n },\n };\n },\n};\n"]}
|
|
@@ -125,6 +125,11 @@ export class PanGesture extends ContinousBaseGesture {
|
|
|
125
125
|
return this;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
activateAfterLongPress(duration) {
|
|
129
|
+
this.config.activateAfterLongPress = duration;
|
|
130
|
+
return this;
|
|
131
|
+
}
|
|
132
|
+
|
|
128
133
|
onChange(callback) {
|
|
129
134
|
// @ts-ignore TS being overprotective, PanGestureHandlerEventPayload is Record
|
|
130
135
|
this.handlers.changeEventCalculator = changeEventCalculator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["panGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","changeX","translationX","changeY","translationY","PanGesture","constructor","handlerName","activeOffsetY","offset","Array","isArray","config","activeOffsetYStart","activeOffsetYEnd","activeOffsetX","activeOffsetXStart","activeOffsetXEnd","failOffsetY","failOffsetYStart","failOffsetYEnd","failOffsetX","failOffsetXStart","failOffsetXEnd","minPointers","maxPointers","minDistance","distance","minDist","minVelocity","velocity","minVelocityX","minVelocityY","averageTouches","value","avgTouches","enableTrackpadTwoFingerGesture","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;;AAYA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,YADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,YAAR,GAAuBJ,QAAQ,CAACI,YAD3B;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,YAAR,GAAuBN,QAAQ,CAACM;AAF3B,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMM,UAAN,SAAyBV,oBAAzB,CAGL;AAGAW,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAFwC,EAExC;;AAGZ,SAAKC,WAAL,GAAmB,mBAAnB;AACD;;AAEDC,EAAAA,aAAa,CAACC,MAAD,EAA4B;AACvC,QAAIC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAJ,EAA2B;AACzB,WAAKG,MAAL,CAAYC,kBAAZ,GAAiCJ,MAAM,CAAC,CAAD,CAAvC;AACA,WAAKG,MAAL,CAAYE,gBAAZ,GAA+BL,MAAM,CAAC,CAAD,CAArC;AACD,KAHD,MAGO,IAAIA,MA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sources":["panGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","changeX","translationX","changeY","translationY","PanGesture","constructor","handlerName","activeOffsetY","offset","Array","isArray","config","activeOffsetYStart","activeOffsetYEnd","activeOffsetX","activeOffsetXStart","activeOffsetXEnd","failOffsetY","failOffsetYStart","failOffsetYEnd","failOffsetX","failOffsetXStart","failOffsetXEnd","minPointers","maxPointers","minDistance","distance","minDist","minVelocity","velocity","minVelocityX","minVelocityY","averageTouches","value","avgTouches","enableTrackpadTwoFingerGesture","activateAfterLongPress","duration","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;;AAYA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,YADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,YAAR,GAAuBJ,QAAQ,CAACI,YAD3B;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,YAAR,GAAuBN,QAAQ,CAACM;AAF3B,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMM,UAAN,SAAyBV,oBAAzB,CAGL;AAGAW,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAFwC,EAExC;;AAGZ,SAAKC,WAAL,GAAmB,mBAAnB;AACD;;AAEDC,EAAAA,aAAa,CAACC,MAAD,EAA4B;AACvC,QAAIC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAJ,EAA2B;AACzB,WAAKG,MAAL,CAAYC,kBAAZ,GAAiCJ,MAAM,CAAC,CAAD,CAA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,IAAP;AACD;;AAEDG,EAAAA,sBAAsB,CAACC,QAAD,EAAmB;AACvC,SAAK1B,MAAL,CAAYyB,sBAAZ,GAAqCC,QAArC;AACA,WAAO,IAAP;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAc7C,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAM2C,QAAN,CAAeC,QAAf,CAAP;AACD;;AAhHD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\nimport {\n PanGestureConfig,\n PanGestureHandlerEventPayload,\n} from '../PanGestureHandler';\n\nexport type PanGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<PanGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<PanGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: PanGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.translationX,\n changeY: current.translationY,\n };\n } else {\n changePayload = {\n changeX: current.translationX - previous.translationX,\n changeY: current.translationY - previous.translationY,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class PanGesture extends ContinousBaseGesture<\n PanGestureHandlerEventPayload,\n PanGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & PanGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'PanGestureHandler';\n }\n\n activeOffsetY(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.activeOffsetYStart = offset[0];\n this.config.activeOffsetYEnd = offset[1];\n } else if (offset < 0) {\n this.config.activeOffsetYStart = offset;\n } else {\n this.config.activeOffsetYEnd = offset;\n }\n return this;\n }\n\n activeOffsetX(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.activeOffsetXStart = offset[0];\n this.config.activeOffsetXEnd = offset[1];\n } else if (offset < 0) {\n this.config.activeOffsetXStart = offset;\n } else {\n this.config.activeOffsetXEnd = offset;\n }\n return this;\n }\n\n failOffsetY(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.failOffsetYStart = offset[0];\n this.config.failOffsetYEnd = offset[1];\n } else if (offset < 0) {\n this.config.failOffsetYStart = offset;\n } else {\n this.config.failOffsetYEnd = offset;\n }\n return this;\n }\n\n failOffsetX(offset: number | number[]) {\n if (Array.isArray(offset)) {\n this.config.failOffsetXStart = offset[0];\n this.config.failOffsetXEnd = offset[1];\n } else if (offset < 0) {\n this.config.failOffsetXStart = offset;\n } else {\n this.config.failOffsetXEnd = offset;\n }\n return this;\n }\n\n minPointers(minPointers: number) {\n this.config.minPointers = minPointers;\n return this;\n }\n\n maxPointers(maxPointers: number) {\n this.config.maxPointers = maxPointers;\n return this;\n }\n\n minDistance(distance: number) {\n this.config.minDist = distance;\n return this;\n }\n\n minVelocity(velocity: number) {\n this.config.minVelocity = velocity;\n return this;\n }\n\n minVelocityX(velocity: number) {\n this.config.minVelocityX = velocity;\n return this;\n }\n\n minVelocityY(velocity: number) {\n this.config.minVelocityY = velocity;\n return this;\n }\n\n averageTouches(value: boolean) {\n this.config.avgTouches = value;\n return this;\n }\n\n enableTrackpadTwoFingerGesture(value: boolean) {\n this.config.enableTrackpadTwoFingerGesture = value;\n return this;\n }\n\n activateAfterLongPress(duration: number) {\n this.config.activateAfterLongPress = duration;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n PanGestureHandlerEventPayload & PanGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, PanGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type PanGestureType = InstanceType<typeof PanGesture>;\n"]}
|
package/lib/module/utils.js
CHANGED
package/lib/module/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["
|
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["pack","rnVersion","version","toArray","object","Array","isArray","withPrevAndCurrent","array","mapFn","previousArr","currentArr","transformedArr","forEach","current","i","previous","transformed","push","hasProperty","key","Object","prototype","hasOwnProperty","call","isJestEnv","global","process","env","JEST_WORKER_ID","tagMessage","msg","isFabric","nativeFabricUIManager","shouldUseCodegenNativeComponent","majorStr","minorStr","split","major","Number","parseInt","minor","isRemoteDebuggingEnabled","nativeCallSyncHook","__REMOTEDEV__"],"mappings":"AAAA,OAAOA,IAAP,MAAiB,2BAAjB;AAEA,MAAMC,SAAS,GAAGD,IAAI,CAACE,OAAvB;AAEA,OAAO,SAASC,OAAT,CAAoBC,MAApB,EAA0C;AAC/C,MAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,MAAd,CAAL,EAA4B;AAC1B,WAAO,CAACA,MAAD,CAAP;AACD;;AAED,SAAOA,MAAP;AACD;AAMD,OAAO,SAASG,kBAAT,CACLC,KADK,EAELC,KAFK,EAGU;AACf,QAAMC,WAAmC,GAAG,CAAC,IAAD,CAA5C;AACA,QAAMC,UAAU,GAAG,CAAC,GAAGH,KAAJ,CAAnB;AACA,QAAMI,cAA6B,GAAG,EAAtC;AACAD,EAAAA,UAAU,CAACE,OAAX,CAAmB,CAACC,OAAD,EAAUC,CAAV,KAAgB;AACjC,UAAMC,QAAQ,GAAGN,WAAW,CAACK,CAAD,CAA5B;AACA,UAAME,WAAW,GAAGR,KAAK,CAACO,QAAD,EAAWF,OAAX,CAAzB;AACAJ,IAAAA,WAAW,CAACQ,IAAZ,CAAiBD,WAAjB;AACAL,IAAAA,cAAc,CAACM,IAAf,CAAoBD,WAApB;AACD,GALD;AAMA,SAAOL,cAAP;AACD,C,CAED;;AACA,OAAO,SAASO,WAAT,CAAqBf,MAArB,EAAqCgB,GAArC,EAAkD;AACvD,SAAOC,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCpB,MAArC,EAA6CgB,GAA7C,CAAP;AACD;AAED,OAAO,SAASK,SAAT,GAA8B;AACnC;AACA,SAAON,WAAW,CAACO,MAAD,EAAS,SAAT,CAAX,IAAkC,CAAC,CAACC,OAAO,CAACC,GAAR,CAAYC,cAAvD;AACD;AAED,OAAO,SAASC,UAAT,CAAoBC,GAApB,EAAiC;AACtC,SAAQ,kCAAiCA,GAAI,EAA7C;AACD,C,CAED;AACA;;AACA,OAAO,SAASC,QAAT,GAA6B;AAAA;;AAClC;AACA,SAAO,CAAC,aAACN,MAAD,oCAAC,QAAQO,qBAAT,CAAR;AACD;AAED,OAAO,SAASC,+BAAT,GAAoD;AACzD,QAAM,CAACC,QAAD,EAAWC,QAAX,IAAuBnC,SAAS,CAACoC,KAAV,CAAgB,GAAhB,CAA7B;AACA,QAAMC,KAAK,GAAGC,MAAM,CAACC,QAAP,CAAgBL,QAAhB,CAAd;AACA,QAAMM,KAAK,GAAGF,MAAM,CAACC,QAAP,CAAgBJ,QAAhB,CAAd,CAHyD,CAKzD;;AACA,SAAOK,KAAK,IAAI,EAAT,IAAeH,KAAK,GAAG,CAA9B;AACD;AAED,OAAO,SAASI,wBAAT,GAA6C;AAClD;AACA;AACA,SAAO,CAAEhB,MAAD,CAAgBiB,kBAAjB,IAAwCjB,MAAD,CAAgBkB,aAA9D;AACD","sourcesContent":["import pack from 'react-native/package.json';\n\nconst rnVersion = pack.version;\n\nexport function toArray<T>(object: T | T[]): T[] {\n if (!Array.isArray(object)) {\n return [object];\n }\n\n return object;\n}\n\nexport type withPrevAndCurrentMapFn<T, Transformed> = (\n previous: Transformed | null,\n current: T\n) => Transformed;\nexport function withPrevAndCurrent<T, Transformed>(\n array: T[],\n mapFn: withPrevAndCurrentMapFn<T, Transformed>\n): Transformed[] {\n const previousArr: (null | Transformed)[] = [null];\n const currentArr = [...array];\n const transformedArr: Transformed[] = [];\n currentArr.forEach((current, i) => {\n const previous = previousArr[i];\n const transformed = mapFn(previous, current);\n previousArr.push(transformed);\n transformedArr.push(transformed);\n });\n return transformedArr;\n}\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasProperty(object: object, key: string) {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n\nexport function isJestEnv(): boolean {\n // @ts-ignore Do not use `@types/node` because it will prioritise Node types over RN types which breaks the types (ex. setTimeout) in React Native projects.\n return hasProperty(global, 'process') && !!process.env.JEST_WORKER_ID;\n}\n\nexport function tagMessage(msg: string) {\n return `[react-native-gesture-handler] ${msg}`;\n}\n\n// helper method to check whether Fabric is enabled, however global.nativeFabricUIManager\n// may not be initialized before the first render\nexport function isFabric(): boolean {\n // @ts-expect-error nativeFabricUIManager is not yet included in the RN types\n return !!global?.nativeFabricUIManager;\n}\n\nexport function shouldUseCodegenNativeComponent(): boolean {\n const [majorStr, minorStr] = rnVersion.split('.');\n const major = Number.parseInt(majorStr);\n const minor = Number.parseInt(minorStr);\n\n // use codegenNativeComponent starting with RN 0.68\n return minor >= 68 || major > 0;\n}\n\nexport function isRemoteDebuggingEnabled(): boolean {\n // react-native-reanimated checks if in remote debugging in the same way\n // @ts-ignore global is available but node types are not included\n return !(global as any).nativeCallSyncHook || (global as any).__REMOTEDEV__;\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ActionType } from './ActionType';
|
|
2
|
+
import FlingGestureHandler from './web/FlingGestureHandler';
|
|
3
|
+
import LongPressGestureHandler from './web/LongPressGestureHandler';
|
|
4
|
+
import NativeViewGestureHandler from './web/NativeViewGestureHandler';
|
|
5
|
+
import PanGestureHandler from './web/PanGestureHandler';
|
|
6
|
+
import PinchGestureHandler from './web/PinchGestureHandler';
|
|
7
|
+
import RotationGestureHandler from './web/RotationGestureHandler';
|
|
8
|
+
import TapGestureHandler from './web/TapGestureHandler';
|
|
9
|
+
export declare const Gestures: {
|
|
10
|
+
PanGestureHandler: typeof PanGestureHandler;
|
|
11
|
+
RotationGestureHandler: typeof RotationGestureHandler;
|
|
12
|
+
PinchGestureHandler: typeof PinchGestureHandler;
|
|
13
|
+
TapGestureHandler: typeof TapGestureHandler;
|
|
14
|
+
NativeViewGestureHandler: typeof NativeViewGestureHandler;
|
|
15
|
+
LongPressGestureHandler: typeof LongPressGestureHandler;
|
|
16
|
+
FlingGestureHandler: typeof FlingGestureHandler;
|
|
17
|
+
};
|
|
18
|
+
declare const _default: {
|
|
19
|
+
Direction: {
|
|
20
|
+
RIGHT: number;
|
|
21
|
+
LEFT: number;
|
|
22
|
+
UP: number;
|
|
23
|
+
DOWN: number;
|
|
24
|
+
};
|
|
25
|
+
handleSetJSResponder(): void;
|
|
26
|
+
handleClearJSResponder(): void;
|
|
27
|
+
createGestureHandler<T>(handlerName: keyof typeof Gestures, handlerTag: number, config: T): void;
|
|
28
|
+
attachGestureHandler(handlerTag: number, newView: number, _actionType: ActionType, propsRef: React.RefObject<unknown>): void;
|
|
29
|
+
updateGestureHandler(handlerTag: number, newConfig: any): void;
|
|
30
|
+
getGestureHandlerNode(handlerTag: number): LongPressGestureHandler | NativeViewGestureHandler | PanGestureHandler | RotationGestureHandler | PinchGestureHandler | TapGestureHandler | FlingGestureHandler;
|
|
31
|
+
dropGestureHandler(handlerTag: number): void;
|
|
32
|
+
flushOperations(): void;
|
|
33
|
+
};
|
|
34
|
+
export default _default;
|
|
@@ -27,7 +27,7 @@ declare const _default: {
|
|
|
27
27
|
createGestureHandler<T>(handlerName: keyof typeof Gestures, handlerTag: number, config: T): void;
|
|
28
28
|
attachGestureHandler(handlerTag: number, newView: number, _actionType: ActionType, propsRef: React.RefObject<unknown>): void;
|
|
29
29
|
updateGestureHandler(handlerTag: number, newConfig: any): void;
|
|
30
|
-
getGestureHandlerNode(handlerTag: number):
|
|
30
|
+
getGestureHandlerNode(handlerTag: number): LongPressGestureHandler | NativeViewGestureHandler | PanGestureHandler | RotationGestureHandler | PinchGestureHandler | TapGestureHandler | FlingGestureHandler;
|
|
31
31
|
dropGestureHandler(handlerTag: number): void;
|
|
32
32
|
flushOperations(): void;
|
|
33
33
|
};
|
|
@@ -31,6 +31,12 @@ export interface RawButtonProps extends NativeViewGestureHandlerProps {
|
|
|
31
31
|
* Defines whether the ripple animation should be drawn on the foreground of the view.
|
|
32
32
|
*/
|
|
33
33
|
foreground?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Android only.
|
|
36
|
+
*
|
|
37
|
+
* Set this to true if you don't want the system to play sound when the button is pressed.
|
|
38
|
+
*/
|
|
39
|
+
touchSoundDisabled?: boolean;
|
|
34
40
|
}
|
|
35
41
|
export interface BaseButtonProps extends RawButtonProps {
|
|
36
42
|
/**
|
|
@@ -8,6 +8,7 @@ interface NativeProps extends ViewProps {
|
|
|
8
8
|
enabled?: WithDefault<boolean, true>;
|
|
9
9
|
rippleColor?: ColorValue;
|
|
10
10
|
rippleRadius?: Int32;
|
|
11
|
+
touchSoundDisabled?: WithDefault<boolean, false>;
|
|
11
12
|
}
|
|
12
13
|
declare const _default: HostComponent<NativeProps>;
|
|
13
14
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseGestureHandlerProps } from './gestureHandlerCommon';
|
|
2
|
-
export declare const panGestureHandlerProps: readonly ["activeOffsetY", "activeOffsetX", "failOffsetY", "failOffsetX", "minDist", "minVelocity", "minVelocityX", "minVelocityY", "minPointers", "maxPointers", "avgTouches", "enableTrackpadTwoFingerGesture"];
|
|
2
|
+
export declare const panGestureHandlerProps: readonly ["activeOffsetY", "activeOffsetX", "failOffsetY", "failOffsetX", "minDist", "minVelocity", "minVelocityX", "minVelocityY", "minPointers", "maxPointers", "avgTouches", "enableTrackpadTwoFingerGesture", "activateAfterLongPress"];
|
|
3
3
|
export declare const panGestureHandlerCustomNativeProps: readonly ["activeOffsetYStart", "activeOffsetYEnd", "activeOffsetXStart", "activeOffsetXEnd", "failOffsetYStart", "failOffsetYEnd", "failOffsetXStart", "failOffsetXEnd"];
|
|
4
4
|
export declare type PanGestureHandlerEventPayload = {
|
|
5
5
|
/**
|
|
@@ -82,6 +82,7 @@ interface CommonPanProperties {
|
|
|
82
82
|
minVelocity?: number;
|
|
83
83
|
minVelocityX?: number;
|
|
84
84
|
minVelocityY?: number;
|
|
85
|
+
activateAfterLongPress?: number;
|
|
85
86
|
}
|
|
86
87
|
export interface PanGestureConfig extends CommonPanProperties {
|
|
87
88
|
activeOffsetYStart?: number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PressabilityDebugView(): null;
|
|
@@ -20,6 +20,7 @@ export declare class PanGesture extends ContinousBaseGesture<PanGestureHandlerEv
|
|
|
20
20
|
minVelocityY(velocity: number): this;
|
|
21
21
|
averageTouches(value: boolean): this;
|
|
22
22
|
enableTrackpadTwoFingerGesture(value: boolean): this;
|
|
23
|
+
activateAfterLongPress(duration: number): this;
|
|
23
24
|
onChange(callback: (event: GestureUpdateEvent<PanGestureHandlerEventPayload & PanGestureChangeEventPayload>) => void): this;
|
|
24
25
|
}
|
|
25
26
|
export declare type PanGestureType = InstanceType<typeof PanGesture>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ValueOf } from '../typeUtils';
|
|
2
2
|
import { Gestures } from '../RNGestureHandlerModule.web';
|
|
3
|
-
export declare function getHandler(tag: number): import("./
|
|
3
|
+
export declare function getHandler(tag: number): import("./LongPressGestureHandler").default | import("./NativeViewGestureHandler").default | import("./PanGestureHandler").default | import("./RotationGestureHandler").default | import("./PinchGestureHandler").default | import("./TapGestureHandler").default | import("./FlingGestureHandler").default;
|
|
4
4
|
export declare function createGestureHandler(handlerTag: number, handler: InstanceType<ValueOf<typeof Gestures>>): void;
|
|
5
5
|
export declare function dropGestureHandler(handlerTag: number): void;
|
|
6
6
|
export declare function getNodes(): {
|
|
7
|
-
[x: number]: import("./
|
|
7
|
+
[x: number]: import("./LongPressGestureHandler").default | import("./NativeViewGestureHandler").default | import("./PanGestureHandler").default | import("./RotationGestureHandler").default | import("./PinchGestureHandler").default | import("./TapGestureHandler").default | import("./FlingGestureHandler").default;
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ActionType } from './ActionType';
|
|
2
|
+
import { Direction } from './web/constants';
|
|
3
|
+
import FlingGestureHandler from './web/FlingGestureHandler';
|
|
4
|
+
import LongPressGestureHandler from './web/LongPressGestureHandler';
|
|
5
|
+
import NativeViewGestureHandler from './web/NativeViewGestureHandler';
|
|
6
|
+
import * as NodeManager from './web/NodeManager';
|
|
7
|
+
import PanGestureHandler from './web/PanGestureHandler';
|
|
8
|
+
import PinchGestureHandler from './web/PinchGestureHandler';
|
|
9
|
+
import RotationGestureHandler from './web/RotationGestureHandler';
|
|
10
|
+
import TapGestureHandler from './web/TapGestureHandler';
|
|
11
|
+
|
|
12
|
+
export const Gestures = {
|
|
13
|
+
PanGestureHandler,
|
|
14
|
+
RotationGestureHandler,
|
|
15
|
+
PinchGestureHandler,
|
|
16
|
+
TapGestureHandler,
|
|
17
|
+
NativeViewGestureHandler,
|
|
18
|
+
LongPressGestureHandler,
|
|
19
|
+
FlingGestureHandler,
|
|
20
|
+
// ForceTouchGestureHandler,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
Direction,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
26
|
+
handleSetJSResponder() {},
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
28
|
+
handleClearJSResponder() {},
|
|
29
|
+
createGestureHandler<T>(
|
|
30
|
+
handlerName: keyof typeof Gestures,
|
|
31
|
+
handlerTag: number,
|
|
32
|
+
config: T
|
|
33
|
+
) {
|
|
34
|
+
//TODO(TS) extends config
|
|
35
|
+
if (!(handlerName in Gestures))
|
|
36
|
+
throw new Error(
|
|
37
|
+
`react-native-gesture-handler: ${handlerName} is not supported on macos.`
|
|
38
|
+
);
|
|
39
|
+
const GestureClass = Gestures[handlerName];
|
|
40
|
+
NodeManager.createGestureHandler(handlerTag, new GestureClass());
|
|
41
|
+
this.updateGestureHandler(handlerTag, config);
|
|
42
|
+
},
|
|
43
|
+
attachGestureHandler(
|
|
44
|
+
handlerTag: number,
|
|
45
|
+
newView: number,
|
|
46
|
+
_actionType: ActionType,
|
|
47
|
+
propsRef: React.RefObject<unknown>
|
|
48
|
+
) {
|
|
49
|
+
NodeManager.getHandler(handlerTag).setView(newView, propsRef);
|
|
50
|
+
},
|
|
51
|
+
updateGestureHandler(handlerTag: number, newConfig: any) {
|
|
52
|
+
NodeManager.getHandler(handlerTag).updateGestureConfig(newConfig);
|
|
53
|
+
},
|
|
54
|
+
getGestureHandlerNode(handlerTag: number) {
|
|
55
|
+
return NodeManager.getHandler(handlerTag);
|
|
56
|
+
},
|
|
57
|
+
dropGestureHandler(handlerTag: number) {
|
|
58
|
+
NodeManager.dropGestureHandler(handlerTag);
|
|
59
|
+
},
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
61
|
+
flushOperations() {},
|
|
62
|
+
};
|
|
@@ -56,6 +56,13 @@ export interface RawButtonProps extends NativeViewGestureHandlerProps {
|
|
|
56
56
|
* Defines whether the ripple animation should be drawn on the foreground of the view.
|
|
57
57
|
*/
|
|
58
58
|
foreground?: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Android only.
|
|
62
|
+
*
|
|
63
|
+
* Set this to true if you don't want the system to play sound when the button is pressed.
|
|
64
|
+
*/
|
|
65
|
+
touchSoundDisabled?: boolean;
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
export interface BaseButtonProps extends RawButtonProps {
|
|
@@ -277,6 +277,7 @@ export default class GenericTouchable extends Component<
|
|
|
277
277
|
shouldActivateOnStart={this.props.shouldActivateOnStart}
|
|
278
278
|
disallowInterruption={this.props.disallowInterruption}
|
|
279
279
|
testID={this.props.testID}
|
|
280
|
+
touchSoundDisabled={this.props.touchSoundDisabled ?? false}
|
|
280
281
|
{...this.props.extraButtonProps}>
|
|
281
282
|
<Animated.View {...coreProps} style={this.props.style}>
|
|
282
283
|
{this.props.children}
|
|
@@ -22,6 +22,7 @@ interface NativeProps extends ViewProps {
|
|
|
22
22
|
enabled?: WithDefault<boolean, true>;
|
|
23
23
|
rippleColor?: ColorValue;
|
|
24
24
|
rippleRadius?: Int32;
|
|
25
|
+
touchSoundDisabled?: WithDefault<boolean, false>;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
export default codegenNativeComponent<NativeProps>('RNGestureHandlerButton');
|
|
@@ -17,6 +17,7 @@ export const panGestureHandlerProps = [
|
|
|
17
17
|
'maxPointers',
|
|
18
18
|
'avgTouches',
|
|
19
19
|
'enableTrackpadTwoFingerGesture',
|
|
20
|
+
'activateAfterLongPress',
|
|
20
21
|
] as const;
|
|
21
22
|
|
|
22
23
|
export const panGestureHandlerCustomNativeProps = [
|
|
@@ -124,6 +125,7 @@ interface CommonPanProperties {
|
|
|
124
125
|
minVelocity?: number;
|
|
125
126
|
minVelocityX?: number;
|
|
126
127
|
minVelocityY?: number;
|
|
128
|
+
activateAfterLongPress?: number;
|
|
127
129
|
}
|
|
128
130
|
|
|
129
131
|
export interface PanGestureConfig extends CommonPanProperties {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Platform,
|
|
4
|
-
Touchable,
|
|
5
4
|
UIManager,
|
|
6
5
|
DeviceEventEmitter,
|
|
7
6
|
EmitterSubscription,
|
|
@@ -28,6 +27,7 @@ import {
|
|
|
28
27
|
import { ValueOf } from '../typeUtils';
|
|
29
28
|
import { isFabric, isJestEnv } from '../utils';
|
|
30
29
|
import { ActionType } from '../ActionType';
|
|
30
|
+
import { PressabilityDebugView } from './PressabilityDebugView';
|
|
31
31
|
|
|
32
32
|
const UIManagerAny = UIManager as any;
|
|
33
33
|
|
|
@@ -472,7 +472,7 @@ export default function createHandler<
|
|
|
472
472
|
const child: any = React.Children.only(this.props.children);
|
|
473
473
|
let grandChildren = child.props.children;
|
|
474
474
|
if (
|
|
475
|
-
|
|
475
|
+
__DEV__ &&
|
|
476
476
|
child.type &&
|
|
477
477
|
(child.type === 'RNGestureHandlerButton' ||
|
|
478
478
|
child.type.name === 'View' ||
|
|
@@ -480,10 +480,11 @@ export default function createHandler<
|
|
|
480
480
|
) {
|
|
481
481
|
grandChildren = React.Children.toArray(grandChildren);
|
|
482
482
|
grandChildren.push(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
483
|
+
<PressabilityDebugView
|
|
484
|
+
key="pressabilityDebugView"
|
|
485
|
+
color="mediumspringgreen"
|
|
486
|
+
hitSlop={child.props.hitSlop}
|
|
487
|
+
/>
|
|
487
488
|
);
|
|
488
489
|
}
|
|
489
490
|
|
|
@@ -13,14 +13,19 @@ const warningMessage = tagMessage(
|
|
|
13
13
|
'react-native-reanimated is required in order to use synchronous state management'
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
+
// check if reanimated module is available, but look for useSharedValue as conditional
|
|
17
|
+
// require of reanimated can sometimes return content of `utils.ts` file (?)
|
|
18
|
+
const REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined;
|
|
19
|
+
const setGestureState = Reanimated?.setGestureState;
|
|
20
|
+
|
|
16
21
|
export const GestureStateManager = {
|
|
17
22
|
create(handlerTag: number): GestureStateManagerType {
|
|
18
23
|
'worklet';
|
|
19
24
|
return {
|
|
20
25
|
begin: () => {
|
|
21
26
|
'worklet';
|
|
22
|
-
if (
|
|
23
|
-
|
|
27
|
+
if (REANIMATED_AVAILABLE) {
|
|
28
|
+
setGestureState(handlerTag, State.BEGAN);
|
|
24
29
|
} else {
|
|
25
30
|
console.warn(warningMessage);
|
|
26
31
|
}
|
|
@@ -28,8 +33,8 @@ export const GestureStateManager = {
|
|
|
28
33
|
|
|
29
34
|
activate: () => {
|
|
30
35
|
'worklet';
|
|
31
|
-
if (
|
|
32
|
-
|
|
36
|
+
if (REANIMATED_AVAILABLE) {
|
|
37
|
+
setGestureState(handlerTag, State.ACTIVE);
|
|
33
38
|
} else {
|
|
34
39
|
console.warn(warningMessage);
|
|
35
40
|
}
|
|
@@ -37,8 +42,8 @@ export const GestureStateManager = {
|
|
|
37
42
|
|
|
38
43
|
fail: () => {
|
|
39
44
|
'worklet';
|
|
40
|
-
if (
|
|
41
|
-
|
|
45
|
+
if (REANIMATED_AVAILABLE) {
|
|
46
|
+
setGestureState(handlerTag, State.FAILED);
|
|
42
47
|
} else {
|
|
43
48
|
console.warn(warningMessage);
|
|
44
49
|
}
|
|
@@ -46,8 +51,8 @@ export const GestureStateManager = {
|
|
|
46
51
|
|
|
47
52
|
end: () => {
|
|
48
53
|
'worklet';
|
|
49
|
-
if (
|
|
50
|
-
|
|
54
|
+
if (REANIMATED_AVAILABLE) {
|
|
55
|
+
setGestureState(handlerTag, State.END);
|
|
51
56
|
} else {
|
|
52
57
|
console.warn(warningMessage);
|
|
53
58
|
}
|
|
@@ -131,6 +131,11 @@ export class PanGesture extends ContinousBaseGesture<
|
|
|
131
131
|
return this;
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
activateAfterLongPress(duration: number) {
|
|
135
|
+
this.config.activateAfterLongPress = duration;
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
|
|
134
139
|
onChange(
|
|
135
140
|
callback: (
|
|
136
141
|
event: GestureUpdateEvent<
|
package/src/utils.ts
CHANGED
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
-
<plist version="1.0">
|
|
4
|
-
<dict>
|
|
5
|
-
<key>SchemeUserState</key>
|
|
6
|
-
<dict>
|
|
7
|
-
<key>RNGestureHandler-tvOS.xcscheme_^#shared#^_</key>
|
|
8
|
-
<dict>
|
|
9
|
-
<key>orderHint</key>
|
|
10
|
-
<integer>1</integer>
|
|
11
|
-
</dict>
|
|
12
|
-
<key>RNGestureHandler.xcscheme_^#shared#^_</key>
|
|
13
|
-
<dict>
|
|
14
|
-
<key>orderHint</key>
|
|
15
|
-
<integer>0</integer>
|
|
16
|
-
</dict>
|
|
17
|
-
</dict>
|
|
18
|
-
</dict>
|
|
19
|
-
</plist>
|