react-native-gesture-handler 2.0.0 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/android/build.gradle +26 -0
  2. package/android/{src → common/src}/main/java/com/swmansion/common/GestureHandlerStateManager.kt +0 -0
  3. package/android/lib/src/main/java/com/swmansion/gesturehandler/GestureHandler.kt +4 -1
  4. package/ios/Handlers/RNFlingHandler.m +1 -1
  5. package/ios/Handlers/RNLongPressHandler.m +2 -2
  6. package/ios/Handlers/RNPanHandler.m +1 -1
  7. package/ios/Handlers/RNTapHandler.m +2 -2
  8. package/lib/commonjs/handlers/gestures/GestureDetector.js +28 -3
  9. package/lib/commonjs/handlers/gestures/GestureDetector.js.map +1 -1
  10. package/lib/commonjs/handlers/gestures/eventReceiver.js +34 -11
  11. package/lib/commonjs/handlers/gestures/eventReceiver.js.map +1 -1
  12. package/lib/commonjs/handlers/gestures/forceTouchGesture.js +26 -0
  13. package/lib/commonjs/handlers/gestures/forceTouchGesture.js.map +1 -1
  14. package/lib/commonjs/handlers/gestures/gesture.js +22 -6
  15. package/lib/commonjs/handlers/gestures/gesture.js.map +1 -1
  16. package/lib/commonjs/handlers/gestures/manualGesture.js +12 -0
  17. package/lib/commonjs/handlers/gestures/manualGesture.js.map +1 -1
  18. package/lib/commonjs/handlers/gestures/panGesture.js +28 -0
  19. package/lib/commonjs/handlers/gestures/panGesture.js.map +1 -1
  20. package/lib/commonjs/handlers/gestures/pinchGesture.js +26 -0
  21. package/lib/commonjs/handlers/gestures/pinchGesture.js.map +1 -1
  22. package/lib/commonjs/handlers/gestures/rotationGesture.js +26 -0
  23. package/lib/commonjs/handlers/gestures/rotationGesture.js.map +1 -1
  24. package/lib/commonjs/index.js +0 -106
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/module/handlers/gestures/GestureDetector.js +27 -3
  27. package/lib/module/handlers/gestures/GestureDetector.js.map +1 -1
  28. package/lib/module/handlers/gestures/eventReceiver.js +34 -11
  29. package/lib/module/handlers/gestures/eventReceiver.js.map +1 -1
  30. package/lib/module/handlers/gestures/forceTouchGesture.js +27 -0
  31. package/lib/module/handlers/gestures/forceTouchGesture.js.map +1 -1
  32. package/lib/module/handlers/gestures/gesture.js +22 -6
  33. package/lib/module/handlers/gestures/gesture.js.map +1 -1
  34. package/lib/module/handlers/gestures/manualGesture.js +13 -0
  35. package/lib/module/handlers/gestures/manualGesture.js.map +1 -1
  36. package/lib/module/handlers/gestures/panGesture.js +29 -0
  37. package/lib/module/handlers/gestures/panGesture.js.map +1 -1
  38. package/lib/module/handlers/gestures/pinchGesture.js +27 -0
  39. package/lib/module/handlers/gestures/pinchGesture.js.map +1 -1
  40. package/lib/module/handlers/gestures/rotationGesture.js +27 -0
  41. package/lib/module/handlers/gestures/rotationGesture.js.map +1 -1
  42. package/lib/module/index.js +0 -11
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/typescript/handlers/ForceTouchGestureHandler.d.ts +1 -1
  45. package/lib/typescript/handlers/gestures/forceTouchGesture.d.ts +7 -1
  46. package/lib/typescript/handlers/gestures/gesture.d.ts +14 -7
  47. package/lib/typescript/handlers/gestures/manualGesture.d.ts +3 -1
  48. package/lib/typescript/handlers/gestures/panGesture.d.ts +8 -1
  49. package/lib/typescript/handlers/gestures/pinchGesture.d.ts +7 -1
  50. package/lib/typescript/handlers/gestures/rotationGesture.d.ts +7 -1
  51. package/lib/typescript/handlers/handlersRegistry.d.ts +1 -1
  52. package/lib/typescript/index.d.ts +11 -11
  53. package/lib/typescript/web/constants.d.ts +0 -1
  54. package/package.json +2 -1
  55. package/src/handlers/gestures/GestureDetector.tsx +31 -2
  56. package/src/handlers/gestures/eventReceiver.ts +24 -2
  57. package/src/handlers/gestures/forceTouchGesture.ts +43 -1
  58. package/src/handlers/gestures/gesture.ts +42 -12
  59. package/src/handlers/gestures/manualGesture.ts +21 -1
  60. package/src/handlers/gestures/panGesture.ts +43 -1
  61. package/src/handlers/gestures/pinchGesture.ts +40 -1
  62. package/src/handlers/gestures/rotationGesture.ts +40 -1
  63. package/src/index.ts +11 -11
  64. package/ios/RNGestureHandler.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/RNGestureHandler.xcscheme +0 -80
  65. package/ios/RNGestureHandler.xcodeproj/xcuserdata/mdk.xcuserdatad/xcschemes/xcschememanagement.plist +0 -27
@@ -1,11 +1,31 @@
1
+ import { GestureUpdateEvent } from '../gestureHandlerCommon';
1
2
  import { ContinousBaseGesture } from './gesture';
2
3
 
3
- export class ManualGesture extends ContinousBaseGesture<Record<string, never>> {
4
+ function changeEventCalculator(
5
+ current: GestureUpdateEvent<Record<string, never>>,
6
+ _previous?: GestureUpdateEvent<Record<string, never>>
7
+ ) {
8
+ 'worklet';
9
+ return current;
10
+ }
11
+
12
+ export class ManualGesture extends ContinousBaseGesture<
13
+ Record<string, never>,
14
+ Record<string, never>
15
+ > {
4
16
  constructor() {
5
17
  super();
6
18
 
7
19
  this.handlerName = 'ManualGestureHandler';
8
20
  }
21
+
22
+ onChange(
23
+ callback: (event: GestureUpdateEvent<Record<string, never>>) => void
24
+ ) {
25
+ // @ts-ignore TS being overprotective, Record<string, never> is Record
26
+ this.handlers.changeEventCalculator = changeEventCalculator;
27
+ return super.onChange(callback);
28
+ }
9
29
  }
10
30
 
11
31
  export type ManualGestureType = InstanceType<typeof ManualGesture>;
@@ -1,10 +1,40 @@
1
1
  import { BaseGestureConfig, ContinousBaseGesture } from './gesture';
2
+ import { GestureUpdateEvent } from '../gestureHandlerCommon';
2
3
  import {
3
4
  PanGestureConfig,
4
5
  PanGestureHandlerEventPayload,
5
6
  } from '../PanGestureHandler';
6
7
 
7
- export class PanGesture extends ContinousBaseGesture<PanGestureHandlerEventPayload> {
8
+ type PanGestureChangeEventPayload = {
9
+ changeX: number;
10
+ changeY: number;
11
+ };
12
+
13
+ function changeEventCalculator(
14
+ current: GestureUpdateEvent<PanGestureHandlerEventPayload>,
15
+ previous?: GestureUpdateEvent<PanGestureHandlerEventPayload>
16
+ ) {
17
+ 'worklet';
18
+ let changePayload: PanGestureChangeEventPayload;
19
+ if (previous === undefined) {
20
+ changePayload = {
21
+ changeX: current.translationX,
22
+ changeY: current.translationY,
23
+ };
24
+ } else {
25
+ changePayload = {
26
+ changeX: current.translationX - previous.translationX,
27
+ changeY: current.translationY - previous.translationY,
28
+ };
29
+ }
30
+
31
+ return { ...current, ...changePayload };
32
+ }
33
+
34
+ export class PanGesture extends ContinousBaseGesture<
35
+ PanGestureHandlerEventPayload,
36
+ PanGestureChangeEventPayload
37
+ > {
8
38
  public config: BaseGestureConfig & PanGestureConfig = {};
9
39
 
10
40
  constructor() {
@@ -100,6 +130,18 @@ export class PanGesture extends ContinousBaseGesture<PanGestureHandlerEventPaylo
100
130
  this.config.enableTrackpadTwoFingerGesture = value;
101
131
  return this;
102
132
  }
133
+
134
+ onChange(
135
+ callback: (
136
+ event: GestureUpdateEvent<
137
+ PanGestureHandlerEventPayload & PanGestureChangeEventPayload
138
+ >
139
+ ) => void
140
+ ) {
141
+ // @ts-ignore TS being overprotective, PanGestureHandlerEventPayload is Record
142
+ this.handlers.changeEventCalculator = changeEventCalculator;
143
+ return super.onChange(callback);
144
+ }
103
145
  }
104
146
 
105
147
  export type PanGestureType = InstanceType<typeof PanGesture>;
@@ -1,12 +1,51 @@
1
1
  import { ContinousBaseGesture } from './gesture';
2
2
  import { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';
3
+ import { GestureUpdateEvent } from '../gestureHandlerCommon';
3
4
 
4
- export class PinchGesture extends ContinousBaseGesture<PinchGestureHandlerEventPayload> {
5
+ type PinchGestureChangeEventPayload = {
6
+ scaleChange: number;
7
+ };
8
+
9
+ function changeEventCalculator(
10
+ current: GestureUpdateEvent<PinchGestureHandlerEventPayload>,
11
+ previous?: GestureUpdateEvent<PinchGestureHandlerEventPayload>
12
+ ) {
13
+ 'worklet';
14
+ let changePayload: PinchGestureChangeEventPayload;
15
+ if (previous === undefined) {
16
+ changePayload = {
17
+ scaleChange: current.scale,
18
+ };
19
+ } else {
20
+ changePayload = {
21
+ scaleChange: current.scale / previous.scale,
22
+ };
23
+ }
24
+
25
+ return { ...current, ...changePayload };
26
+ }
27
+
28
+ export class PinchGesture extends ContinousBaseGesture<
29
+ PinchGestureHandlerEventPayload,
30
+ PinchGestureChangeEventPayload
31
+ > {
5
32
  constructor() {
6
33
  super();
7
34
 
8
35
  this.handlerName = 'PinchGestureHandler';
9
36
  }
37
+
38
+ onChange(
39
+ callback: (
40
+ event: GestureUpdateEvent<
41
+ PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload
42
+ >
43
+ ) => void
44
+ ) {
45
+ // @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record
46
+ this.handlers.changeEventCalculator = changeEventCalculator;
47
+ return super.onChange(callback);
48
+ }
10
49
  }
11
50
 
12
51
  export type PinchGestureType = InstanceType<typeof PinchGesture>;
@@ -1,12 +1,51 @@
1
1
  import { ContinousBaseGesture } from './gesture';
2
2
  import { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';
3
+ import { GestureUpdateEvent } from '../gestureHandlerCommon';
3
4
 
4
- export class RotationGesture extends ContinousBaseGesture<RotationGestureHandlerEventPayload> {
5
+ type RotationGestureChangeEventPayload = {
6
+ rotationChange: number;
7
+ };
8
+
9
+ function changeEventCalculator(
10
+ current: GestureUpdateEvent<RotationGestureHandlerEventPayload>,
11
+ previous?: GestureUpdateEvent<RotationGestureHandlerEventPayload>
12
+ ) {
13
+ 'worklet';
14
+ let changePayload: RotationGestureChangeEventPayload;
15
+ if (previous === undefined) {
16
+ changePayload = {
17
+ rotationChange: current.rotation,
18
+ };
19
+ } else {
20
+ changePayload = {
21
+ rotationChange: current.rotation - previous.rotation,
22
+ };
23
+ }
24
+
25
+ return { ...current, ...changePayload };
26
+ }
27
+
28
+ export class RotationGesture extends ContinousBaseGesture<
29
+ RotationGestureHandlerEventPayload,
30
+ RotationGestureChangeEventPayload
31
+ > {
5
32
  constructor() {
6
33
  super();
7
34
 
8
35
  this.handlerName = 'RotationGestureHandler';
9
36
  }
37
+
38
+ onChange(
39
+ callback: (
40
+ event: GestureUpdateEvent<
41
+ RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload
42
+ >
43
+ ) => void
44
+ ) {
45
+ // @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record
46
+ this.handlers.changeEventCalculator = changeEventCalculator;
47
+ return super.onChange(callback);
48
+ }
10
49
  }
11
50
 
12
51
  export type RotationGestureType = InstanceType<typeof RotationGesture>;
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,
@@ -1,80 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Scheme
3
- LastUpgradeVersion = "0830"
4
- version = "1.3">
5
- <BuildAction
6
- parallelizeBuildables = "YES"
7
- buildImplicitDependencies = "YES">
8
- <BuildActionEntries>
9
- <BuildActionEntry
10
- buildForTesting = "YES"
11
- buildForRunning = "YES"
12
- buildForProfiling = "YES"
13
- buildForArchiving = "YES"
14
- buildForAnalyzing = "YES">
15
- <BuildableReference
16
- BuildableIdentifier = "primary"
17
- BlueprintIdentifier = "58B511DA1A9E6C8500147676"
18
- BuildableName = "libRNGestureHandler.a"
19
- BlueprintName = "RNGestureHandler"
20
- ReferencedContainer = "container:RNGestureHandler.xcodeproj">
21
- </BuildableReference>
22
- </BuildActionEntry>
23
- </BuildActionEntries>
24
- </BuildAction>
25
- <TestAction
26
- buildConfiguration = "Debug"
27
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29
- shouldUseLaunchSchemeArgsEnv = "YES">
30
- <Testables>
31
- </Testables>
32
- <AdditionalOptions>
33
- </AdditionalOptions>
34
- </TestAction>
35
- <LaunchAction
36
- buildConfiguration = "Debug"
37
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
38
- selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
39
- launchStyle = "0"
40
- useCustomWorkingDirectory = "NO"
41
- ignoresPersistentStateOnLaunch = "NO"
42
- debugDocumentVersioning = "YES"
43
- debugServiceExtension = "internal"
44
- allowLocationSimulation = "YES">
45
- <MacroExpansion>
46
- <BuildableReference
47
- BuildableIdentifier = "primary"
48
- BlueprintIdentifier = "58B511DA1A9E6C8500147676"
49
- BuildableName = "libRNGestureHandler.a"
50
- BlueprintName = "RNGestureHandler"
51
- ReferencedContainer = "container:RNGestureHandler.xcodeproj">
52
- </BuildableReference>
53
- </MacroExpansion>
54
- <AdditionalOptions>
55
- </AdditionalOptions>
56
- </LaunchAction>
57
- <ProfileAction
58
- buildConfiguration = "Release"
59
- shouldUseLaunchSchemeArgsEnv = "YES"
60
- savedToolIdentifier = ""
61
- useCustomWorkingDirectory = "NO"
62
- debugDocumentVersioning = "YES">
63
- <MacroExpansion>
64
- <BuildableReference
65
- BuildableIdentifier = "primary"
66
- BlueprintIdentifier = "58B511DA1A9E6C8500147676"
67
- BuildableName = "libRNGestureHandler.a"
68
- BlueprintName = "RNGestureHandler"
69
- ReferencedContainer = "container:RNGestureHandler.xcodeproj">
70
- </BuildableReference>
71
- </MacroExpansion>
72
- </ProfileAction>
73
- <AnalyzeAction
74
- buildConfiguration = "Debug">
75
- </AnalyzeAction>
76
- <ArchiveAction
77
- buildConfiguration = "Release"
78
- revealArchiveInOrganizer = "YES">
79
- </ArchiveAction>
80
- </Scheme>
@@ -1,27 +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</key>
13
- <dict>
14
- <key>orderHint</key>
15
- <integer>0</integer>
16
- </dict>
17
- </dict>
18
- <key>SuppressBuildableAutocreation</key>
19
- <dict>
20
- <key>58B511DA1A9E6C8500147676</key>
21
- <dict>
22
- <key>primary</key>
23
- <true/>
24
- </dict>
25
- </dict>
26
- </dict>
27
- </plist>