@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.
- package/CHANGELOG.md +51 -1
- package/README.md +7 -1
- package/dist/chunk-24NUL23E.js +8 -0
- package/dist/chunk-4XBX7KOD.js +8 -0
- package/dist/{chunk-OBRGJAST.js → chunk-6AN5X3YE.js} +3 -3
- package/dist/{chunk-5MGWHOSV.js → chunk-6NOCY764.js} +2 -2
- package/dist/{chunk-PFPO7DX2.mjs → chunk-6YIUETBF.mjs} +1 -1
- package/dist/{chunk-767UKZXG.js → chunk-E3ALFSH2.js} +76 -33
- package/dist/chunk-EN4PN7X3.mjs +22 -0
- package/dist/{chunk-CMHVF6F4.mjs → chunk-GSUC4HWP.mjs} +1 -1
- package/dist/chunk-IHVMNOS4.js +28 -0
- package/dist/{chunk-2ICQLWH2.mjs → chunk-IX6SEOSK.mjs} +53 -12
- package/dist/{chunk-C3EDC5ZW.mjs → chunk-JBK5ZLMH.mjs} +1 -1
- package/dist/{chunk-OW5XTGVN.mjs → chunk-L4JFECXU.mjs} +2 -2
- package/dist/{chunk-BAAQI37F.mjs → chunk-M4766VUV.mjs} +1 -1
- package/dist/{chunk-Z3HCJ43H.mjs → chunk-MFAFB4K7.mjs} +1 -1
- package/dist/{chunk-4NAMD62I.js → chunk-MUT6BTZS.js} +7 -7
- package/dist/{chunk-F7LJX56B.mjs → chunk-QNLSCOR5.mjs} +1 -1
- package/dist/{chunk-REYL77RE.mjs → chunk-W7NTRSPD.mjs} +17 -10
- package/dist/{chunk-PM6CVGXJ.js → chunk-WNVHPMBI.js} +16 -8
- package/dist/chunk-Z5USXWTE.js +8 -0
- package/dist/{chunk-X7B5WR5A.js → chunk-ZBHQPVWE.js} +2 -2
- package/dist/gestureLayer/index.d.mts +2 -2
- package/dist/gestureLayer/index.d.ts +2 -2
- package/dist/gestureLayer/index.js +10 -10
- package/dist/gestureLayer/index.mjs +3 -3
- package/dist/index.d.mts +89 -10
- package/dist/index.d.ts +89 -10
- package/dist/index.js +67 -49
- package/dist/index.mjs +21 -18
- package/dist/motion/FlatList.d.mts +53 -0
- package/dist/motion/FlatList.d.ts +53 -0
- package/dist/motion/FlatList.js +13 -0
- package/dist/motion/FlatList.mjs +4 -0
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +5 -5
- package/dist/motion/Image.mjs +4 -4
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +5 -5
- package/dist/motion/Pressable.mjs +4 -4
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +5 -5
- package/dist/motion/ScrollView.mjs +4 -4
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +5 -5
- package/dist/motion/Text.mjs +4 -4
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +5 -5
- package/dist/motion/View.mjs +4 -4
- package/dist/touch/index.d.mts +1 -1
- package/dist/touch/index.d.ts +1 -1
- package/dist/touch/index.js +3 -3
- package/dist/touch/index.mjs +1 -1
- package/dist/{types-BQgLJeQG.d.mts → types-DyJpG64F.d.mts} +1 -1
- package/dist/{types-BQgLJeQG.d.ts → types-DyJpG64F.d.ts} +1 -1
- package/dist/{useGesture-DfaTx-3t.d.mts → useGesture-CnZQnYHH.d.mts} +1 -1
- package/dist/{useGesture-B0_CzOUz.d.ts → useGesture-DbH46EBp.d.ts} +1 -1
- package/jest-setup.js +7 -1
- package/llms.txt +25 -4
- package/package.json +8 -1
- package/src/index.ts +5 -0
- package/src/motion/FlatList.tsx +77 -0
- package/src/motion/createMotionComponent.tsx +68 -10
- package/src/motion/index.ts +3 -0
- package/src/stagger/Stagger.tsx +75 -0
- package/src/stagger/StaggerContext.ts +25 -0
- package/src/stagger/index.ts +2 -0
- package/src/transitions/index.ts +6 -1
- package/src/transitions/resolve.ts +7 -1
- package/src/transitions/runtime.ts +22 -7
- package/src/values/useScroll.ts +9 -5
- package/dist/chunk-FWWVHLXB.js +0 -8
- package/dist/chunk-K5SI6VXS.js +0 -8
- 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')
|
|
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(
|
|
58
|
-
|
|
59
|
-
|
|
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
|
}
|
package/src/values/useScroll.ts
CHANGED
|
@@ -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
|
|
15
|
-
*
|
|
16
|
-
* as a worklet — but the type narrows to the same
|
|
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
|
|
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)
|
package/dist/chunk-FWWVHLXB.js
DELETED
package/dist/chunk-K5SI6VXS.js
DELETED
package/dist/chunk-STARIT6W.js
DELETED