@rootnative/inertia 0.0.8 → 0.0.10

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 (101) hide show
  1. package/CHANGELOG.md +81 -1
  2. package/README.md +7 -7
  3. package/dist/applyBounds-BYGiHrYO.d.mts +18 -0
  4. package/dist/applyBounds-BYGiHrYO.d.ts +18 -0
  5. package/dist/{chunk-E3ALFSH2.js → chunk-2UGWAB6N.js} +78 -70
  6. package/dist/{chunk-ZBHQPVWE.js → chunk-3ZNHPT5Z.js} +2 -2
  7. package/dist/{chunk-IHVMNOS4.js → chunk-46766TBM.js} +2 -2
  8. package/dist/{chunk-MUT6BTZS.js → chunk-4EZ5DBL3.js} +10 -7
  9. package/dist/{chunk-MFAFB4K7.mjs → chunk-6FCATUMY.mjs} +8 -10
  10. package/dist/{chunk-6YIUETBF.mjs → chunk-7BH3CAO5.mjs} +1 -1
  11. package/dist/{chunk-JBK5ZLMH.mjs → chunk-CUHOCONB.mjs} +1 -1
  12. package/dist/{chunk-M4766VUV.mjs → chunk-DRA2K53O.mjs} +1 -1
  13. package/dist/{chunk-L4JFECXU.mjs → chunk-F4HMCXAX.mjs} +6 -3
  14. package/dist/{chunk-W7NTRSPD.mjs → chunk-HEAWMZEM.mjs} +105 -66
  15. package/dist/{chunk-IX6SEOSK.mjs → chunk-JENYDTXH.mjs} +52 -44
  16. package/dist/chunk-KFHZMFAX.js +23 -0
  17. package/dist/{chunk-6AN5X3YE.js → chunk-KXU6VH2Y.js} +10 -11
  18. package/dist/{chunk-WNVHPMBI.js → chunk-N33GSDNQ.js} +106 -65
  19. package/dist/chunk-OH46TGEA.mjs +20 -0
  20. package/dist/{chunk-QNLSCOR5.mjs → chunk-OLOSU2BD.mjs} +1 -1
  21. package/dist/chunk-PLKXCJIB.js +8 -0
  22. package/dist/{chunk-GSUC4HWP.mjs → chunk-QXKPIENP.mjs} +1 -1
  23. package/dist/chunk-UBHQJFUW.js +8 -0
  24. package/dist/{chunk-6NOCY764.js → chunk-VKXSL3ZL.js} +2 -2
  25. package/dist/chunk-XKNEQDAT.js +8 -0
  26. package/dist/{chunk-EN4PN7X3.mjs → chunk-Z23AMUSW.mjs} +1 -1
  27. package/dist/gestureLayer/index.d.mts +3 -3
  28. package/dist/gestureLayer/index.d.ts +3 -3
  29. package/dist/gestureLayer/index.js +12 -18
  30. package/dist/gestureLayer/index.mjs +5 -11
  31. package/dist/index.d.mts +105 -47
  32. package/dist/index.d.ts +105 -47
  33. package/dist/index.js +119 -92
  34. package/dist/index.mjs +71 -60
  35. package/dist/motion/FlatList.d.mts +1 -1
  36. package/dist/motion/FlatList.d.ts +1 -1
  37. package/dist/motion/FlatList.js +5 -5
  38. package/dist/motion/FlatList.mjs +4 -4
  39. package/dist/motion/Image.d.mts +1 -1
  40. package/dist/motion/Image.d.ts +1 -1
  41. package/dist/motion/Image.js +5 -5
  42. package/dist/motion/Image.mjs +4 -4
  43. package/dist/motion/Pressable.d.mts +1 -1
  44. package/dist/motion/Pressable.d.ts +1 -1
  45. package/dist/motion/Pressable.js +5 -5
  46. package/dist/motion/Pressable.mjs +4 -4
  47. package/dist/motion/ScrollView.d.mts +1 -1
  48. package/dist/motion/ScrollView.d.ts +1 -1
  49. package/dist/motion/ScrollView.js +5 -5
  50. package/dist/motion/ScrollView.mjs +4 -4
  51. package/dist/motion/Text.d.mts +1 -1
  52. package/dist/motion/Text.d.ts +1 -1
  53. package/dist/motion/Text.js +5 -5
  54. package/dist/motion/Text.mjs +4 -4
  55. package/dist/motion/View.d.mts +1 -1
  56. package/dist/motion/View.d.ts +1 -1
  57. package/dist/motion/View.js +5 -5
  58. package/dist/motion/View.mjs +4 -4
  59. package/dist/touch/index.d.mts +2 -1
  60. package/dist/touch/index.d.ts +2 -1
  61. package/dist/touch/index.js +16 -31
  62. package/dist/touch/index.mjs +11 -29
  63. package/dist/{types-DyJpG64F.d.mts → types-08mG8fNk.d.mts} +10 -3
  64. package/dist/{types-DyJpG64F.d.ts → types-08mG8fNk.d.ts} +10 -3
  65. package/dist/{useGesture-DbH46EBp.d.ts → useGesture-D1lHeQQ6.d.ts} +1 -1
  66. package/dist/{useGesture-CnZQnYHH.d.mts → useGesture-DjszaHWz.d.mts} +1 -1
  67. package/llms.txt +1 -1
  68. package/package.json +4 -2
  69. package/src/config/namedTransitions.ts +7 -9
  70. package/src/gestureLayer/index.ts +3 -0
  71. package/src/gestureLayer/useGestureLayer.ts +6 -9
  72. package/src/gestures/focusVisibility.ts +19 -17
  73. package/src/gestures/index.ts +1 -1
  74. package/src/index.ts +10 -0
  75. package/src/layout/resolveLayout.ts +4 -1
  76. package/src/layout/useSharedLayout.ts +2 -1
  77. package/src/motion/createMotionComponent.tsx +92 -44
  78. package/src/presence/Presence.tsx +5 -7
  79. package/src/touch/applyBounds.ts +30 -0
  80. package/src/touch/index.ts +1 -0
  81. package/src/touch/useTouchDrag.ts +15 -45
  82. package/src/transitions/constants.ts +14 -0
  83. package/src/transitions/easing.ts +23 -11
  84. package/src/transitions/index.ts +5 -0
  85. package/src/transitions/keys.ts +0 -2
  86. package/src/transitions/resolve.ts +86 -11
  87. package/src/transitions/resolveSequence.ts +3 -1
  88. package/src/transitions/runtime.ts +4 -7
  89. package/src/transitions/spring.ts +7 -2
  90. package/src/types.ts +9 -2
  91. package/src/values/extrapolation.ts +21 -0
  92. package/src/values/index.ts +2 -0
  93. package/src/values/useGesture.ts +9 -2
  94. package/src/values/useInterpolatedStyle.ts +42 -19
  95. package/src/values/useShadow.ts +18 -7
  96. package/src/values/useSpring.ts +34 -25
  97. package/src/values/useTransform.ts +24 -20
  98. package/src/values/useTranslateStyle.ts +31 -0
  99. package/dist/chunk-24NUL23E.js +0 -8
  100. package/dist/chunk-4XBX7KOD.js +0 -8
  101. package/dist/chunk-Z5USXWTE.js +0 -8
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkIHVMNOS4_js = require('../chunk-IHVMNOS4.js');
4
- require('../chunk-E3ALFSH2.js');
5
- require('../chunk-6AN5X3YE.js');
6
- require('../chunk-WNVHPMBI.js');
3
+ var chunk46766TBM_js = require('../chunk-46766TBM.js');
4
+ require('../chunk-2UGWAB6N.js');
5
+ require('../chunk-KXU6VH2Y.js');
6
+ require('../chunk-N33GSDNQ.js');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "MotionFlatList", {
11
11
  enumerable: true,
12
- get: function () { return chunkIHVMNOS4_js.MotionFlatList; }
12
+ get: function () { return chunk46766TBM_js.MotionFlatList; }
13
13
  });
@@ -1,4 +1,4 @@
1
- export { MotionFlatList } from '../chunk-EN4PN7X3.mjs';
2
- import '../chunk-IX6SEOSK.mjs';
3
- import '../chunk-MFAFB4K7.mjs';
4
- import '../chunk-W7NTRSPD.mjs';
1
+ export { MotionFlatList } from '../chunk-Z23AMUSW.mjs';
2
+ import '../chunk-JENYDTXH.mjs';
3
+ import '../chunk-6FCATUMY.mjs';
4
+ import '../chunk-HEAWMZEM.mjs';
@@ -1,5 +1,5 @@
1
1
  import { Image } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.mjs';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.mjs';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { Image } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.js';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkZ5USXWTE_js = require('../chunk-Z5USXWTE.js');
4
- require('../chunk-E3ALFSH2.js');
5
- require('../chunk-6AN5X3YE.js');
6
- require('../chunk-WNVHPMBI.js');
3
+ var chunkXKNEQDAT_js = require('../chunk-XKNEQDAT.js');
4
+ require('../chunk-2UGWAB6N.js');
5
+ require('../chunk-KXU6VH2Y.js');
6
+ require('../chunk-N33GSDNQ.js');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "MotionImage", {
11
11
  enumerable: true,
12
- get: function () { return chunkZ5USXWTE_js.MotionImage; }
12
+ get: function () { return chunkXKNEQDAT_js.MotionImage; }
13
13
  });
@@ -1,4 +1,4 @@
1
- export { MotionImage } from '../chunk-6YIUETBF.mjs';
2
- import '../chunk-IX6SEOSK.mjs';
3
- import '../chunk-MFAFB4K7.mjs';
4
- import '../chunk-W7NTRSPD.mjs';
1
+ export { MotionImage } from '../chunk-7BH3CAO5.mjs';
2
+ import '../chunk-JENYDTXH.mjs';
3
+ import '../chunk-6FCATUMY.mjs';
4
+ import '../chunk-HEAWMZEM.mjs';
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import * as react_native from 'react-native';
3
- import { M as MotionComponent } from '../types-DyJpG64F.mjs';
3
+ import { M as MotionComponent } from '../types-08mG8fNk.mjs';
4
4
 
5
5
  /**
6
6
  * Animatable `Pressable`. The `gesture` prop's `pressed` sub-state hooks into
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import * as react_native from 'react-native';
3
- import { M as MotionComponent } from '../types-DyJpG64F.js';
3
+ import { M as MotionComponent } from '../types-08mG8fNk.js';
4
4
 
5
5
  /**
6
6
  * Animatable `Pressable`. The `gesture` prop's `pressed` sub-state hooks into
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunk6NOCY764_js = require('../chunk-6NOCY764.js');
4
- require('../chunk-E3ALFSH2.js');
5
- require('../chunk-6AN5X3YE.js');
6
- require('../chunk-WNVHPMBI.js');
3
+ var chunkVKXSL3ZL_js = require('../chunk-VKXSL3ZL.js');
4
+ require('../chunk-2UGWAB6N.js');
5
+ require('../chunk-KXU6VH2Y.js');
6
+ require('../chunk-N33GSDNQ.js');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "MotionPressable", {
11
11
  enumerable: true,
12
- get: function () { return chunk6NOCY764_js.MotionPressable; }
12
+ get: function () { return chunkVKXSL3ZL_js.MotionPressable; }
13
13
  });
@@ -1,4 +1,4 @@
1
- export { MotionPressable } from '../chunk-JBK5ZLMH.mjs';
2
- import '../chunk-IX6SEOSK.mjs';
3
- import '../chunk-MFAFB4K7.mjs';
4
- import '../chunk-W7NTRSPD.mjs';
1
+ export { MotionPressable } from '../chunk-CUHOCONB.mjs';
2
+ import '../chunk-JENYDTXH.mjs';
3
+ import '../chunk-6FCATUMY.mjs';
4
+ import '../chunk-HEAWMZEM.mjs';
@@ -1,5 +1,5 @@
1
1
  import { ScrollView } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.mjs';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.mjs';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { ScrollView } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.js';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkZBHQPVWE_js = require('../chunk-ZBHQPVWE.js');
4
- require('../chunk-E3ALFSH2.js');
5
- require('../chunk-6AN5X3YE.js');
6
- require('../chunk-WNVHPMBI.js');
3
+ var chunk3ZNHPT5Z_js = require('../chunk-3ZNHPT5Z.js');
4
+ require('../chunk-2UGWAB6N.js');
5
+ require('../chunk-KXU6VH2Y.js');
6
+ require('../chunk-N33GSDNQ.js');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "MotionScrollView", {
11
11
  enumerable: true,
12
- get: function () { return chunkZBHQPVWE_js.MotionScrollView; }
12
+ get: function () { return chunk3ZNHPT5Z_js.MotionScrollView; }
13
13
  });
@@ -1,4 +1,4 @@
1
- export { MotionScrollView } from '../chunk-M4766VUV.mjs';
2
- import '../chunk-IX6SEOSK.mjs';
3
- import '../chunk-MFAFB4K7.mjs';
4
- import '../chunk-W7NTRSPD.mjs';
1
+ export { MotionScrollView } from '../chunk-DRA2K53O.mjs';
2
+ import '../chunk-JENYDTXH.mjs';
3
+ import '../chunk-6FCATUMY.mjs';
4
+ import '../chunk-HEAWMZEM.mjs';
@@ -1,5 +1,5 @@
1
1
  import { Text } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.mjs';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.mjs';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { Text } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.js';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunk4XBX7KOD_js = require('../chunk-4XBX7KOD.js');
4
- require('../chunk-E3ALFSH2.js');
5
- require('../chunk-6AN5X3YE.js');
6
- require('../chunk-WNVHPMBI.js');
3
+ var chunkUBHQJFUW_js = require('../chunk-UBHQJFUW.js');
4
+ require('../chunk-2UGWAB6N.js');
5
+ require('../chunk-KXU6VH2Y.js');
6
+ require('../chunk-N33GSDNQ.js');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "MotionText", {
11
11
  enumerable: true,
12
- get: function () { return chunk4XBX7KOD_js.MotionText; }
12
+ get: function () { return chunkUBHQJFUW_js.MotionText; }
13
13
  });
@@ -1,4 +1,4 @@
1
- export { MotionText } from '../chunk-QNLSCOR5.mjs';
2
- import '../chunk-IX6SEOSK.mjs';
3
- import '../chunk-MFAFB4K7.mjs';
4
- import '../chunk-W7NTRSPD.mjs';
1
+ export { MotionText } from '../chunk-OLOSU2BD.mjs';
2
+ import '../chunk-JENYDTXH.mjs';
3
+ import '../chunk-6FCATUMY.mjs';
4
+ import '../chunk-HEAWMZEM.mjs';
@@ -1,5 +1,5 @@
1
1
  import { View } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.mjs';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.mjs';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { View } from 'react-native';
2
- import { M as MotionComponent } from '../types-DyJpG64F.js';
2
+ import { M as MotionComponent } from '../types-08mG8fNk.js';
3
3
  import 'react';
4
4
 
5
5
  /**
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunk24NUL23E_js = require('../chunk-24NUL23E.js');
4
- require('../chunk-E3ALFSH2.js');
5
- require('../chunk-6AN5X3YE.js');
6
- require('../chunk-WNVHPMBI.js');
3
+ var chunkPLKXCJIB_js = require('../chunk-PLKXCJIB.js');
4
+ require('../chunk-2UGWAB6N.js');
5
+ require('../chunk-KXU6VH2Y.js');
6
+ require('../chunk-N33GSDNQ.js');
7
7
 
8
8
 
9
9
 
10
10
  Object.defineProperty(exports, "MotionView", {
11
11
  enumerable: true,
12
- get: function () { return chunk24NUL23E_js.MotionView; }
12
+ get: function () { return chunkPLKXCJIB_js.MotionView; }
13
13
  });
@@ -1,4 +1,4 @@
1
- export { MotionView } from '../chunk-GSUC4HWP.mjs';
2
- import '../chunk-IX6SEOSK.mjs';
3
- import '../chunk-MFAFB4K7.mjs';
4
- import '../chunk-W7NTRSPD.mjs';
1
+ export { MotionView } from '../chunk-QXKPIENP.mjs';
2
+ import '../chunk-JENYDTXH.mjs';
3
+ import '../chunk-6FCATUMY.mjs';
4
+ import '../chunk-HEAWMZEM.mjs';
@@ -1,6 +1,7 @@
1
+ export { a as applyBounds } from '../applyBounds-BYGiHrYO.mjs';
1
2
  import { PanResponderInstance } from 'react-native';
2
3
  import { useAnimatedStyle, SharedValue } from 'react-native-reanimated';
3
- import { T as TransitionConfig } from '../types-DyJpG64F.mjs';
4
+ import { T as TransitionConfig } from '../types-08mG8fNk.mjs';
4
5
  import 'react';
5
6
 
6
7
  /**
@@ -1,6 +1,7 @@
1
+ export { a as applyBounds } from '../applyBounds-BYGiHrYO.js';
1
2
  import { PanResponderInstance } from 'react-native';
2
3
  import { useAnimatedStyle, SharedValue } from 'react-native-reanimated';
3
- import { T as TransitionConfig } from '../types-DyJpG64F.js';
4
+ import { T as TransitionConfig } from '../types-08mG8fNk.js';
4
5
  import 'react';
5
6
 
6
7
  /**
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkWNVHPMBI_js = require('../chunk-WNVHPMBI.js');
3
+ var chunkKFHZMFAX_js = require('../chunk-KFHZMFAX.js');
4
+ var chunkN33GSDNQ_js = require('../chunk-N33GSDNQ.js');
4
5
  var react = require('react');
5
6
  var reactNative = require('react-native');
6
7
  var reactNativeReanimated = require('react-native-reanimated');
@@ -19,22 +20,12 @@ function useTouchDrag(options = {}) {
19
20
  const top = constraints?.top;
20
21
  const bottom = constraints?.bottom;
21
22
  const elasticCoef = elastic;
22
- const { onDragStart, onDragEnd, onRelease } = options;
23
+ const callbacksRef = react.useRef(options);
24
+ callbacksRef.current = options;
23
25
  const responder = react.useMemo(
24
26
  () => buildResponder(),
25
27
  // eslint-disable-next-line react-hooks/exhaustive-deps
26
- [
27
- lockX,
28
- lockY,
29
- left,
30
- right,
31
- top,
32
- bottom,
33
- elasticCoef,
34
- onDragStart,
35
- onDragEnd,
36
- onRelease
37
- ]
28
+ [lockX, lockY, left, right, top, bottom, elasticCoef]
38
29
  );
39
30
  function buildResponder() {
40
31
  const handleEnd = (g) => {
@@ -43,19 +34,20 @@ function useTouchDrag(options = {}) {
43
34
  const y = dragY.value;
44
35
  const vx = g.vx * 1e3;
45
36
  const vy = g.vy * 1e3;
37
+ const { onRelease, onDragEnd } = callbacksRef.current;
46
38
  if (onRelease) {
47
39
  const result = onRelease({ x, y, velocity: { x: vx, y: vy } });
48
40
  if (result) {
49
41
  if (result.x && lockX) {
50
42
  const toX = "to" in result.x ? result.x.to : x;
51
- dragX.value = chunkWNVHPMBI_js.buildReleaseAnimation(
43
+ dragX.value = chunkN33GSDNQ_js.buildReleaseAnimation(
52
44
  result.x,
53
45
  toX
54
46
  );
55
47
  }
56
48
  if (result.y && lockY) {
57
49
  const toY = "to" in result.y ? result.y.to : y;
58
- dragY.value = chunkWNVHPMBI_js.buildReleaseAnimation(
50
+ dragY.value = chunkN33GSDNQ_js.buildReleaseAnimation(
59
51
  result.y,
60
52
  toY
61
53
  );
@@ -74,11 +66,11 @@ function useTouchDrag(options = {}) {
74
66
  startX.value = dragX.value;
75
67
  startY.value = dragY.value;
76
68
  isDragging.value = true;
77
- if (onDragStart) onDragStart();
69
+ callbacksRef.current.onDragStart?.();
78
70
  },
79
71
  onPanResponderMove: (_e, g) => {
80
72
  if (lockX) {
81
- dragX.value = applyBounds(
73
+ dragX.value = chunkKFHZMFAX_js.applyBounds(
82
74
  startX.value + g.dx,
83
75
  left,
84
76
  right,
@@ -86,7 +78,7 @@ function useTouchDrag(options = {}) {
86
78
  );
87
79
  }
88
80
  if (lockY) {
89
- dragY.value = applyBounds(
81
+ dragY.value = chunkKFHZMFAX_js.applyBounds(
90
82
  startY.value + g.dy,
91
83
  top,
92
84
  bottom,
@@ -98,9 +90,7 @@ function useTouchDrag(options = {}) {
98
90
  onPanResponderTerminate: (_e, g) => handleEnd(g)
99
91
  });
100
92
  }
101
- const animatedStyle = reactNativeReanimated.useAnimatedStyle(() => ({
102
- transform: [{ translateX: dragX.value }, { translateY: dragY.value }]
103
- }));
93
+ const animatedStyle = chunkKFHZMFAX_js.useTranslateStyle(dragX, dragY);
104
94
  return {
105
95
  panHandlers: responder.panHandlers,
106
96
  animatedStyle,
@@ -109,14 +99,9 @@ function useTouchDrag(options = {}) {
109
99
  isDragging
110
100
  };
111
101
  }
112
- function applyBounds(value, min, max, elastic) {
113
- if (min !== void 0 && value < min) {
114
- return elastic > 0 ? min + (value - min) * elastic : min;
115
- }
116
- if (max !== void 0 && value > max) {
117
- return elastic > 0 ? max + (value - max) * elastic : max;
118
- }
119
- return value;
120
- }
121
102
 
103
+ Object.defineProperty(exports, "applyBounds", {
104
+ enumerable: true,
105
+ get: function () { return chunkKFHZMFAX_js.applyBounds; }
106
+ });
122
107
  exports.useTouchDrag = useTouchDrag;
@@ -1,7 +1,9 @@
1
- import { buildReleaseAnimation } from '../chunk-W7NTRSPD.mjs';
2
- import { useMemo } from 'react';
1
+ import { applyBounds, useTranslateStyle } from '../chunk-OH46TGEA.mjs';
2
+ export { applyBounds } from '../chunk-OH46TGEA.mjs';
3
+ import { buildReleaseAnimation } from '../chunk-HEAWMZEM.mjs';
4
+ import { useRef, useMemo } from 'react';
3
5
  import { PanResponder } from 'react-native';
4
- import { useSharedValue, useAnimatedStyle } from 'react-native-reanimated';
6
+ import { useSharedValue } from 'react-native-reanimated';
5
7
 
6
8
  function useTouchDrag(options = {}) {
7
9
  const { axis = "both", constraints, elastic = 0 } = options;
@@ -17,22 +19,12 @@ function useTouchDrag(options = {}) {
17
19
  const top = constraints?.top;
18
20
  const bottom = constraints?.bottom;
19
21
  const elasticCoef = elastic;
20
- const { onDragStart, onDragEnd, onRelease } = options;
22
+ const callbacksRef = useRef(options);
23
+ callbacksRef.current = options;
21
24
  const responder = useMemo(
22
25
  () => buildResponder(),
23
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
24
- [
25
- lockX,
26
- lockY,
27
- left,
28
- right,
29
- top,
30
- bottom,
31
- elasticCoef,
32
- onDragStart,
33
- onDragEnd,
34
- onRelease
35
- ]
27
+ [lockX, lockY, left, right, top, bottom, elasticCoef]
36
28
  );
37
29
  function buildResponder() {
38
30
  const handleEnd = (g) => {
@@ -41,6 +33,7 @@ function useTouchDrag(options = {}) {
41
33
  const y = dragY.value;
42
34
  const vx = g.vx * 1e3;
43
35
  const vy = g.vy * 1e3;
36
+ const { onRelease, onDragEnd } = callbacksRef.current;
44
37
  if (onRelease) {
45
38
  const result = onRelease({ x, y, velocity: { x: vx, y: vy } });
46
39
  if (result) {
@@ -72,7 +65,7 @@ function useTouchDrag(options = {}) {
72
65
  startX.value = dragX.value;
73
66
  startY.value = dragY.value;
74
67
  isDragging.value = true;
75
- if (onDragStart) onDragStart();
68
+ callbacksRef.current.onDragStart?.();
76
69
  },
77
70
  onPanResponderMove: (_e, g) => {
78
71
  if (lockX) {
@@ -96,9 +89,7 @@ function useTouchDrag(options = {}) {
96
89
  onPanResponderTerminate: (_e, g) => handleEnd(g)
97
90
  });
98
91
  }
99
- const animatedStyle = useAnimatedStyle(() => ({
100
- transform: [{ translateX: dragX.value }, { translateY: dragY.value }]
101
- }));
92
+ const animatedStyle = useTranslateStyle(dragX, dragY);
102
93
  return {
103
94
  panHandlers: responder.panHandlers,
104
95
  animatedStyle,
@@ -107,14 +98,5 @@ function useTouchDrag(options = {}) {
107
98
  isDragging
108
99
  };
109
100
  }
110
- function applyBounds(value, min, max, elastic) {
111
- if (min !== void 0 && value < min) {
112
- return elastic > 0 ? min + (value - min) * elastic : min;
113
- }
114
- if (max !== void 0 && value > max) {
115
- return elastic > 0 ? max + (value - max) * elastic : max;
116
- }
117
- return value;
118
- }
119
101
 
120
102
  export { useTouchDrag };
@@ -24,8 +24,6 @@ interface SpringTransition {
24
24
  friction?: number;
25
25
  mass?: number;
26
26
  velocity?: number;
27
- restSpeedThreshold?: number;
28
- restDisplacementThreshold?: number;
29
27
  delay?: number;
30
28
  repeat?: RepeatConfig;
31
29
  }
@@ -107,6 +105,15 @@ type NamedTransitions = Partial<Record<TransitionName, TransitionConfig>>;
107
105
  type TransitionInput = TransitionConfig | TransitionName;
108
106
  /**
109
107
  * Repeat config — one shape, not three flags. Default `alternate: true`.
108
+ *
109
+ * `count` is the total number of iterations, including the first pass, so
110
+ * `repeat: 2` plays the animation twice. A count below `1` runs the animation
111
+ * once and warns in dev.
112
+ *
113
+ * `alternate` reverses direction on every other pass for a single-value
114
+ * animation. It has no effect on a sequence (an array target): Reanimated
115
+ * restarts a sequence at its first step on every pass. Append the reverse
116
+ * steps to the sequence to alternate.
110
117
  */
111
118
  type RepeatConfig = number | 'infinite' | {
112
119
  count: number | 'infinite';
@@ -456,4 +463,4 @@ interface MotionComponent<C extends ComponentType<any>> {
456
463
  displayName?: string;
457
464
  }
458
465
 
459
- export type { AnimatableValue as A, BoxShadowInput as B, DecayTransition as D, EasingInput as E, GestureLayerTransitions as G, MotionComponent as M, NamedTransitions as N, PerPropertyTransition as P, RegisteredTransitions as R, SpringTransition as S, TransitionConfig as T, VariantsMap as V, MotionProps as a, TransitionInput as b, TransitionName as c, VariantController as d, AnimateStyle as e, AnimationCallbackInfo as f, EasingFunction as g, EasingFunctionFactory as h, GestureSubStates as i, NoAnimationTransition as j, RepeatConfig as k, SequenceStep as l, TimingTransition as m, Transition as n };
466
+ export type { AnimatableValue as A, BoxShadowInput as B, DecayTransition as D, EasingInput as E, GestureLayerTransitions as G, MotionComponent as M, NamedTransitions as N, PerPropertyTransition as P, RegisteredTransitions as R, SpringTransition as S, TransitionConfig as T, VariantsMap as V, MotionProps as a, TransitionInput as b, TransitionName as c, VariantController as d, AnimateStyle as e, AnimationCallbackInfo as f, EasingFunction as g, EasingFunctionFactory as h, GestureSubStates as i, MotionComponentProps as j, NoAnimationTransition as k, RepeatConfig as l, SequenceStep as m, TimingTransition as n, Transition as o };
@@ -24,8 +24,6 @@ interface SpringTransition {
24
24
  friction?: number;
25
25
  mass?: number;
26
26
  velocity?: number;
27
- restSpeedThreshold?: number;
28
- restDisplacementThreshold?: number;
29
27
  delay?: number;
30
28
  repeat?: RepeatConfig;
31
29
  }
@@ -107,6 +105,15 @@ type NamedTransitions = Partial<Record<TransitionName, TransitionConfig>>;
107
105
  type TransitionInput = TransitionConfig | TransitionName;
108
106
  /**
109
107
  * Repeat config — one shape, not three flags. Default `alternate: true`.
108
+ *
109
+ * `count` is the total number of iterations, including the first pass, so
110
+ * `repeat: 2` plays the animation twice. A count below `1` runs the animation
111
+ * once and warns in dev.
112
+ *
113
+ * `alternate` reverses direction on every other pass for a single-value
114
+ * animation. It has no effect on a sequence (an array target): Reanimated
115
+ * restarts a sequence at its first step on every pass. Append the reverse
116
+ * steps to the sequence to alternate.
110
117
  */
111
118
  type RepeatConfig = number | 'infinite' | {
112
119
  count: number | 'infinite';
@@ -456,4 +463,4 @@ interface MotionComponent<C extends ComponentType<any>> {
456
463
  displayName?: string;
457
464
  }
458
465
 
459
- export type { AnimatableValue as A, BoxShadowInput as B, DecayTransition as D, EasingInput as E, GestureLayerTransitions as G, MotionComponent as M, NamedTransitions as N, PerPropertyTransition as P, RegisteredTransitions as R, SpringTransition as S, TransitionConfig as T, VariantsMap as V, MotionProps as a, TransitionInput as b, TransitionName as c, VariantController as d, AnimateStyle as e, AnimationCallbackInfo as f, EasingFunction as g, EasingFunctionFactory as h, GestureSubStates as i, NoAnimationTransition as j, RepeatConfig as k, SequenceStep as l, TimingTransition as m, Transition as n };
466
+ export type { AnimatableValue as A, BoxShadowInput as B, DecayTransition as D, EasingInput as E, GestureLayerTransitions as G, MotionComponent as M, NamedTransitions as N, PerPropertyTransition as P, RegisteredTransitions as R, SpringTransition as S, TransitionConfig as T, VariantsMap as V, MotionProps as a, TransitionInput as b, TransitionName as c, VariantController as d, AnimateStyle as e, AnimationCallbackInfo as f, EasingFunction as g, EasingFunctionFactory as h, GestureSubStates as i, MotionComponentProps as j, NoAnimationTransition as k, RepeatConfig as l, SequenceStep as m, TimingTransition as n, Transition as o };
@@ -1,5 +1,5 @@
1
1
  import { SharedValue } from 'react-native-reanimated';
2
- import { b as TransitionInput, G as GestureLayerTransitions } from './types-DyJpG64F.js';
2
+ import { b as TransitionInput, G as GestureLayerTransitions } from './types-08mG8fNk.js';
3
3
 
4
4
  /**
5
5
  * Handler bag returned by `useGesture`. Spread on a `Pressable` to drive the
@@ -1,5 +1,5 @@
1
1
  import { SharedValue } from 'react-native-reanimated';
2
- import { b as TransitionInput, G as GestureLayerTransitions } from './types-DyJpG64F.mjs';
2
+ import { b as TransitionInput, G as GestureLayerTransitions } from './types-08mG8fNk.mjs';
3
3
 
4
4
  /**
5
5
  * Handler bag returned by `useGesture`. Spread on a `Pressable` to drive the
package/llms.txt CHANGED
@@ -80,7 +80,7 @@ import { MotionFlatList } from '@rootnative/inertia/flat-list'
80
80
  - `useShadow({ from, to, progress })` — pure value-layer interpolator between two `ShadowConfig`s (`shadowOpacity` / `shadowRadius` / `shadowOffset` / `elevation` / `shadowColor`, plus `boxShadow` as a CSS string or `BoxShadowLayer[]` — the shadow surface on web and RN 0.76+ new-arch; multi-layer, CSS-transition padding semantics, malformed strings throw at setup) driven by a `SharedValue<number>` (0→1). Returns an animated style fragment to spread onto `style`; only emits keys present on either side, absent sides default to natural zero. The hook does not animate on its own — drive `progress` with a spring, a scroll-derived `useTransform`, or any other shared value source.
81
81
  - `useColorTransition(progress, [from, to], options?)` — pure value-layer interpolator for a single color channel, driven by a `SharedValue<number>` (0→1). Returns an animated style fragment with one color key (default `backgroundColor`; configurable via `options.key` to `color` / `borderColor` / `tintColor` / `shadowColor` / per-side border colors). For raw `SharedValue<string>` output, use `useTransform(progress, [0, 1], [from, to])` instead.
82
82
  - `useColorCascade(rest, layers, options?)` — pure value-layer interpolator compositing a **priority-ordered** stack of color layers over a base `rest` color; each `layers` entry is `{ progress: SharedValue<number>, color: string }`, later entries win as their progress rises (equivalent to the nested `focus(error(hover(rest)))` `interpolateColor` chain). `options.key` reuses `ColorStyleKey` (default `backgroundColor`). Returns a spreadable animated style fragment; memoized on a colors+key signature. Color-only by design — cascade a numeric key separately via `useInterpolatedStyle` + `useTransform` max. `useColorTransition` stays the single-layer fast path.
83
- - `useInterpolatedStyle(progress, map, options?)` — pure value-layer interpolator mapping one `SharedValue<number>` onto **N** style props at once, returned as a spreadable animated style fragment (the multi-key, style-fragment counterpart to `useTransform`'s output-range form). Numeric keys (`opacity` / `height` / `fontSize` / …) route through `interpolate`; transform keys (`translateX` / `scale` / `rotate` / …) lift into a `transform` array in map key-order (`rotate*` emit `'<n>deg'`); color keys (`backgroundColor` / `borderColor` / …) route through `interpolateColor` (a multi-stop `useColorTransition`). Stop types are compile-checked. `options.inputRange` (default `[0,1]` / evenly-spaced) and `options.extrapolate` (default `'clamp'`) apply to every key. Memoized on an order-preserving signature. For function-valued or multi-source composition, drop to `useTransform`'s worklet form or a hand-rolled `useAnimatedStyle`.
83
+ - `useInterpolatedStyle(progress, map, options?)` — pure value-layer interpolator mapping one `SharedValue<number>` onto **N** style props at once, returned as a spreadable animated style fragment (the multi-key, style-fragment counterpart to `useTransform`'s output-range form). Numeric keys (`opacity` / `height` / `fontSize` / …) route through `interpolate`; transform keys (`translateX` / `scale` / `rotate` / …) lift into a `transform` array in map key-order (`rotate*` emit `'<n>deg'`); color keys (`backgroundColor` / `borderColor` / …) route through `interpolateColor` (a multi-stop `useColorTransition`). Stop types are compile-checked. **The return type is derived from the map's own keys (`InterpolatedStyle<K>`), so it narrows to the right style family and needs no cast in a `style` array** — view keys satisfy `StyleProp<ViewStyle>`, text-metric keys (`fontSize` / `lineHeight` / `letterSpacing`) satisfy `StyleProp<TextStyle>`, `tintColor` satisfies `StyleProp<ImageStyle>`, and transform keys collapse into the emitted `transform` array. (Reanimated's `useAnimatedStyle` returns the `DefaultStyle` union, whose `TextStyle` member fails against `ViewStyle` on `cursor` inside a style array.) `options.inputRange` (default `[0,1]` / evenly-spaced) and `options.extrapolate` (default `'clamp'`) apply to every key. Memoized on an order-preserving signature. For function-valued or multi-source composition, drop to `useTransform`'s worklet form or a hand-rolled `useAnimatedStyle`.
84
84
  - `useScroll()` — returns `{ scrollX, scrollY, onScroll }` for use with `Motion.ScrollView` or `Motion.FlatList`. Scroll events fire on the UI thread. Set `scrollEventThrottle={16}` on a `Motion.ScrollView`; `Motion.FlatList` defaults it to 1.
85
85
  - `createMotionComponent<C>(C)` — wrap any component with the same Motion prop surface, inferring style from `C`.
86
86
  - `buildReleaseAnimation(transition, toValue)` — worklet-safe single-step animation builder (spring / timing / decay / no-animation). For assigning Inertia-resolved animations to shared values from inside a gesture worklet. Used internally by `@rootnative/inertia-gestures`'s `useDrag({ onRelease })`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootnative/inertia",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Declarative animation primitives for React Native, built on react-native-reanimated.",
5
5
  "license": "MIT",
6
6
  "author": "RootNative",
@@ -125,13 +125,14 @@
125
125
  "!**/*.test.*"
126
126
  ],
127
127
  "peerDependencies": {
128
+ "@testing-library/react-native": ">=13.0.0",
128
129
  "react": ">=19.0.0",
129
130
  "react-native": ">=0.81.0",
130
131
  "react-native-reanimated": ">=4.0.0",
131
132
  "react-native-worklets": ">=0.5.0"
132
133
  },
133
134
  "peerDependenciesMeta": {
134
- "react-native-worklets": {
135
+ "@testing-library/react-native": {
135
136
  "optional": true
136
137
  }
137
138
  },
@@ -145,6 +146,7 @@
145
146
  "react": "19.1.0",
146
147
  "react-native": "0.81.5",
147
148
  "react-native-reanimated": "~4.1.1",
149
+ "react-native-worklets": "~0.5.1",
148
150
  "react-test-renderer": "19.1.0",
149
151
  "size-limit": "^11.1.0",
150
152
  "tsup": "^8.3.5",
@@ -1,3 +1,4 @@
1
+ import { warnOnce } from '../internal/warnOnce'
1
2
  import { isTopLevelTransition } from '../transitions/keys'
2
3
  import {
3
4
  type NamedTransitions,
@@ -6,8 +7,6 @@ import {
6
7
  type TransitionInput,
7
8
  } from '../types'
8
9
 
9
- declare const __DEV__: boolean
10
-
11
10
  /**
12
11
  * Fallback used when a name isn't found in the registry: the library default
13
12
  * spring, matching what an omitted transition resolves to everywhere else.
@@ -26,13 +25,12 @@ export function lookupNamedTransition(
26
25
  ): TransitionConfig {
27
26
  const cfg = registry[name]
28
27
  if (cfg) return cfg
29
- if (__DEV__) {
30
- console.warn(
31
- `[inertia] Unknown transition name "${name}" — falling back to the ` +
32
- `default spring. Register it on a provider: ` +
33
- `<MotionConfig transitions={{ '${name}': { ... } }}>.`,
34
- )
35
- }
28
+ warnOnce(
29
+ `unknown-transition:${name}`,
30
+ `[inertia] Unknown transition name "${name}" — falling back to the ` +
31
+ `default spring. Register it on a provider: ` +
32
+ `<MotionConfig transitions={{ '${name}': { ... } }}>.`,
33
+ )
36
34
  return UNKNOWN_NAME_FALLBACK
37
35
  }
38
36