react-native-screen-transitions 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/lib/commonjs/constants.js.map +1 -1
  2. package/lib/commonjs/hooks/animation/use-screen-animation.js +9 -5
  3. package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -1
  4. package/lib/commonjs/providers/transition-styles.js +18 -4
  5. package/lib/commonjs/providers/transition-styles.js.map +1 -1
  6. package/lib/commonjs/utils/animation/derivations.js +1 -14
  7. package/lib/commonjs/utils/animation/derivations.js.map +1 -1
  8. package/lib/commonjs/utils/bounds/constants.js.map +1 -1
  9. package/lib/commonjs/utils/bounds/index.js +23 -90
  10. package/lib/commonjs/utils/bounds/index.js.map +1 -1
  11. package/lib/commonjs/utils/gesture/apply-offset-rules.js.map +1 -1
  12. package/lib/commonjs/utils/gesture/check-gesture-activation.js.map +1 -1
  13. package/lib/module/constants.js.map +1 -1
  14. package/lib/module/hooks/animation/use-screen-animation.js +9 -5
  15. package/lib/module/hooks/animation/use-screen-animation.js.map +1 -1
  16. package/lib/module/providers/transition-styles.js +19 -5
  17. package/lib/module/providers/transition-styles.js.map +1 -1
  18. package/lib/module/utils/animation/derivations.js +1 -14
  19. package/lib/module/utils/animation/derivations.js.map +1 -1
  20. package/lib/module/utils/bounds/constants.js.map +1 -1
  21. package/lib/module/utils/bounds/index.js +24 -91
  22. package/lib/module/utils/bounds/index.js.map +1 -1
  23. package/lib/module/utils/gesture/apply-offset-rules.js.map +1 -1
  24. package/lib/module/utils/gesture/check-gesture-activation.js.map +1 -1
  25. package/lib/typescript/constants.d.ts +2 -2
  26. package/lib/typescript/constants.d.ts.map +1 -1
  27. package/lib/typescript/hooks/animation/use-screen-animation.d.ts +1 -1
  28. package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -1
  29. package/lib/typescript/index.d.ts +8 -8
  30. package/lib/typescript/providers/transition-styles.d.ts.map +1 -1
  31. package/lib/typescript/types/animation.d.ts +2 -4
  32. package/lib/typescript/types/animation.d.ts.map +1 -1
  33. package/lib/typescript/types/bounds.d.ts +0 -57
  34. package/lib/typescript/types/bounds.d.ts.map +1 -1
  35. package/lib/typescript/types/navigator.d.ts +4 -0
  36. package/lib/typescript/types/navigator.d.ts.map +1 -1
  37. package/lib/typescript/utils/animation/derivations.d.ts +1 -4
  38. package/lib/typescript/utils/animation/derivations.d.ts.map +1 -1
  39. package/lib/typescript/utils/bounds/_types/builder.d.ts +2 -2
  40. package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -1
  41. package/lib/typescript/utils/bounds/_utils/geometry.d.ts +2 -2
  42. package/lib/typescript/utils/bounds/_utils/geometry.d.ts.map +1 -1
  43. package/lib/typescript/utils/bounds/constants.d.ts +2 -2
  44. package/lib/typescript/utils/bounds/constants.d.ts.map +1 -1
  45. package/lib/typescript/utils/bounds/index.d.ts +4 -4
  46. package/lib/typescript/utils/bounds/index.d.ts.map +1 -1
  47. package/lib/typescript/utils/gesture/apply-offset-rules.d.ts +2 -2
  48. package/lib/typescript/utils/gesture/apply-offset-rules.d.ts.map +1 -1
  49. package/lib/typescript/utils/gesture/check-gesture-activation.d.ts +2 -2
  50. package/lib/typescript/utils/gesture/check-gesture-activation.d.ts.map +1 -1
  51. package/package.json +1 -1
  52. package/src/constants.ts +2 -2
  53. package/src/hooks/animation/use-screen-animation.tsx +51 -46
  54. package/src/providers/transition-styles.tsx +24 -11
  55. package/src/types/animation.ts +2 -4
  56. package/src/types/bounds.ts +0 -64
  57. package/src/types/navigator.ts +5 -0
  58. package/src/utils/animation/derivations.ts +3 -20
  59. package/src/utils/bounds/_types/builder.ts +2 -2
  60. package/src/utils/bounds/_utils/geometry.ts +2 -2
  61. package/src/utils/bounds/constants.ts +2 -2
  62. package/src/utils/bounds/index.ts +35 -105
  63. package/src/utils/gesture/apply-offset-rules.ts +3 -3
  64. package/src/utils/gesture/check-gesture-activation.ts +3 -3
@@ -1,16 +1,18 @@
1
- import type { ScaledSize } from "react-native";
2
1
  import type { MeasuredDimensions } from "react-native-reanimated";
3
2
  import {
4
- DEFAULT_BUILDER_OPTIONS,
5
3
  EMPTY_BOUND_HELPER_RESULT,
6
4
  EMPTY_BOUND_HELPER_RESULT_RAW,
7
5
  ENTER_RANGE,
8
6
  EXIT_RANGE,
9
7
  FULLSCREEN_DIMENSIONS,
10
8
  } from "../../constants";
11
- import type { ScreenTransitionState } from "../../types/animation";
12
- import type { BoundsAccessor, BoundsBuilder } from "../../types/bounds";
9
+ import type {
10
+ ScreenInterpolationProps,
11
+ ScreenTransitionState,
12
+ } from "../../types/animation";
13
+ import type { BoundsAccessor } from "../../types/bounds";
13
14
  import type { ScreenPhase } from "../../types/core";
15
+ import type { Layout } from "../../types/navigator";
14
16
  import type {
15
17
  BoundsBuilderInitParams,
16
18
  BoundsBuilderOptions,
@@ -35,7 +37,7 @@ export interface BuildBoundsAccessorParams {
35
37
  previous?: ScreenTransitionState;
36
38
  next?: ScreenTransitionState;
37
39
  progress: number;
38
- dimensions: ScaledSize;
40
+ dimensions: Layout;
39
41
  }
40
42
 
41
43
  const resolveBounds = (props: {
@@ -44,7 +46,7 @@ const resolveBounds = (props: {
44
46
  current?: ScreenTransitionState;
45
47
  next?: ScreenTransitionState;
46
48
  toRect?: Partial<MeasuredDimensions>;
47
- dimensions: ScaledSize;
49
+ dimensions: Layout;
48
50
  computeOptions: BoundsBuilderOptions;
49
51
  }) => {
50
52
  "worklet";
@@ -180,110 +182,38 @@ const computeBoundStyles = (
180
182
  : composeTransformRelative(common);
181
183
  };
182
184
 
183
- /**
184
- * @deprecated Use `createBounds` instead. We'll avoid using the builder pattern for this type of function.
185
- */
186
- const buildBoundStyles = (params: BoundsBuilderInitParams): BoundsBuilder => {
185
+ export const createBounds = (
186
+ props: Omit<ScreenInterpolationProps, "bounds">,
187
+ ): BoundsAccessor => {
187
188
  "worklet";
188
189
 
189
- const cfg: { options: BoundsBuilderOptions } = {
190
- options: { ...DEFAULT_BUILDER_OPTIONS },
190
+ const boundsFunction = (params?: BoundsBuilderOptions) => {
191
+ "worklet";
192
+ const id = params?.id ?? props.activeBoundId;
193
+
194
+ return computeBoundStyles(
195
+ {
196
+ id,
197
+ current: props.current,
198
+ previous: props.previous,
199
+ next: props.next,
200
+ progress: props.progress,
201
+ dimensions: props.layouts.screen,
202
+ },
203
+ params,
204
+ );
191
205
  };
192
206
 
193
- const builder = (): BoundsBuilder => ({
194
- gestures: (options) => {
195
- cfg.options.gestures = options;
196
- return builder();
197
- },
198
- toFullscreen: () => {
199
- cfg.options.toFullscreen = true;
200
- return builder();
201
- },
202
- absolute: () => {
203
- cfg.options.absolute = true;
204
- cfg.options.relative = false;
205
- return builder();
206
- },
207
- relative: () => {
208
- cfg.options.relative = true;
209
- cfg.options.absolute = false;
210
- return builder();
211
- },
212
- transform: () => {
213
- cfg.options.method = "transform";
214
- return builder();
215
- },
216
- size: () => {
217
- cfg.options.method = "size";
218
- return builder();
219
- },
220
- content: () => {
221
- cfg.options.method = "content";
222
- return builder();
223
- },
224
- contentFill: () => {
225
- cfg.options.contentScaleMode = "aspectFill";
226
- return builder();
227
- },
228
- contentFit: () => {
229
- cfg.options.contentScaleMode = "aspectFit";
230
- return builder();
231
- },
232
-
233
- build: () => {
234
- return computeBoundStyles(params, cfg.options);
235
- },
236
- });
237
-
238
- return builder();
239
- };
240
-
241
- export const createBounds = ({
242
- activeBoundId,
243
- current,
244
- previous,
245
- next,
246
- progress,
247
- dimensions,
248
- }: BuildBoundsAccessorParams): BoundsAccessor => {
249
- "worklet";
250
-
251
- const bounds: BoundsAccessor = ((params?: string | BoundsBuilderOptions) => {
252
- if (typeof params === "object") {
253
- const id = params.id ?? activeBoundId;
254
-
255
- return computeBoundStyles(
256
- {
257
- id,
258
- current,
259
- previous,
260
- next,
261
- progress,
262
- dimensions,
263
- },
264
- params,
265
- );
266
- }
267
-
268
- const id = typeof params === "string" ? params : activeBoundId;
269
- return buildBoundStyles({
270
- id,
271
- current,
272
- previous,
273
- next,
274
- progress,
275
- dimensions,
276
- });
277
- }) as BoundsAccessor;
278
-
279
- bounds.get = (id?: string, phase?: ScreenPhase) =>
280
- getBounds({
281
- id: id ?? activeBoundId,
207
+ const get = (id?: string, phase?: ScreenPhase) => {
208
+ "worklet";
209
+ return getBounds({
210
+ id: id ?? props.activeBoundId,
282
211
  phase,
283
- current,
284
- previous,
285
- next,
212
+ current: props.current,
213
+ previous: props.previous,
214
+ next: props.next,
286
215
  });
216
+ };
287
217
 
288
- return bounds;
218
+ return Object.assign(boundsFunction, { get }) as BoundsAccessor;
289
219
  };
@@ -1,4 +1,3 @@
1
- import type { ScaledSize } from "react-native";
2
1
  import type { GestureStateManagerType } from "react-native-gesture-handler/lib/typescript/handlers/gestures/gestureStateManager";
3
2
  import type { SharedValue } from "react-native-reanimated";
4
3
  import {
@@ -16,6 +15,7 @@ import {
16
15
  GestureOffsetState,
17
16
  type SideActivation,
18
17
  } from "../../types/gesture";
18
+ import type { Layout } from "../../types/navigator";
19
19
 
20
20
  type Directions = {
21
21
  vertical: boolean;
@@ -31,7 +31,7 @@ interface CheckGestureActivationProps {
31
31
  manager?: GestureStateManagerType;
32
32
  gestureOffsetState: SharedValue<GestureOffsetState>;
33
33
  activationArea?: GestureActivationArea;
34
- dimensions: ScaledSize;
34
+ dimensions: Layout;
35
35
  responseDistance?: number;
36
36
  }
37
37
 
@@ -88,7 +88,7 @@ function normalizeSides(area?: GestureActivationArea): NormalizedSides {
88
88
 
89
89
  function computeEdgeConstraints(
90
90
  initialTouch: { x: number; y: number },
91
- dimensions: ScaledSize,
91
+ dimensions: Layout,
92
92
  sides: NormalizedSides,
93
93
  responseDistance?: number,
94
94
  ) {
@@ -1,4 +1,3 @@
1
- import type { ScaledSize } from "react-native";
2
1
  import type { GestureStateManagerType } from "react-native-gesture-handler/lib/typescript/handlers/gestures/gestureStateManager";
3
2
  import type { SharedValue } from "react-native-reanimated";
4
3
  import {
@@ -7,6 +6,7 @@ import {
7
6
  GestureOffsetState,
8
7
  type SideActivation,
9
8
  } from "../../types/gesture";
9
+ import type { Layout } from "../../types/navigator";
10
10
 
11
11
  type Directions = {
12
12
  vertical: boolean;
@@ -22,7 +22,7 @@ interface CheckGestureActivationProps {
22
22
  manager?: GestureStateManagerType;
23
23
  gestureOffsetState: SharedValue<GestureOffsetState>;
24
24
  activationArea?: GestureActivationArea;
25
- dimensions: ScaledSize;
25
+ dimensions: Layout;
26
26
  responseDistance?: number;
27
27
  }
28
28
 
@@ -90,7 +90,7 @@ function normalizeSides(area?: GestureActivationArea): NormalizedSides {
90
90
 
91
91
  function computeEdgeConstraints(
92
92
  initialTouch: { x: number; y: number },
93
- dimensions: ScaledSize,
93
+ dimensions: Layout,
94
94
  sides: NormalizedSides,
95
95
  responseDistance?: number,
96
96
  ) {