@rootnative/inertia 0.0.6 → 0.0.8

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 (79) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/README.md +7 -1
  3. package/dist/chunk-24NUL23E.js +8 -0
  4. package/dist/chunk-4XBX7KOD.js +8 -0
  5. package/dist/{chunk-OBRGJAST.js → chunk-6AN5X3YE.js} +3 -3
  6. package/dist/{chunk-5MGWHOSV.js → chunk-6NOCY764.js} +2 -2
  7. package/dist/{chunk-PFPO7DX2.mjs → chunk-6YIUETBF.mjs} +1 -1
  8. package/dist/{chunk-767UKZXG.js → chunk-E3ALFSH2.js} +76 -33
  9. package/dist/chunk-EN4PN7X3.mjs +22 -0
  10. package/dist/{chunk-CMHVF6F4.mjs → chunk-GSUC4HWP.mjs} +1 -1
  11. package/dist/chunk-IHVMNOS4.js +28 -0
  12. package/dist/{chunk-2ICQLWH2.mjs → chunk-IX6SEOSK.mjs} +53 -12
  13. package/dist/{chunk-C3EDC5ZW.mjs → chunk-JBK5ZLMH.mjs} +1 -1
  14. package/dist/{chunk-OW5XTGVN.mjs → chunk-L4JFECXU.mjs} +2 -2
  15. package/dist/{chunk-BAAQI37F.mjs → chunk-M4766VUV.mjs} +1 -1
  16. package/dist/{chunk-Z3HCJ43H.mjs → chunk-MFAFB4K7.mjs} +1 -1
  17. package/dist/{chunk-4NAMD62I.js → chunk-MUT6BTZS.js} +7 -7
  18. package/dist/{chunk-F7LJX56B.mjs → chunk-QNLSCOR5.mjs} +1 -1
  19. package/dist/{chunk-REYL77RE.mjs → chunk-W7NTRSPD.mjs} +17 -10
  20. package/dist/{chunk-PM6CVGXJ.js → chunk-WNVHPMBI.js} +16 -8
  21. package/dist/chunk-Z5USXWTE.js +8 -0
  22. package/dist/{chunk-X7B5WR5A.js → chunk-ZBHQPVWE.js} +2 -2
  23. package/dist/gestureLayer/index.d.mts +2 -2
  24. package/dist/gestureLayer/index.d.ts +2 -2
  25. package/dist/gestureLayer/index.js +10 -10
  26. package/dist/gestureLayer/index.mjs +3 -3
  27. package/dist/index.d.mts +89 -10
  28. package/dist/index.d.ts +89 -10
  29. package/dist/index.js +67 -49
  30. package/dist/index.mjs +21 -18
  31. package/dist/motion/FlatList.d.mts +53 -0
  32. package/dist/motion/FlatList.d.ts +53 -0
  33. package/dist/motion/FlatList.js +13 -0
  34. package/dist/motion/FlatList.mjs +4 -0
  35. package/dist/motion/Image.d.mts +1 -1
  36. package/dist/motion/Image.d.ts +1 -1
  37. package/dist/motion/Image.js +5 -5
  38. package/dist/motion/Image.mjs +4 -4
  39. package/dist/motion/Pressable.d.mts +1 -1
  40. package/dist/motion/Pressable.d.ts +1 -1
  41. package/dist/motion/Pressable.js +5 -5
  42. package/dist/motion/Pressable.mjs +4 -4
  43. package/dist/motion/ScrollView.d.mts +1 -1
  44. package/dist/motion/ScrollView.d.ts +1 -1
  45. package/dist/motion/ScrollView.js +5 -5
  46. package/dist/motion/ScrollView.mjs +4 -4
  47. package/dist/motion/Text.d.mts +1 -1
  48. package/dist/motion/Text.d.ts +1 -1
  49. package/dist/motion/Text.js +5 -5
  50. package/dist/motion/Text.mjs +4 -4
  51. package/dist/motion/View.d.mts +1 -1
  52. package/dist/motion/View.d.ts +1 -1
  53. package/dist/motion/View.js +5 -5
  54. package/dist/motion/View.mjs +4 -4
  55. package/dist/touch/index.d.mts +1 -1
  56. package/dist/touch/index.d.ts +1 -1
  57. package/dist/touch/index.js +3 -3
  58. package/dist/touch/index.mjs +1 -1
  59. package/dist/{types-BQgLJeQG.d.mts → types-DyJpG64F.d.mts} +1 -1
  60. package/dist/{types-BQgLJeQG.d.ts → types-DyJpG64F.d.ts} +1 -1
  61. package/dist/{useGesture-DfaTx-3t.d.mts → useGesture-CnZQnYHH.d.mts} +1 -1
  62. package/dist/{useGesture-B0_CzOUz.d.ts → useGesture-DbH46EBp.d.ts} +1 -1
  63. package/jest-setup.js +7 -1
  64. package/llms.txt +25 -4
  65. package/package.json +8 -1
  66. package/src/index.ts +5 -0
  67. package/src/motion/FlatList.tsx +77 -0
  68. package/src/motion/createMotionComponent.tsx +68 -10
  69. package/src/motion/index.ts +3 -0
  70. package/src/stagger/Stagger.tsx +75 -0
  71. package/src/stagger/StaggerContext.ts +25 -0
  72. package/src/stagger/index.ts +2 -0
  73. package/src/transitions/index.ts +6 -1
  74. package/src/transitions/resolve.ts +7 -1
  75. package/src/transitions/runtime.ts +22 -7
  76. package/src/values/useScroll.ts +9 -5
  77. package/dist/chunk-FWWVHLXB.js +0 -8
  78. package/dist/chunk-K5SI6VXS.js +0 -8
  79. package/dist/chunk-STARIT6W.js +0 -8
@@ -5,6 +5,7 @@ import {
5
5
  withTiming,
6
6
  } from 'react-native-reanimated'
7
7
  import { springToReanimated } from './spring'
8
+ import { type AnimationCallback } from './resolve'
8
9
  import { type TransitionConfig } from '../types'
9
10
 
10
11
  const DEFAULT_TIMING_DURATION = 250
@@ -26,13 +27,23 @@ const DEFAULT_TIMING_DURATION = 250
26
27
  *
27
28
  * For decay transitions, `toValue` is ignored — decay decelerates from the
28
29
  * SV's current position via its own physics. Pass `0` if you don't have one.
30
+ *
31
+ * `callback`, when provided, fires once when the animation settles — the same
32
+ * `(finished) => void` shape Reanimated's `with*` factories accept. It runs on
33
+ * the UI thread, so bridge to JS with `runOnJS(...)` inside it. For
34
+ * `no-animation` the callback fires synchronously with `finished: true`, since
35
+ * a direct assignment has no settle point of its own.
29
36
  */
30
37
  export function buildReleaseAnimation(
31
38
  transition: TransitionConfig,
32
39
  toValue: number,
40
+ callback?: AnimationCallback,
33
41
  ): unknown {
34
42
  'worklet'
35
- if (transition.type === 'no-animation') return toValue
43
+ if (transition.type === 'no-animation') {
44
+ if (callback) callback(true, toValue)
45
+ return toValue
46
+ }
36
47
  if (transition.type === 'decay') {
37
48
  const cfg: {
38
49
  velocity: number
@@ -43,7 +54,7 @@ export function buildReleaseAnimation(
43
54
  cfg.deceleration = transition.deceleration
44
55
  }
45
56
  if (transition.clamp !== undefined) cfg.clamp = transition.clamp
46
- return withDecay(cfg)
57
+ return withDecay(cfg, callback as never)
47
58
  }
48
59
  if (transition.type === 'timing') {
49
60
  // Reanimated 4's `Easing.bezier(...)` returns an `EasingFunctionFactory`
@@ -54,10 +65,14 @@ export function buildReleaseAnimation(
54
65
  e && typeof e === 'object' && 'factory' in e
55
66
  ? e.factory()
56
67
  : (e ?? Easing.inOut(Easing.ease))
57
- return withTiming(toValue, {
58
- duration: transition.duration ?? DEFAULT_TIMING_DURATION,
59
- easing: easingFn,
60
- })
68
+ return withTiming(
69
+ toValue,
70
+ {
71
+ duration: transition.duration ?? DEFAULT_TIMING_DURATION,
72
+ easing: easingFn,
73
+ },
74
+ callback as never,
75
+ )
61
76
  }
62
- return withSpring(toValue, springToReanimated(transition))
77
+ return withSpring(toValue, springToReanimated(transition), callback as never)
63
78
  }
@@ -11,10 +11,10 @@ export interface UseScrollResult {
11
11
  /** Vertical scroll offset in points. */
12
12
  scrollY: SharedValue<number>
13
13
  /**
14
- * Handler to pass to a `Motion.ScrollView`'s `onScroll` prop (or any other
15
- * Reanimated `Animated.ScrollView`). The handler is opaque to JS it runs
16
- * as a worklet — but the type narrows to the same shape RN's native
17
- * `onScroll` prop expects so it composes cleanly.
14
+ * Handler to pass to the `onScroll` prop of `Motion.ScrollView` or
15
+ * `Motion.FlatList` (or any other Reanimated animated scroller). The handler
16
+ * is opaque to JS — it runs as a worklet — but the type narrows to the same
17
+ * shape RN's native `onScroll` prop expects so it composes cleanly.
18
18
  */
19
19
  onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void
20
20
  }
@@ -47,9 +47,13 @@ export interface UseScrollResult {
47
47
  * read from any worklet (`useAnimatedStyle`, `useDerivedValue`,
48
48
  * `useTransform`) without a JS-thread bounce.
49
49
  *
50
- * Remember to set `scrollEventThrottle={16}` on the `ScrollView` for 60Hz
50
+ * Remember to set `scrollEventThrottle={16}` on a `Motion.ScrollView` for 60Hz
51
51
  * updates — RN's default is to dispatch on every event, which on iOS still
52
52
  * means one per frame, but Android benefits from the explicit cap.
53
+ *
54
+ * `Motion.FlatList` needs no such setting — it defaults `scrollEventThrottle`
55
+ * to 1 for you. Prefer it over `Motion.ScrollView` for long or unbounded lists:
56
+ * it virtualizes, and both accept this handler.
53
57
  */
54
58
  export function useScroll(): UseScrollResult {
55
59
  const scrollX = useSharedValue(0)
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk767UKZXG_js = require('./chunk-767UKZXG.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionImage = chunk767UKZXG_js.createMotionComponent(reactNative.Image);
7
-
8
- exports.MotionImage = MotionImage;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk767UKZXG_js = require('./chunk-767UKZXG.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionView = chunk767UKZXG_js.createMotionComponent(reactNative.View);
7
-
8
- exports.MotionView = MotionView;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk767UKZXG_js = require('./chunk-767UKZXG.js');
4
- var reactNative = require('react-native');
5
-
6
- var MotionText = chunk767UKZXG_js.createMotionComponent(reactNative.Text);
7
-
8
- exports.MotionText = MotionText;