react-native-gesture-handler 2.0.0 → 2.1.3
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/android/build.gradle +26 -0
- package/android/{src → common/src}/main/java/com/swmansion/common/GestureHandlerStateManager.kt +0 -0
- package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +4 -1
- package/ios/Handlers/RNFlingHandler.m +1 -1
- package/ios/Handlers/RNLongPressHandler.m +2 -2
- package/ios/Handlers/RNPanHandler.m +1 -1
- package/ios/Handlers/RNTapHandler.m +2 -2
- package/lib/commonjs/handlers/gestures/GestureDetector.js +28 -3
- package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/commonjs/handlers/gestures/eventReceiver.js +34 -11
- package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js +26 -0
- package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/gesture.js +22 -6
- package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/manualGesture.js +12 -0
- package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/panGesture.js +28 -0
- package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/pinchGesture.js +26 -0
- package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/commonjs/handlers/gestures/rotationGesture.js +26 -0
- package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/commonjs/index.js +0 -106
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/handlers/gestures/GestureDetector.js +27 -3
- package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
- package/lib/module/handlers/gestures/eventReceiver.js +34 -11
- package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
- package/lib/module/handlers/gestures/forceTouchGesture.js +27 -0
- package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/gesture.js +22 -6
- package/lib/module/handlers/gestures/gesture.js.map +1 -1
- package/lib/module/handlers/gestures/manualGesture.js +13 -0
- package/lib/module/handlers/gestures/manualGesture.js.map +1 -1
- package/lib/module/handlers/gestures/panGesture.js +29 -0
- package/lib/module/handlers/gestures/panGesture.js.map +1 -1
- package/lib/module/handlers/gestures/pinchGesture.js +27 -0
- package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
- package/lib/module/handlers/gestures/rotationGesture.js +27 -0
- package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
- package/lib/module/index.js +0 -11
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -1
- package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +7 -1
- package/lib/typescript/handlers/gestures/gesture.d.ts +14 -7
- package/lib/typescript/handlers/gestures/manualGesture.d.ts +3 -1
- package/lib/typescript/handlers/gestures/panGesture.d.ts +8 -1
- package/lib/typescript/handlers/gestures/pinchGesture.d.ts +7 -1
- package/lib/typescript/handlers/gestures/rotationGesture.d.ts +7 -1
- package/lib/typescript/handlers/handlersRegistry.d.ts +1 -1
- package/lib/typescript/index.d.ts +11 -11
- package/lib/typescript/web/constants.d.ts +0 -1
- package/package.json +2 -1
- package/src/handlers/gestures/GestureDetector.tsx +31 -2
- package/src/handlers/gestures/eventReceiver.ts +24 -2
- package/src/handlers/gestures/forceTouchGesture.ts +43 -1
- package/src/handlers/gestures/gesture.ts +42 -12
- package/src/handlers/gestures/manualGesture.ts +21 -1
- package/src/handlers/gestures/panGesture.ts +43 -1
- package/src/handlers/gestures/pinchGesture.ts +40 -1
- package/src/handlers/gestures/rotationGesture.ts +40 -1
- package/src/index.ts +11 -11
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/RNGestureHandler.xcscheme +0 -80
- package/ios/RNGestureHandler.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["pinchGesture.ts"],"names":["ContinousBaseGesture","PinchGesture","constructor","handlerName"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;
|
1
|
+
{"version":3,"sources":["pinchGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","scaleChange","scale","PinchGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;;AAQA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,YAAN,SAA2BR,oBAA3B,CAGL;AACAS,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,qBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcZ,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMU,QAAN,CAAeC,QAAf,CAAP;AACD;;AAjBD","sourcesContent":["import { ContinousBaseGesture } from './gesture';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype PinchGestureChangeEventPayload = {\n scaleChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<PinchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<PinchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: PinchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n scaleChange: current.scale,\n };\n } else {\n changePayload = {\n scaleChange: current.scale / previous.scale,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class PinchGesture extends ContinousBaseGesture<\n PinchGestureHandlerEventPayload,\n PinchGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'PinchGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type PinchGestureType = InstanceType<typeof PinchGesture>;\n"]}
|
@@ -1,9 +1,36 @@
|
|
1
1
|
import { ContinousBaseGesture } from './gesture';
|
2
|
+
|
3
|
+
function changeEventCalculator(current, previous) {
|
4
|
+
'worklet';
|
5
|
+
|
6
|
+
let changePayload;
|
7
|
+
|
8
|
+
if (previous === undefined) {
|
9
|
+
changePayload = {
|
10
|
+
rotationChange: current.rotation
|
11
|
+
};
|
12
|
+
} else {
|
13
|
+
changePayload = {
|
14
|
+
rotationChange: current.rotation - previous.rotation
|
15
|
+
};
|
16
|
+
}
|
17
|
+
|
18
|
+
return { ...current,
|
19
|
+
...changePayload
|
20
|
+
};
|
21
|
+
}
|
22
|
+
|
2
23
|
export class RotationGesture extends ContinousBaseGesture {
|
3
24
|
constructor() {
|
4
25
|
super();
|
5
26
|
this.handlerName = 'RotationGestureHandler';
|
6
27
|
}
|
7
28
|
|
29
|
+
onChange(callback) {
|
30
|
+
// @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record
|
31
|
+
this.handlers.changeEventCalculator = changeEventCalculator;
|
32
|
+
return super.onChange(callback);
|
33
|
+
}
|
34
|
+
|
8
35
|
}
|
9
36
|
//# sourceMappingURL=rotationGesture.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["rotationGesture.ts"],"names":["ContinousBaseGesture","RotationGesture","constructor","handlerName"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;
|
1
|
+
{"version":3,"sources":["rotationGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","rotationChange","rotation","RotationGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;;AAQA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,cAAc,EAAEJ,OAAO,CAACK;AADV,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,cAAc,EAAEJ,OAAO,CAACK,QAAR,GAAmBJ,QAAQ,CAACI;AAD9B,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,eAAN,SAA8BR,oBAA9B,CAGL;AACAS,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,wBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcZ,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMU,QAAN,CAAeC,QAAf,CAAP;AACD;;AAjBD","sourcesContent":["import { ContinousBaseGesture } from './gesture';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype RotationGestureChangeEventPayload = {\n rotationChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<RotationGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<RotationGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: RotationGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n rotationChange: current.rotation,\n };\n } else {\n changePayload = {\n rotationChange: current.rotation - previous.rotation,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class RotationGesture extends ContinousBaseGesture<\n RotationGestureHandlerEventPayload,\n RotationGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'RotationGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type RotationGestureType = InstanceType<typeof RotationGesture>;\n"]}
|
package/lib/module/index.js
CHANGED
@@ -13,17 +13,6 @@ export { FlingGestureHandler } from './handlers/FlingGestureHandler';
|
|
13
13
|
export { default as createNativeWrapper } from './handlers/createNativeWrapper';
|
14
14
|
export { GestureDetector } from './handlers/gestures/GestureDetector';
|
15
15
|
export { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';
|
16
|
-
export { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';
|
17
|
-
export { PanGestureType as PanGesture } from './handlers/gestures/panGesture';
|
18
|
-
export { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';
|
19
|
-
export { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';
|
20
|
-
export { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';
|
21
|
-
export { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';
|
22
|
-
export { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';
|
23
|
-
export { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';
|
24
|
-
export { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';
|
25
|
-
export { ComposedGestureType as ComposedGesture, RaceGestureType as RaceGesture, SimultaneousGestureType as SimultaneousGesture, ExclusiveGestureType as ExclusiveGesture } from './handlers/gestures/gestureComposition';
|
26
|
-
export { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';
|
27
16
|
export { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler';
|
28
17
|
export { RawButton, BaseButton, RectButton, BorderlessButton } from './components/GestureButtons';
|
29
18
|
export { TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback } from './components/touchables';
|
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["initialize","Directions","State","default","gestureHandlerRootHOC","GestureHandlerRootView","TapGestureHandler","ForceTouchGestureHandler","LongPressGestureHandler","PanGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","createNativeWrapper","GestureDetector","GestureObjects","Gesture","
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["initialize","Directions","State","default","gestureHandlerRootHOC","GestureHandlerRootView","TapGestureHandler","ForceTouchGestureHandler","LongPressGestureHandler","PanGestureHandler","PinchGestureHandler","RotationGestureHandler","FlingGestureHandler","createNativeWrapper","GestureDetector","GestureObjects","Gesture","NativeViewGestureHandler","RawButton","BaseButton","RectButton","BorderlessButton","TouchableHighlight","TouchableNativeFeedback","TouchableOpacity","TouchableWithoutFeedback","ScrollView","Switch","TextInput","DrawerLayoutAndroid","FlatList","Swipeable","DrawerLayout"],"mappings":"AAAA,SAASA,UAAT,QAA2B,QAA3B;AAEA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,KAAT,QAAsB,SAAtB;AACA,SAASC,OAAO,IAAIC,qBAApB,QAAiD,yBAAjD;AACA,SAASD,OAAO,IAAIE,sBAApB,QAAkD,0BAAlD;AA4CA,SAASC,iBAAT,QAAkC,8BAAlC;AACA,SAASC,wBAAT,QAAyC,qCAAzC;AACA,SAASC,uBAAT,QAAwC,oCAAxC;AACA,SAASC,iBAAT,QAAkC,8BAAlC;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASC,sBAAT,QAAuC,mCAAvC;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAAST,OAAO,IAAIU,mBAApB,QAA+C,gCAA/C;AAKA,SAASC,eAAT,QAAgC,qCAAhC;AACA,SAASC,cAAc,IAAIC,OAA3B,QAA0C,oCAA1C;AAiBA,SAASC,wBAAT,QAAyC,qCAAzC;AAOA,SACEC,SADF,EAEEC,UAFF,EAGEC,UAHF,EAIEC,gBAJF,QAKO,6BALP;AAMA,SACEC,kBADF,EAEEC,uBAFF,EAGEC,gBAHF,EAIEC,wBAJF,QAKO,yBALP;AAMA,SACEC,UADF,EAEEC,MAFF,EAGEC,SAHF,EAIEC,mBAJF,EAKEC,QALF,QAMO,gCANP;AA8CA,SAAS3B,OAAO,IAAI4B,SAApB,QAAqC,wBAArC;AASA,SAAS5B,OAAO,IAAI6B,YAApB,QAAwC,2BAAxC;AAEAhC,UAAU","sourcesContent":["import { initialize } from './init';\n\nexport { Directions } from './Directions';\nexport { State } from './State';\nexport { default as gestureHandlerRootHOC } from './gestureHandlerRootHOC';\nexport { default as GestureHandlerRootView } from './GestureHandlerRootView';\nexport type {\n // event types\n GestureEvent,\n HandlerStateChangeEvent,\n // event payloads types\n GestureEventPayload,\n HandlerStateChangeEventPayload,\n // pointer events\n GestureTouchEvent,\n TouchData,\n // new api event types\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from './handlers/gestureHandlerCommon';\nexport type { GestureType } from './handlers/gestures/gesture';\nexport type {\n TapGestureHandlerEventPayload,\n TapGestureHandlerProps,\n} from './handlers/TapGestureHandler';\nexport type {\n ForceTouchGestureHandlerEventPayload,\n ForceTouchGestureHandlerProps,\n} from './handlers/ForceTouchGestureHandler';\nexport type {\n LongPressGestureHandlerEventPayload,\n LongPressGestureHandlerProps,\n} from './handlers/LongPressGestureHandler';\nexport type {\n PanGestureHandlerEventPayload,\n PanGestureHandlerProps,\n} from './handlers/PanGestureHandler';\nexport type {\n PinchGestureHandlerEventPayload,\n PinchGestureHandlerProps,\n} from './handlers/PinchGestureHandler';\nexport type {\n RotationGestureHandlerEventPayload,\n RotationGestureHandlerProps,\n} from './handlers/RotationGestureHandler';\nexport type {\n FlingGestureHandlerEventPayload,\n FlingGestureHandlerProps,\n} from './handlers/FlingGestureHandler';\nexport { TapGestureHandler } from './handlers/TapGestureHandler';\nexport { ForceTouchGestureHandler } from './handlers/ForceTouchGestureHandler';\nexport { LongPressGestureHandler } from './handlers/LongPressGestureHandler';\nexport { PanGestureHandler } from './handlers/PanGestureHandler';\nexport { PinchGestureHandler } from './handlers/PinchGestureHandler';\nexport { RotationGestureHandler } from './handlers/RotationGestureHandler';\nexport { FlingGestureHandler } from './handlers/FlingGestureHandler';\nexport { default as createNativeWrapper } from './handlers/createNativeWrapper';\nexport type {\n NativeViewGestureHandlerPayload,\n NativeViewGestureHandlerProps,\n} from './handlers/NativeViewGestureHandler';\nexport { GestureDetector } from './handlers/gestures/GestureDetector';\nexport { GestureObjects as Gesture } from './handlers/gestures/gestureObjects';\nexport type { TapGestureType as TapGesture } from './handlers/gestures/tapGesture';\nexport type { PanGestureType as PanGesture } from './handlers/gestures/panGesture';\nexport type { FlingGestureType as FlingGesture } from './handlers/gestures/flingGesture';\nexport type { LongPressGestureType as LongPressGesture } from './handlers/gestures/longPressGesture';\nexport type { PinchGestureType as PinchGesture } from './handlers/gestures/pinchGesture';\nexport type { RotationGestureType as RotationGesture } from './handlers/gestures/rotationGesture';\nexport type { ForceTouchGestureType as ForceTouchGesture } from './handlers/gestures/forceTouchGesture';\nexport type { NativeGestureType as NativeGesture } from './handlers/gestures/nativeGesture';\nexport type { ManualGestureType as ManualGesture } from './handlers/gestures/manualGesture';\nexport type {\n ComposedGestureType as ComposedGesture,\n RaceGestureType as RaceGesture,\n SimultaneousGestureType as SimultaneousGesture,\n ExclusiveGestureType as ExclusiveGesture,\n} from './handlers/gestures/gestureComposition';\nexport type { GestureStateManagerType as GestureStateManager } from './handlers/gestures/gestureStateManager';\nexport { NativeViewGestureHandler } from './handlers/NativeViewGestureHandler';\nexport type {\n RawButtonProps,\n BaseButtonProps,\n RectButtonProps,\n BorderlessButtonProps,\n} from './components/GestureButtons';\nexport {\n RawButton,\n BaseButton,\n RectButton,\n BorderlessButton,\n} from './components/GestureButtons';\nexport {\n TouchableHighlight,\n TouchableNativeFeedback,\n TouchableOpacity,\n TouchableWithoutFeedback,\n} from './components/touchables';\nexport {\n ScrollView,\n Switch,\n TextInput,\n DrawerLayoutAndroid,\n FlatList,\n} from './components/GestureComponents';\nexport type {\n //events\n GestureHandlerGestureEvent,\n GestureHandlerStateChangeEvent,\n //event payloads\n GestureHandlerGestureEventNativeEvent,\n GestureHandlerStateChangeNativeEvent,\n NativeViewGestureHandlerGestureEvent,\n NativeViewGestureHandlerStateChangeEvent,\n TapGestureHandlerGestureEvent,\n TapGestureHandlerStateChangeEvent,\n ForceTouchGestureHandlerGestureEvent,\n ForceTouchGestureHandlerStateChangeEvent,\n LongPressGestureHandlerGestureEvent,\n LongPressGestureHandlerStateChangeEvent,\n PanGestureHandlerGestureEvent,\n PanGestureHandlerStateChangeEvent,\n PinchGestureHandlerGestureEvent,\n PinchGestureHandlerStateChangeEvent,\n RotationGestureHandlerGestureEvent,\n RotationGestureHandlerStateChangeEvent,\n FlingGestureHandlerGestureEvent,\n FlingGestureHandlerStateChangeEvent,\n // handlers props\n NativeViewGestureHandlerProperties,\n TapGestureHandlerProperties,\n LongPressGestureHandlerProperties,\n PanGestureHandlerProperties,\n PinchGestureHandlerProperties,\n RotationGestureHandlerProperties,\n FlingGestureHandlerProperties,\n ForceTouchGestureHandlerProperties,\n // buttons props\n RawButtonProperties,\n BaseButtonProperties,\n RectButtonProperties,\n BorderlessButtonProperties,\n} from './handlers/gestureHandlerTypesCompat';\n\nexport { default as Swipeable } from './components/Swipeable';\nexport type {\n DrawerLayoutProps,\n DrawerPosition,\n DrawerState,\n DrawerType,\n DrawerLockMode,\n DrawerKeyboardDismissMode,\n} from './components/DrawerLayout';\nexport { default as DrawerLayout } from './components/DrawerLayout';\n\ninitialize();\n"]}
|
@@ -39,5 +39,5 @@ export interface ForceTouchGestureHandlerProps extends BaseGestureHandlerProps<F
|
|
39
39
|
export declare type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {
|
40
40
|
forceTouchAvailable: boolean;
|
41
41
|
};
|
42
|
-
export declare const ForceTouchGestureHandler: typeof ForceTouchFallback | React.
|
42
|
+
export declare const ForceTouchGestureHandler: typeof ForceTouchFallback | React.ComponentType<ForceTouchGestureHandlerProps & React.RefAttributes<any>>;
|
43
43
|
export {};
|
@@ -1,10 +1,16 @@
|
|
1
1
|
import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
|
2
2
|
import { ForceTouchGestureConfig, ForceTouchGestureHandlerEventPayload } from '../ForceTouchGestureHandler';
|
3
|
-
|
3
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
4
|
+
declare type ForceTouchGestureChangeEventPayload = {
|
5
|
+
forceChange: number;
|
6
|
+
};
|
7
|
+
export declare class ForceTouchGesture extends ContinousBaseGesture<ForceTouchGestureHandlerEventPayload, ForceTouchGestureChangeEventPayload> {
|
4
8
|
config: BaseGestureConfig & ForceTouchGestureConfig;
|
5
9
|
constructor();
|
6
10
|
minForce(force: number): this;
|
7
11
|
maxForce(force: number): this;
|
8
12
|
feedbackOnActivation(value: boolean): this;
|
13
|
+
onChange(callback: (event: GestureUpdateEvent<GestureUpdateEvent<ForceTouchGestureHandlerEventPayload & ForceTouchGestureChangeEventPayload>>) => void): this;
|
9
14
|
}
|
10
15
|
export declare type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;
|
16
|
+
export {};
|
@@ -23,11 +23,14 @@ export declare type HandlerCallbacks<EventPayloadT extends Record<string, unknow
|
|
23
23
|
onBegin?: (event: GestureStateChangeEvent<EventPayloadT>) => void;
|
24
24
|
onStart?: (event: GestureStateChangeEvent<EventPayloadT>) => void;
|
25
25
|
onEnd?: (event: GestureStateChangeEvent<EventPayloadT>, success: boolean) => void;
|
26
|
+
onFinalize?: (event: GestureStateChangeEvent<EventPayloadT>, success: boolean) => void;
|
26
27
|
onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;
|
28
|
+
onChange?: (event: any) => void;
|
27
29
|
onTouchesDown?: TouchEventHandlerType;
|
28
30
|
onTouchesMove?: TouchEventHandlerType;
|
29
31
|
onTouchesUp?: TouchEventHandlerType;
|
30
32
|
onTouchesCancelled?: TouchEventHandlerType;
|
33
|
+
changeEventCalculator?: (current: GestureUpdateEvent<Record<string, unknown>>, previous?: GestureUpdateEvent<Record<string, unknown>>) => GestureUpdateEvent<Record<string, unknown>>;
|
31
34
|
isWorklet: boolean[];
|
32
35
|
};
|
33
36
|
export declare const CALLBACK_TYPE: {
|
@@ -35,11 +38,13 @@ export declare const CALLBACK_TYPE: {
|
|
35
38
|
readonly BEGAN: 1;
|
36
39
|
readonly START: 2;
|
37
40
|
readonly UPDATE: 3;
|
38
|
-
readonly
|
39
|
-
readonly
|
40
|
-
readonly
|
41
|
-
readonly
|
42
|
-
readonly
|
41
|
+
readonly CHANGE: 4;
|
42
|
+
readonly END: 5;
|
43
|
+
readonly FINALIZE: 6;
|
44
|
+
readonly TOUCHES_DOWN: 7;
|
45
|
+
readonly TOUCHES_MOVE: 8;
|
46
|
+
readonly TOUCHES_UP: 9;
|
47
|
+
readonly TOUCHES_CANCELLED: 10;
|
43
48
|
};
|
44
49
|
export declare type CALLBACK_TYPE = typeof CALLBACK_TYPE[keyof typeof CALLBACK_TYPE];
|
45
50
|
export declare abstract class Gesture {
|
@@ -66,10 +71,11 @@ export declare abstract class BaseGesture<EventPayloadT extends Record<string, u
|
|
66
71
|
handlers: HandlerCallbacks<EventPayloadT>;
|
67
72
|
private addDependency;
|
68
73
|
withRef(ref: React.MutableRefObject<GestureType | undefined>): this;
|
69
|
-
protected isWorklet(callback:
|
74
|
+
protected isWorklet(callback: Function): boolean;
|
70
75
|
onBegin(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void): this;
|
71
76
|
onStart(callback: (event: GestureStateChangeEvent<EventPayloadT>) => void): this;
|
72
77
|
onEnd(callback: (event: GestureStateChangeEvent<EventPayloadT>, success: boolean) => void): this;
|
78
|
+
onFinalize(callback: (event: GestureStateChangeEvent<EventPayloadT>, success: boolean) => void): this;
|
73
79
|
onTouchesDown(callback: TouchEventHandlerType): this;
|
74
80
|
onTouchesMove(callback: TouchEventHandlerType): this;
|
75
81
|
onTouchesUp(callback: TouchEventHandlerType): this;
|
@@ -83,8 +89,9 @@ export declare abstract class BaseGesture<EventPayloadT extends Record<string, u
|
|
83
89
|
toGestureArray(): GestureType[];
|
84
90
|
prepare(): void;
|
85
91
|
}
|
86
|
-
export declare abstract class ContinousBaseGesture<EventPayloadT extends Record<string, unknown>> extends BaseGesture<EventPayloadT> {
|
92
|
+
export declare abstract class ContinousBaseGesture<EventPayloadT extends Record<string, unknown>, EventChangePayloadT extends Record<string, unknown>> extends BaseGesture<EventPayloadT> {
|
87
93
|
onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void): this;
|
94
|
+
onChange(callback: (event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>) => void): this;
|
88
95
|
manualActivation(manualActivation: boolean): this;
|
89
96
|
}
|
90
97
|
export {};
|
@@ -1,5 +1,7 @@
|
|
1
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
1
2
|
import { ContinousBaseGesture } from './gesture';
|
2
|
-
export declare class ManualGesture extends ContinousBaseGesture<Record<string, never>> {
|
3
|
+
export declare class ManualGesture extends ContinousBaseGesture<Record<string, never>, Record<string, never>> {
|
3
4
|
constructor();
|
5
|
+
onChange(callback: (event: GestureUpdateEvent<Record<string, never>>) => void): this;
|
4
6
|
}
|
5
7
|
export declare type ManualGestureType = InstanceType<typeof ManualGesture>;
|
@@ -1,6 +1,11 @@
|
|
1
1
|
import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
|
2
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
2
3
|
import { PanGestureConfig, PanGestureHandlerEventPayload } from '../PanGestureHandler';
|
3
|
-
|
4
|
+
declare type PanGestureChangeEventPayload = {
|
5
|
+
changeX: number;
|
6
|
+
changeY: number;
|
7
|
+
};
|
8
|
+
export declare class PanGesture extends ContinousBaseGesture<PanGestureHandlerEventPayload, PanGestureChangeEventPayload> {
|
4
9
|
config: BaseGestureConfig & PanGestureConfig;
|
5
10
|
constructor();
|
6
11
|
activeOffsetY(offset: number | number[]): this;
|
@@ -15,5 +20,7 @@ export declare class PanGesture extends ContinousBaseGesture<PanGestureHandlerEv
|
|
15
20
|
minVelocityY(velocity: number): this;
|
16
21
|
averageTouches(value: boolean): this;
|
17
22
|
enableTrackpadTwoFingerGesture(value: boolean): this;
|
23
|
+
onChange(callback: (event: GestureUpdateEvent<PanGestureHandlerEventPayload & PanGestureChangeEventPayload>) => void): this;
|
18
24
|
}
|
19
25
|
export declare type PanGestureType = InstanceType<typeof PanGesture>;
|
26
|
+
export {};
|
@@ -1,6 +1,12 @@
|
|
1
1
|
import { ContinousBaseGesture } from './gesture';
|
2
2
|
import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';
|
3
|
-
|
3
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
4
|
+
declare type PinchGestureChangeEventPayload = {
|
5
|
+
scaleChange: number;
|
6
|
+
};
|
7
|
+
export declare class PinchGesture extends ContinousBaseGesture<PinchGestureHandlerEventPayload, PinchGestureChangeEventPayload> {
|
4
8
|
constructor();
|
9
|
+
onChange(callback: (event: GestureUpdateEvent<PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload>) => void): this;
|
5
10
|
}
|
6
11
|
export declare type PinchGestureType = InstanceType<typeof PinchGesture>;
|
12
|
+
export {};
|
@@ -1,6 +1,12 @@
|
|
1
1
|
import { ContinousBaseGesture } from './gesture';
|
2
2
|
import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
|
3
|
-
|
3
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
4
|
+
declare type RotationGestureChangeEventPayload = {
|
5
|
+
rotationChange: number;
|
6
|
+
};
|
7
|
+
export declare class RotationGesture extends ContinousBaseGesture<RotationGestureHandlerEventPayload, RotationGestureChangeEventPayload> {
|
4
8
|
constructor();
|
9
|
+
onChange(callback: (event: GestureUpdateEvent<RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload>) => void): this;
|
5
10
|
}
|
6
11
|
export declare type RotationGestureType = InstanceType<typeof RotationGesture>;
|
12
|
+
export {};
|
@@ -3,4 +3,4 @@ export declare const handlerIDToTag: Record<string, number>;
|
|
3
3
|
export declare function getNextHandlerTag(): number;
|
4
4
|
export declare function registerHandler(handlerTag: number, handler: GestureType): void;
|
5
5
|
export declare function unregisterHandler(handlerTag: number): void;
|
6
|
-
export declare function findHandler(handlerTag: number):
|
6
|
+
export declare function findHandler(handlerTag: number): GestureType | undefined;
|
@@ -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
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-gesture-handler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.1.3",
|
4
4
|
"description": "Experimental implementation of a new declarative API for gesture handling in react-native",
|
5
5
|
"scripts": {
|
6
6
|
"prepare": "bob build",
|
@@ -27,6 +27,7 @@
|
|
27
27
|
"android/src/main/java/",
|
28
28
|
"android/lib/build.gradle",
|
29
29
|
"android/lib/src/main/java/",
|
30
|
+
"android/common/src/main/java/",
|
30
31
|
"ios/",
|
31
32
|
"Swipeable/",
|
32
33
|
"DrawerLayout/",
|
@@ -256,8 +256,12 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
256
256
|
return gesture.onStart;
|
257
257
|
case CALLBACK_TYPE.UPDATE:
|
258
258
|
return gesture.onUpdate;
|
259
|
+
case CALLBACK_TYPE.CHANGE:
|
260
|
+
return gesture.onChange;
|
259
261
|
case CALLBACK_TYPE.END:
|
260
262
|
return gesture.onEnd;
|
263
|
+
case CALLBACK_TYPE.FINALIZE:
|
264
|
+
return gesture.onFinalize;
|
261
265
|
case CALLBACK_TYPE.TOUCHES_DOWN:
|
262
266
|
return gesture.onTouchesDown;
|
263
267
|
case CALLBACK_TYPE.TOUCHES_MOVE:
|
@@ -308,6 +312,11 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
308
312
|
HandlerCallbacks<Record<string, unknown>>[] | null
|
309
313
|
>(null);
|
310
314
|
|
315
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
316
|
+
const lastUpdateEvent = Reanimated.useSharedValue<
|
317
|
+
(GestureUpdateEvent | undefined)[]
|
318
|
+
>([]);
|
319
|
+
|
311
320
|
// not every gesture needs a state controller, init them lazily
|
312
321
|
const stateControllers: GestureStateManagerType[] = [];
|
313
322
|
|
@@ -337,16 +346,23 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
337
346
|
event.state === State.ACTIVE
|
338
347
|
) {
|
339
348
|
runWorklet(CALLBACK_TYPE.START, gesture, event);
|
349
|
+
lastUpdateEvent.value[gesture.handlerTag] = undefined;
|
340
350
|
} else if (
|
341
351
|
event.oldState !== event.state &&
|
342
352
|
event.state === State.END
|
343
353
|
) {
|
344
|
-
|
354
|
+
if (event.oldState === State.ACTIVE) {
|
355
|
+
runWorklet(CALLBACK_TYPE.END, gesture, event, true);
|
356
|
+
}
|
357
|
+
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);
|
345
358
|
} else if (
|
346
359
|
(event.state === State.FAILED || event.state === State.CANCELLED) &&
|
347
360
|
event.state !== event.oldState
|
348
361
|
) {
|
349
|
-
|
362
|
+
if (event.oldState === State.ACTIVE) {
|
363
|
+
runWorklet(CALLBACK_TYPE.END, gesture, event, false);
|
364
|
+
}
|
365
|
+
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
|
350
366
|
}
|
351
367
|
} else if (isTouchEvent(event)) {
|
352
368
|
if (!stateControllers[i]) {
|
@@ -363,6 +379,19 @@ function useAnimatedGesture(preparedGesture: GestureConfigReference) {
|
|
363
379
|
}
|
364
380
|
} else {
|
365
381
|
runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);
|
382
|
+
|
383
|
+
if (gesture.onChange && gesture.changeEventCalculator) {
|
384
|
+
runWorklet(
|
385
|
+
CALLBACK_TYPE.CHANGE,
|
386
|
+
gesture,
|
387
|
+
gesture.changeEventCalculator?.(
|
388
|
+
event,
|
389
|
+
lastUpdateEvent.value[gesture.handlerTag]
|
390
|
+
)
|
391
|
+
);
|
392
|
+
|
393
|
+
lastUpdateEvent.value[gesture.handlerTag] = event;
|
394
|
+
}
|
366
395
|
}
|
367
396
|
}
|
368
397
|
}
|
@@ -36,6 +36,8 @@ const dummyStateManager: GestureStateManagerType = {
|
|
36
36
|
},
|
37
37
|
};
|
38
38
|
|
39
|
+
const lastUpdateEvent: (GestureUpdateEvent | undefined)[] = [];
|
40
|
+
|
39
41
|
function isStateChangeEvent(
|
40
42
|
event: GestureUpdateEvent | GestureStateChangeEvent | GestureTouchEvent
|
41
43
|
): event is GestureStateChangeEvent {
|
@@ -69,13 +71,22 @@ function onGestureHandlerEvent(
|
|
69
71
|
event.state === State.ACTIVE
|
70
72
|
) {
|
71
73
|
handler.handlers.onStart?.(event);
|
74
|
+
lastUpdateEvent[handler.handlers.handlerTag] = event;
|
72
75
|
} else if (event.oldState !== event.state && event.state === State.END) {
|
73
|
-
|
76
|
+
if (event.oldState === State.ACTIVE) {
|
77
|
+
handler.handlers.onEnd?.(event, true);
|
78
|
+
}
|
79
|
+
handler.handlers.onFinalize?.(event, true);
|
80
|
+
lastUpdateEvent[handler.handlers.handlerTag] = undefined;
|
74
81
|
} else if (
|
75
82
|
(event.state === State.FAILED || event.state === State.CANCELLED) &&
|
76
83
|
event.oldState !== event.state
|
77
84
|
) {
|
78
|
-
|
85
|
+
if (event.oldState === State.ACTIVE) {
|
86
|
+
handler.handlers.onEnd?.(event, false);
|
87
|
+
}
|
88
|
+
handler.handlers.onFinalize?.(event, false);
|
89
|
+
lastUpdateEvent[handler.handlers.handlerTag] = undefined;
|
79
90
|
}
|
80
91
|
} else if (isTouchEvent(event)) {
|
81
92
|
switch (event.eventType) {
|
@@ -94,6 +105,17 @@ function onGestureHandlerEvent(
|
|
94
105
|
}
|
95
106
|
} else {
|
96
107
|
handler.handlers.onUpdate?.(event);
|
108
|
+
|
109
|
+
if (handler.handlers.onChange && handler.handlers.changeEventCalculator) {
|
110
|
+
handler.handlers.onChange?.(
|
111
|
+
handler.handlers.changeEventCalculator?.(
|
112
|
+
event,
|
113
|
+
lastUpdateEvent[handler.handlers.handlerTag]
|
114
|
+
)
|
115
|
+
);
|
116
|
+
|
117
|
+
lastUpdateEvent[handler.handlers.handlerTag] = event;
|
118
|
+
}
|
97
119
|
}
|
98
120
|
}
|
99
121
|
}
|
@@ -3,8 +3,35 @@ import {
|
|
3
3
|
ForceTouchGestureConfig,
|
4
4
|
ForceTouchGestureHandlerEventPayload,
|
5
5
|
} from '../ForceTouchGestureHandler';
|
6
|
+
import { GestureUpdateEvent } from '../gestureHandlerCommon';
|
6
7
|
|
7
|
-
|
8
|
+
type ForceTouchGestureChangeEventPayload = {
|
9
|
+
forceChange: number;
|
10
|
+
};
|
11
|
+
|
12
|
+
function changeEventCalculator(
|
13
|
+
current: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>,
|
14
|
+
previous?: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>
|
15
|
+
) {
|
16
|
+
'worklet';
|
17
|
+
let changePayload: ForceTouchGestureChangeEventPayload;
|
18
|
+
if (previous === undefined) {
|
19
|
+
changePayload = {
|
20
|
+
forceChange: current.force,
|
21
|
+
};
|
22
|
+
} else {
|
23
|
+
changePayload = {
|
24
|
+
forceChange: current.force - previous.force,
|
25
|
+
};
|
26
|
+
}
|
27
|
+
|
28
|
+
return { ...current, ...changePayload };
|
29
|
+
}
|
30
|
+
|
31
|
+
export class ForceTouchGesture extends ContinousBaseGesture<
|
32
|
+
ForceTouchGestureHandlerEventPayload,
|
33
|
+
ForceTouchGestureChangeEventPayload
|
34
|
+
> {
|
8
35
|
public config: BaseGestureConfig & ForceTouchGestureConfig = {};
|
9
36
|
|
10
37
|
constructor() {
|
@@ -27,6 +54,21 @@ export class ForceTouchGesture extends ContinousBaseGesture<ForceTouchGestureHan
|
|
27
54
|
this.config.feedbackOnActivation = value;
|
28
55
|
return this;
|
29
56
|
}
|
57
|
+
|
58
|
+
onChange(
|
59
|
+
callback: (
|
60
|
+
event: GestureUpdateEvent<
|
61
|
+
GestureUpdateEvent<
|
62
|
+
ForceTouchGestureHandlerEventPayload &
|
63
|
+
ForceTouchGestureChangeEventPayload
|
64
|
+
>
|
65
|
+
>
|
66
|
+
) => void
|
67
|
+
) {
|
68
|
+
// @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record
|
69
|
+
this.handlers.changeEventCalculator = changeEventCalculator;
|
70
|
+
return super.onChange(callback);
|
71
|
+
}
|
30
72
|
}
|
31
73
|
|
32
74
|
export type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;
|
@@ -56,11 +56,20 @@ export type HandlerCallbacks<EventPayloadT extends Record<string, unknown>> = {
|
|
56
56
|
event: GestureStateChangeEvent<EventPayloadT>,
|
57
57
|
success: boolean
|
58
58
|
) => void;
|
59
|
+
onFinalize?: (
|
60
|
+
event: GestureStateChangeEvent<EventPayloadT>,
|
61
|
+
success: boolean
|
62
|
+
) => void;
|
59
63
|
onUpdate?: (event: GestureUpdateEvent<EventPayloadT>) => void;
|
64
|
+
onChange?: (event: any) => void;
|
60
65
|
onTouchesDown?: TouchEventHandlerType;
|
61
66
|
onTouchesMove?: TouchEventHandlerType;
|
62
67
|
onTouchesUp?: TouchEventHandlerType;
|
63
68
|
onTouchesCancelled?: TouchEventHandlerType;
|
69
|
+
changeEventCalculator?: (
|
70
|
+
current: GestureUpdateEvent<Record<string, unknown>>,
|
71
|
+
previous?: GestureUpdateEvent<Record<string, unknown>>
|
72
|
+
) => GestureUpdateEvent<Record<string, unknown>>;
|
64
73
|
isWorklet: boolean[];
|
65
74
|
};
|
66
75
|
|
@@ -69,11 +78,13 @@ export const CALLBACK_TYPE = {
|
|
69
78
|
BEGAN: 1,
|
70
79
|
START: 2,
|
71
80
|
UPDATE: 3,
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
81
|
+
CHANGE: 4,
|
82
|
+
END: 5,
|
83
|
+
FINALIZE: 6,
|
84
|
+
TOUCHES_DOWN: 7,
|
85
|
+
TOUCHES_MOVE: 8,
|
86
|
+
TOUCHES_UP: 9,
|
87
|
+
TOUCHES_CANCELLED: 10,
|
77
88
|
} as const;
|
78
89
|
|
79
90
|
// Allow using CALLBACK_TYPE as object and type
|
@@ -126,12 +137,8 @@ export abstract class BaseGesture<
|
|
126
137
|
return this;
|
127
138
|
}
|
128
139
|
|
129
|
-
|
130
|
-
|
131
|
-
| TouchEventHandlerType
|
132
|
-
| ((event: GestureUpdateEvent<EventPayloadT>) => void)
|
133
|
-
| ((event: GestureStateChangeEvent<EventPayloadT>) => void)
|
134
|
-
) {
|
140
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
141
|
+
protected isWorklet(callback: Function) {
|
135
142
|
//@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
136
143
|
return callback.__workletHash !== undefined;
|
137
144
|
}
|
@@ -160,6 +167,18 @@ export abstract class BaseGesture<
|
|
160
167
|
return this;
|
161
168
|
}
|
162
169
|
|
170
|
+
onFinalize(
|
171
|
+
callback: (
|
172
|
+
event: GestureStateChangeEvent<EventPayloadT>,
|
173
|
+
success: boolean
|
174
|
+
) => void
|
175
|
+
) {
|
176
|
+
this.handlers.onFinalize = callback;
|
177
|
+
//@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
|
178
|
+
this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
|
179
|
+
return this;
|
180
|
+
}
|
181
|
+
|
163
182
|
onTouchesDown(callback: TouchEventHandlerType) {
|
164
183
|
this.config.needsPointerData = true;
|
165
184
|
this.handlers.onTouchesDown = callback;
|
@@ -247,7 +266,8 @@ export abstract class BaseGesture<
|
|
247
266
|
}
|
248
267
|
|
249
268
|
export abstract class ContinousBaseGesture<
|
250
|
-
EventPayloadT extends Record<string, unknown
|
269
|
+
EventPayloadT extends Record<string, unknown>,
|
270
|
+
EventChangePayloadT extends Record<string, unknown>
|
251
271
|
> extends BaseGesture<EventPayloadT> {
|
252
272
|
onUpdate(callback: (event: GestureUpdateEvent<EventPayloadT>) => void) {
|
253
273
|
this.handlers.onUpdate = callback;
|
@@ -255,6 +275,16 @@ export abstract class ContinousBaseGesture<
|
|
255
275
|
return this;
|
256
276
|
}
|
257
277
|
|
278
|
+
onChange(
|
279
|
+
callback: (
|
280
|
+
event: GestureUpdateEvent<EventPayloadT & EventChangePayloadT>
|
281
|
+
) => void
|
282
|
+
) {
|
283
|
+
this.handlers.onChange = callback;
|
284
|
+
this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);
|
285
|
+
return this;
|
286
|
+
}
|
287
|
+
|
258
288
|
manualActivation(manualActivation: boolean) {
|
259
289
|
this.config.manualActivation = manualActivation;
|
260
290
|
return this;
|