@rootnative/inertia 0.0.1 → 0.0.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/CHANGELOG.md +36 -2
- package/dist/{chunk-TDSO63CJ.js → chunk-3XTVY34H.js} +2 -2
- package/dist/{chunk-NXDJZD6A.mjs → chunk-46P57VMY.mjs} +1 -1
- package/dist/{chunk-7UDYEFBU.js → chunk-BP3Y2SHQ.js} +477 -298
- package/dist/{chunk-6SMPIOIC.mjs → chunk-BQQTHG2V.mjs} +1 -1
- package/dist/{chunk-DWCLIBYO.mjs → chunk-CSODMRJ7.mjs} +478 -299
- package/dist/chunk-FNVFV4EY.js +8 -0
- package/dist/chunk-FWQOXA43.js +8 -0
- package/dist/chunk-KBP4LR75.js +8 -0
- package/dist/{chunk-ALRHDFZE.mjs → chunk-O22NXXCZ.mjs} +1 -1
- package/dist/{chunk-CWLFUYIY.mjs → chunk-OQV66TBQ.mjs} +1 -1
- package/dist/{chunk-JVBXPF2G.mjs → chunk-SGUHE5CX.mjs} +1 -1
- package/dist/{chunk-2HYD2ZBK.js → chunk-W5MC3P4N.js} +2 -2
- package/dist/index.d.mts +231 -43
- package/dist/index.d.ts +231 -43
- package/dist/index.js +212 -23
- package/dist/index.mjs +204 -18
- package/dist/motion/Image.js +3 -3
- package/dist/motion/Image.mjs +2 -2
- package/dist/motion/Pressable.js +3 -3
- package/dist/motion/Pressable.mjs +2 -2
- package/dist/motion/ScrollView.js +3 -3
- package/dist/motion/ScrollView.mjs +2 -2
- package/dist/motion/Text.js +3 -3
- package/dist/motion/Text.mjs +2 -2
- package/dist/motion/View.js +3 -3
- package/dist/motion/View.mjs +2 -2
- package/llms.txt +5 -0
- package/package.json +1 -1
- package/src/index.ts +10 -0
- package/src/layout/index.ts +1 -0
- package/src/layout/sharedRegistry.ts +51 -2
- package/src/motion/createMotionComponent.tsx +781 -502
- package/src/presence/Presence.tsx +73 -10
- package/src/values/index.ts +13 -0
- package/src/values/useAnimation.ts +15 -1
- package/src/values/useAnimator.ts +83 -0
- package/src/values/useColorCascade.ts +125 -0
- package/src/values/useInterpolatedStyle.ts +319 -0
- package/src/values/useMotionValue.ts +20 -2
- package/src/values/useSpring.ts +12 -0
- package/dist/chunk-3UTJJ4A3.js +0 -8
- package/dist/chunk-4QGXK6TF.js +0 -8
- package/dist/chunk-Z7HIOFKQ.js +0 -8
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
cancelAnimation,
|
|
4
|
+
useSharedValue,
|
|
5
|
+
type SharedValue,
|
|
6
|
+
} from 'react-native-reanimated'
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* Create an animatable value owned by JS but readable from worklets.
|
|
@@ -40,5 +45,18 @@ export function useMotionValue<T extends number | string>(
|
|
|
40
45
|
export function useMotionValue<T extends number | string>(
|
|
41
46
|
initial: T,
|
|
42
47
|
): SharedValue<T> {
|
|
43
|
-
|
|
48
|
+
const sv = useSharedValue<T>(initial)
|
|
49
|
+
// Cancel any in-flight animation when the owning component unmounts, so a
|
|
50
|
+
// mid-flight (or infinite-repeat) `withX` driving this value stops ticking
|
|
51
|
+
// its worklet once the value is orphaned. The shared value is
|
|
52
|
+
// identity-stable per hook instance and owned by this component, so
|
|
53
|
+
// cancelling on unmount is always safe. Mid-life cancellation stays the
|
|
54
|
+
// consumer's job via the `/reanimated` interop `cancelAnimation`.
|
|
55
|
+
useEffect(
|
|
56
|
+
() => () => cancelAnimation(sv),
|
|
57
|
+
// `sv` is identity-stable per hook instance (Reanimated guarantee).
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
[],
|
|
60
|
+
)
|
|
61
|
+
return sv
|
|
44
62
|
}
|
package/src/values/useSpring.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo } from 'react'
|
|
2
2
|
import {
|
|
3
|
+
cancelAnimation,
|
|
3
4
|
useAnimatedReaction,
|
|
4
5
|
useSharedValue,
|
|
5
6
|
withSpring,
|
|
@@ -95,6 +96,17 @@ export function useSpring(
|
|
|
95
96
|
[isSharedTarget, reanimConfig],
|
|
96
97
|
)
|
|
97
98
|
|
|
99
|
+
// Stop the in-flight spring when the owning component unmounts so its
|
|
100
|
+
// worklet doesn't keep ticking against an orphaned value. `output` is
|
|
101
|
+
// identity-stable per hook instance and owned here, so cancelling on
|
|
102
|
+
// unmount is always safe.
|
|
103
|
+
useEffect(
|
|
104
|
+
() => () => cancelAnimation(output),
|
|
105
|
+
// `output` is identity-stable per hook instance (Reanimated guarantee).
|
|
106
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
107
|
+
[],
|
|
108
|
+
)
|
|
109
|
+
|
|
98
110
|
return output
|
|
99
111
|
}
|
|
100
112
|
|
package/dist/chunk-3UTJJ4A3.js
DELETED
package/dist/chunk-4QGXK6TF.js
DELETED
package/dist/chunk-Z7HIOFKQ.js
DELETED