@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.
- package/CHANGELOG.md +81 -1
- package/README.md +7 -7
- package/dist/applyBounds-BYGiHrYO.d.mts +18 -0
- package/dist/applyBounds-BYGiHrYO.d.ts +18 -0
- package/dist/{chunk-E3ALFSH2.js → chunk-2UGWAB6N.js} +78 -70
- package/dist/{chunk-ZBHQPVWE.js → chunk-3ZNHPT5Z.js} +2 -2
- package/dist/{chunk-IHVMNOS4.js → chunk-46766TBM.js} +2 -2
- package/dist/{chunk-MUT6BTZS.js → chunk-4EZ5DBL3.js} +10 -7
- package/dist/{chunk-MFAFB4K7.mjs → chunk-6FCATUMY.mjs} +8 -10
- package/dist/{chunk-6YIUETBF.mjs → chunk-7BH3CAO5.mjs} +1 -1
- package/dist/{chunk-JBK5ZLMH.mjs → chunk-CUHOCONB.mjs} +1 -1
- package/dist/{chunk-M4766VUV.mjs → chunk-DRA2K53O.mjs} +1 -1
- package/dist/{chunk-L4JFECXU.mjs → chunk-F4HMCXAX.mjs} +6 -3
- package/dist/{chunk-W7NTRSPD.mjs → chunk-HEAWMZEM.mjs} +105 -66
- package/dist/{chunk-IX6SEOSK.mjs → chunk-JENYDTXH.mjs} +52 -44
- package/dist/chunk-KFHZMFAX.js +23 -0
- package/dist/{chunk-6AN5X3YE.js → chunk-KXU6VH2Y.js} +10 -11
- package/dist/{chunk-WNVHPMBI.js → chunk-N33GSDNQ.js} +106 -65
- package/dist/chunk-OH46TGEA.mjs +20 -0
- package/dist/{chunk-QNLSCOR5.mjs → chunk-OLOSU2BD.mjs} +1 -1
- package/dist/chunk-PLKXCJIB.js +8 -0
- package/dist/{chunk-GSUC4HWP.mjs → chunk-QXKPIENP.mjs} +1 -1
- package/dist/chunk-UBHQJFUW.js +8 -0
- package/dist/{chunk-6NOCY764.js → chunk-VKXSL3ZL.js} +2 -2
- package/dist/chunk-XKNEQDAT.js +8 -0
- package/dist/{chunk-EN4PN7X3.mjs → chunk-Z23AMUSW.mjs} +1 -1
- package/dist/gestureLayer/index.d.mts +3 -3
- package/dist/gestureLayer/index.d.ts +3 -3
- package/dist/gestureLayer/index.js +12 -18
- package/dist/gestureLayer/index.mjs +5 -11
- package/dist/index.d.mts +105 -47
- package/dist/index.d.ts +105 -47
- package/dist/index.js +119 -92
- package/dist/index.mjs +71 -60
- package/dist/motion/FlatList.d.mts +1 -1
- package/dist/motion/FlatList.d.ts +1 -1
- package/dist/motion/FlatList.js +5 -5
- package/dist/motion/FlatList.mjs +4 -4
- 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 +2 -1
- package/dist/touch/index.d.ts +2 -1
- package/dist/touch/index.js +16 -31
- package/dist/touch/index.mjs +11 -29
- package/dist/{types-DyJpG64F.d.mts → types-08mG8fNk.d.mts} +10 -3
- package/dist/{types-DyJpG64F.d.ts → types-08mG8fNk.d.ts} +10 -3
- package/dist/{useGesture-DbH46EBp.d.ts → useGesture-D1lHeQQ6.d.ts} +1 -1
- package/dist/{useGesture-CnZQnYHH.d.mts → useGesture-DjszaHWz.d.mts} +1 -1
- package/llms.txt +1 -1
- package/package.json +4 -2
- package/src/config/namedTransitions.ts +7 -9
- package/src/gestureLayer/index.ts +3 -0
- package/src/gestureLayer/useGestureLayer.ts +6 -9
- package/src/gestures/focusVisibility.ts +19 -17
- package/src/gestures/index.ts +1 -1
- package/src/index.ts +10 -0
- package/src/layout/resolveLayout.ts +4 -1
- package/src/layout/useSharedLayout.ts +2 -1
- package/src/motion/createMotionComponent.tsx +92 -44
- package/src/presence/Presence.tsx +5 -7
- package/src/touch/applyBounds.ts +30 -0
- package/src/touch/index.ts +1 -0
- package/src/touch/useTouchDrag.ts +15 -45
- package/src/transitions/constants.ts +14 -0
- package/src/transitions/easing.ts +23 -11
- package/src/transitions/index.ts +5 -0
- package/src/transitions/keys.ts +0 -2
- package/src/transitions/resolve.ts +86 -11
- package/src/transitions/resolveSequence.ts +3 -1
- package/src/transitions/runtime.ts +4 -7
- package/src/transitions/spring.ts +7 -2
- package/src/types.ts +9 -2
- package/src/values/extrapolation.ts +21 -0
- package/src/values/index.ts +2 -0
- package/src/values/useGesture.ts +9 -2
- package/src/values/useInterpolatedStyle.ts +42 -19
- package/src/values/useShadow.ts +18 -7
- package/src/values/useSpring.ts +34 -25
- package/src/values/useTransform.ts +24 -20
- package/src/values/useTranslateStyle.ts +31 -0
- package/dist/chunk-24NUL23E.js +0 -8
- package/dist/chunk-4XBX7KOD.js +0 -8
- package/dist/chunk-Z5USXWTE.js +0 -8
|
@@ -3,7 +3,48 @@
|
|
|
3
3
|
var reactNativeWorklets = require('react-native-worklets');
|
|
4
4
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
5
5
|
|
|
6
|
-
// src/transitions/
|
|
6
|
+
// src/transitions/sig.ts
|
|
7
|
+
function stableSig(value) {
|
|
8
|
+
if (value === void 0) return "";
|
|
9
|
+
try {
|
|
10
|
+
return stableStringify(value);
|
|
11
|
+
} catch {
|
|
12
|
+
return String(value);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function stableStringify(v) {
|
|
16
|
+
if (v === null || typeof v !== "object") {
|
|
17
|
+
if (typeof v === "function" || v === void 0) return "null";
|
|
18
|
+
return JSON.stringify(v);
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(v)) {
|
|
21
|
+
return "[" + v.map(stableStringify).join(",") + "]";
|
|
22
|
+
}
|
|
23
|
+
const obj = v;
|
|
24
|
+
const keys = Object.keys(obj).sort();
|
|
25
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/transitions/keys.ts
|
|
29
|
+
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
30
|
+
"type",
|
|
31
|
+
"tension",
|
|
32
|
+
"friction",
|
|
33
|
+
"mass",
|
|
34
|
+
"velocity",
|
|
35
|
+
"duration",
|
|
36
|
+
"easing",
|
|
37
|
+
"delay",
|
|
38
|
+
"repeat",
|
|
39
|
+
"deceleration",
|
|
40
|
+
"clamp"
|
|
41
|
+
]);
|
|
42
|
+
function isTopLevelTransition(t) {
|
|
43
|
+
if (t === null || typeof t !== "object") return false;
|
|
44
|
+
const keys = Object.keys(t);
|
|
45
|
+
if (keys.length === 0) return false;
|
|
46
|
+
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
47
|
+
}
|
|
7
48
|
|
|
8
49
|
// src/internal/warnOnce.ts
|
|
9
50
|
var warned = /* @__PURE__ */ new Set();
|
|
@@ -24,7 +65,7 @@ function warnNonWorkletOnce(key, message) {
|
|
|
24
65
|
// src/transitions/easing.ts
|
|
25
66
|
function ensureWorkletEasing(easing) {
|
|
26
67
|
if (!easing) return void 0;
|
|
27
|
-
const fn =
|
|
68
|
+
const fn = unwrapEasingFactory(easing);
|
|
28
69
|
if (reactNativeWorklets.isWorkletFunction(fn)) return fn;
|
|
29
70
|
warnNonWorkletOnce(
|
|
30
71
|
"timing-easing",
|
|
@@ -36,10 +77,18 @@ function ensureWorkletEasing(easing) {
|
|
|
36
77
|
};
|
|
37
78
|
return wrapped;
|
|
38
79
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
80
|
+
function unwrapEasingFactory(easing) {
|
|
81
|
+
"worklet";
|
|
82
|
+
if (typeof easing === "object" && easing !== null && "factory" in easing && typeof easing.factory === "function") {
|
|
83
|
+
return easing.factory();
|
|
84
|
+
}
|
|
85
|
+
return easing;
|
|
41
86
|
}
|
|
42
87
|
|
|
88
|
+
// src/transitions/constants.ts
|
|
89
|
+
var DEFAULT_TIMING_DURATION = 250;
|
|
90
|
+
var DEFAULT_LAYOUT_DURATION = 300;
|
|
91
|
+
|
|
43
92
|
// src/transitions/spring.ts
|
|
44
93
|
var DEFAULT_SPRING = {
|
|
45
94
|
tension: 170,
|
|
@@ -52,14 +101,11 @@ function springToReanimated(t) {
|
|
|
52
101
|
stiffness: t.tension ?? DEFAULT_SPRING.tension,
|
|
53
102
|
damping: t.friction ?? DEFAULT_SPRING.friction,
|
|
54
103
|
mass: t.mass ?? DEFAULT_SPRING.mass,
|
|
55
|
-
velocity: t.velocity
|
|
56
|
-
restSpeedThreshold: t.restSpeedThreshold,
|
|
57
|
-
restDisplacementThreshold: t.restDisplacementThreshold
|
|
104
|
+
velocity: t.velocity
|
|
58
105
|
};
|
|
59
106
|
}
|
|
60
107
|
|
|
61
108
|
// src/transitions/resolve.ts
|
|
62
|
-
var DEFAULT_TIMING_DURATION = 250;
|
|
63
109
|
function buildSpring(cfg, toValue, cb) {
|
|
64
110
|
return reactNativeReanimated.withSpring(toValue, springToReanimated(cfg), cb);
|
|
65
111
|
}
|
|
@@ -92,17 +138,54 @@ function buildOne(cfg, toValue, cb) {
|
|
|
92
138
|
if (cfg.type === "timing") return buildTiming(cfg, toValue, cb);
|
|
93
139
|
return buildSpring(cfg, toValue, cb);
|
|
94
140
|
}
|
|
95
|
-
function
|
|
96
|
-
if (repeat === void 0) return
|
|
141
|
+
function normalizeRepeat(repeat) {
|
|
142
|
+
if (repeat === void 0) return void 0;
|
|
97
143
|
if (repeat === "infinite") {
|
|
98
|
-
return
|
|
144
|
+
return {
|
|
145
|
+
count: Number.POSITIVE_INFINITY,
|
|
146
|
+
alternate: true,
|
|
147
|
+
explicitAlternate: false
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const rawCount = typeof repeat === "number" ? repeat : repeat.count;
|
|
151
|
+
const alternate = typeof repeat === "number" ? true : repeat.alternate;
|
|
152
|
+
if (rawCount === "infinite") {
|
|
153
|
+
return {
|
|
154
|
+
count: Number.POSITIVE_INFINITY,
|
|
155
|
+
alternate: alternate ?? true,
|
|
156
|
+
explicitAlternate: alternate !== void 0
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
if (!(rawCount >= 1)) {
|
|
160
|
+
warnOnce(
|
|
161
|
+
`repeat-count:${String(rawCount)}`,
|
|
162
|
+
`[inertia] repeat count ${String(rawCount)} is below 1 \u2014 the animation runs once. Use \`repeat: 2\` or more to repeat, or \`repeat: 'infinite'\`. (Reanimated reads a count of 0 as endless, so it is not forwarded.)`
|
|
163
|
+
);
|
|
164
|
+
return void 0;
|
|
99
165
|
}
|
|
100
|
-
|
|
101
|
-
|
|
166
|
+
return {
|
|
167
|
+
count: rawCount,
|
|
168
|
+
alternate: alternate ?? true,
|
|
169
|
+
explicitAlternate: alternate !== void 0
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function repeatIterationsOf(repeat) {
|
|
173
|
+
return normalizeRepeat(repeat)?.count ?? 1;
|
|
174
|
+
}
|
|
175
|
+
function applyRepeat(animation, repeat, options) {
|
|
176
|
+
const r = normalizeRepeat(repeat);
|
|
177
|
+
if (r === void 0) return animation;
|
|
178
|
+
const count = Number.isFinite(r.count) ? r.count : -1;
|
|
179
|
+
if (options?.sequence) {
|
|
180
|
+
if (r.explicitAlternate && r.alternate) {
|
|
181
|
+
warnOnce(
|
|
182
|
+
"repeat-sequence-alternate",
|
|
183
|
+
"[inertia] repeat.alternate has no effect on a sequence \u2014 Reanimated restarts a sequence at its first step on every pass. Append the reverse steps to the sequence to alternate."
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
return reactNativeReanimated.withRepeat(animation, count, false);
|
|
102
187
|
}
|
|
103
|
-
|
|
104
|
-
const alternate = repeat.alternate ?? true;
|
|
105
|
-
return reactNativeReanimated.withRepeat(animation, count, alternate);
|
|
188
|
+
return reactNativeReanimated.withRepeat(animation, count, r.alternate);
|
|
106
189
|
}
|
|
107
190
|
function applyDelay(animation, delay) {
|
|
108
191
|
if (!delay || delay <= 0) return animation;
|
|
@@ -141,7 +224,9 @@ function resolveAnimatableValue(value, base, factory) {
|
|
|
141
224
|
(step2, i) => resolveStep(step2, stepBase, factory?.("step", i))
|
|
142
225
|
);
|
|
143
226
|
const seq = reactNativeReanimated.withSequence(...animations);
|
|
144
|
-
return applyRepeat(seq, base ? repeatOf(base) : void 0
|
|
227
|
+
return applyRepeat(seq, base ? repeatOf(base) : void 0, {
|
|
228
|
+
sequence: true
|
|
229
|
+
});
|
|
145
230
|
}
|
|
146
231
|
const step = value;
|
|
147
232
|
const cb = factory?.("animation", void 0);
|
|
@@ -211,7 +296,6 @@ function bezier(x1, y1, x2, y2, source) {
|
|
|
211
296
|
}
|
|
212
297
|
return reactNativeReanimated.Easing.bezier(x1, y1, x2, y2);
|
|
213
298
|
}
|
|
214
|
-
var DEFAULT_TIMING_DURATION2 = 250;
|
|
215
299
|
function buildReleaseAnimation(transition, toValue, callback) {
|
|
216
300
|
"worklet";
|
|
217
301
|
if (transition.type === "no-animation") {
|
|
@@ -228,11 +312,11 @@ function buildReleaseAnimation(transition, toValue, callback) {
|
|
|
228
312
|
}
|
|
229
313
|
if (transition.type === "timing") {
|
|
230
314
|
const e = transition.easing;
|
|
231
|
-
const easingFn = e
|
|
315
|
+
const easingFn = e ? unwrapEasingFactory(e) : reactNativeReanimated.Easing.inOut(reactNativeReanimated.Easing.ease);
|
|
232
316
|
return reactNativeReanimated.withTiming(
|
|
233
317
|
toValue,
|
|
234
318
|
{
|
|
235
|
-
duration: transition.duration ??
|
|
319
|
+
duration: transition.duration ?? DEFAULT_TIMING_DURATION,
|
|
236
320
|
easing: easingFn
|
|
237
321
|
},
|
|
238
322
|
callback
|
|
@@ -241,57 +325,14 @@ function buildReleaseAnimation(transition, toValue, callback) {
|
|
|
241
325
|
return reactNativeReanimated.withSpring(toValue, springToReanimated(transition), callback);
|
|
242
326
|
}
|
|
243
327
|
|
|
244
|
-
|
|
245
|
-
var TRANSITION_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
246
|
-
"type",
|
|
247
|
-
"tension",
|
|
248
|
-
"friction",
|
|
249
|
-
"mass",
|
|
250
|
-
"velocity",
|
|
251
|
-
"restSpeedThreshold",
|
|
252
|
-
"restDisplacementThreshold",
|
|
253
|
-
"duration",
|
|
254
|
-
"easing",
|
|
255
|
-
"delay",
|
|
256
|
-
"repeat",
|
|
257
|
-
"deceleration",
|
|
258
|
-
"clamp"
|
|
259
|
-
]);
|
|
260
|
-
function isTopLevelTransition(t) {
|
|
261
|
-
if (t === null || typeof t !== "object") return false;
|
|
262
|
-
const keys = Object.keys(t);
|
|
263
|
-
if (keys.length === 0) return false;
|
|
264
|
-
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// src/transitions/sig.ts
|
|
268
|
-
function stableSig(value) {
|
|
269
|
-
if (value === void 0) return "";
|
|
270
|
-
try {
|
|
271
|
-
return stableStringify(value);
|
|
272
|
-
} catch {
|
|
273
|
-
return String(value);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
function stableStringify(v) {
|
|
277
|
-
if (v === null || typeof v !== "object") {
|
|
278
|
-
if (typeof v === "function" || v === void 0) return "null";
|
|
279
|
-
return JSON.stringify(v);
|
|
280
|
-
}
|
|
281
|
-
if (Array.isArray(v)) {
|
|
282
|
-
return "[" + v.map(stableStringify).join(",") + "]";
|
|
283
|
-
}
|
|
284
|
-
const obj = v;
|
|
285
|
-
const keys = Object.keys(obj).sort();
|
|
286
|
-
return "{" + keys.map((k) => JSON.stringify(k) + ":" + stableStringify(obj[k])).join(",") + "}";
|
|
287
|
-
}
|
|
288
|
-
|
|
328
|
+
exports.DEFAULT_LAYOUT_DURATION = DEFAULT_LAYOUT_DURATION;
|
|
289
329
|
exports.DEFAULT_SPRING = DEFAULT_SPRING;
|
|
290
330
|
exports.applyDelay = applyDelay;
|
|
291
331
|
exports.buildReleaseAnimation = buildReleaseAnimation;
|
|
292
332
|
exports.cubicBezier = cubicBezier;
|
|
293
333
|
exports.ensureWorkletEasing = ensureWorkletEasing;
|
|
294
334
|
exports.isTopLevelTransition = isTopLevelTransition;
|
|
335
|
+
exports.repeatIterationsOf = repeatIterationsOf;
|
|
295
336
|
exports.resolveAnimatableValue = resolveAnimatableValue;
|
|
296
337
|
exports.resolveTransition = resolveTransition;
|
|
297
338
|
exports.springToReanimated = springToReanimated;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useAnimatedStyle } from 'react-native-reanimated';
|
|
2
|
+
|
|
3
|
+
// src/touch/applyBounds.ts
|
|
4
|
+
function applyBounds(value, min, max, elastic) {
|
|
5
|
+
"worklet";
|
|
6
|
+
if (min !== void 0 && value < min) {
|
|
7
|
+
return elastic > 0 ? min + (value - min) * elastic : min;
|
|
8
|
+
}
|
|
9
|
+
if (max !== void 0 && value > max) {
|
|
10
|
+
return elastic > 0 ? max + (value - max) * elastic : max;
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
function useTranslateStyle(x, y) {
|
|
15
|
+
return useAnimatedStyle(() => ({
|
|
16
|
+
transform: [{ translateX: x.value }, { translateY: y.value }]
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { applyBounds, useTranslateStyle };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk2UGWAB6N_js = require('./chunk-2UGWAB6N.js');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
|
|
6
|
-
var MotionPressable =
|
|
6
|
+
var MotionPressable = chunk2UGWAB6N_js.createMotionComponent(reactNative.Pressable);
|
|
7
7
|
|
|
8
8
|
exports.MotionPressable = MotionPressable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
|
|
2
|
-
import { U as UseGestureHandlers } from '../useGesture-
|
|
3
|
-
import { b as TransitionInput, G as GestureLayerTransitions } from '../types-
|
|
2
|
+
import { U as UseGestureHandlers } from '../useGesture-DjszaHWz.mjs';
|
|
3
|
+
import { b as TransitionInput, G as GestureLayerTransitions } from '../types-08mG8fNk.mjs';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
|
|
@@ -157,4 +157,4 @@ interface UseGestureLayerResult {
|
|
|
157
157
|
*/
|
|
158
158
|
declare function useGestureLayer(states: GestureLayerStates, options?: UseGestureLayerOptions): UseGestureLayerResult;
|
|
159
159
|
|
|
160
|
-
export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
|
|
160
|
+
export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, GestureLayerTransitions, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SharedValue, AnimatedStyle } from 'react-native-reanimated';
|
|
2
|
-
import { U as UseGestureHandlers } from '../useGesture-
|
|
3
|
-
import { b as TransitionInput, G as GestureLayerTransitions } from '../types-
|
|
2
|
+
import { U as UseGestureHandlers } from '../useGesture-D1lHeQQ6.js';
|
|
3
|
+
import { b as TransitionInput, G as GestureLayerTransitions } from '../types-08mG8fNk.js';
|
|
4
4
|
import 'react';
|
|
5
5
|
import 'react-native';
|
|
6
6
|
|
|
@@ -157,4 +157,4 @@ interface UseGestureLayerResult {
|
|
|
157
157
|
*/
|
|
158
158
|
declare function useGestureLayer(states: GestureLayerStates, options?: UseGestureLayerOptions): UseGestureLayerResult;
|
|
159
159
|
|
|
160
|
-
export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
|
|
160
|
+
export { type GestureLayerProgress, type GestureLayerStates, type GestureLayerStyle, GestureLayerTransitions, type UseGestureLayerOptions, type UseGestureLayerResult, useGestureLayer };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk4EZ5DBL3_js = require('../chunk-4EZ5DBL3.js');
|
|
4
|
+
var chunkKXU6VH2Y_js = require('../chunk-KXU6VH2Y.js');
|
|
5
|
+
var chunkN33GSDNQ_js = require('../chunk-N33GSDNQ.js');
|
|
6
6
|
var react = require('react');
|
|
7
7
|
var reactNativeReanimated = require('react-native-reanimated');
|
|
8
8
|
|
|
9
9
|
function useGestureLayer(states, options = {}) {
|
|
10
10
|
const { disabled: isDisabled = false, transition: transitionInput } = options;
|
|
11
|
-
const shouldReduceMotion =
|
|
12
|
-
const transition =
|
|
11
|
+
const shouldReduceMotion = chunkKXU6VH2Y_js.useShouldReduceMotion();
|
|
12
|
+
const transition = chunkKXU6VH2Y_js.resolveNamedTransitionProp(
|
|
13
13
|
transitionInput,
|
|
14
|
-
|
|
14
|
+
chunkKXU6VH2Y_js.useNamedTransitions()
|
|
15
15
|
);
|
|
16
|
-
const gesture =
|
|
16
|
+
const gesture = chunk4EZ5DBL3_js.useGesture(transition);
|
|
17
17
|
const disabledProgress = reactNativeReanimated.useSharedValue(0);
|
|
18
|
-
const transitionSig =
|
|
18
|
+
const transitionSig = chunkN33GSDNQ_js.stableSig(transition);
|
|
19
19
|
react.useEffect(() => {
|
|
20
20
|
const target = isDisabled ? 1 : 0;
|
|
21
21
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
|
|
22
|
-
disabledProgress.value =
|
|
22
|
+
disabledProgress.value = chunkN33GSDNQ_js.resolveTransition(cfg, target);
|
|
23
23
|
}, [isDisabled, shouldReduceMotion, transitionSig, disabledProgress]);
|
|
24
|
+
const statesSig = chunkN33GSDNQ_js.stableSig(states);
|
|
24
25
|
const meta = react.useMemo(() => {
|
|
25
26
|
const layers = {
|
|
26
27
|
rest: states.rest,
|
|
@@ -60,14 +61,7 @@ function useGestureLayer(states, options = {}) {
|
|
|
60
61
|
restValues[k] = restRaw !== void 0 ? restRaw : isColor ? "transparent" : 0;
|
|
61
62
|
}
|
|
62
63
|
return { layers, keys, types, restValues };
|
|
63
|
-
}, [
|
|
64
|
-
states.rest,
|
|
65
|
-
states.hovered,
|
|
66
|
-
states.focused,
|
|
67
|
-
states.focusVisible,
|
|
68
|
-
states.pressed,
|
|
69
|
-
states.disabled
|
|
70
|
-
]);
|
|
64
|
+
}, [statesSig]);
|
|
71
65
|
const style = reactNativeReanimated.useAnimatedStyle(() => {
|
|
72
66
|
const { layers, keys, types, restValues } = meta;
|
|
73
67
|
const ph = gesture.hovered.value;
|
|
@@ -154,7 +148,7 @@ function useGestureLayer(states, options = {}) {
|
|
|
154
148
|
}
|
|
155
149
|
function disabledTransition(transition) {
|
|
156
150
|
if (!transition) return void 0;
|
|
157
|
-
if (
|
|
151
|
+
if (chunkN33GSDNQ_js.isTopLevelTransition(transition)) return transition;
|
|
158
152
|
return void 0;
|
|
159
153
|
}
|
|
160
154
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useGesture } from '../chunk-
|
|
2
|
-
import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-
|
|
3
|
-
import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-
|
|
1
|
+
import { useGesture } from '../chunk-F4HMCXAX.mjs';
|
|
2
|
+
import { useShouldReduceMotion, resolveNamedTransitionProp, useNamedTransitions } from '../chunk-6FCATUMY.mjs';
|
|
3
|
+
import { stableSig, resolveTransition, isTopLevelTransition } from '../chunk-HEAWMZEM.mjs';
|
|
4
4
|
import { useEffect, useMemo } from 'react';
|
|
5
5
|
import { useSharedValue, useAnimatedStyle, interpolateColor } from 'react-native-reanimated';
|
|
6
6
|
|
|
@@ -19,6 +19,7 @@ function useGestureLayer(states, options = {}) {
|
|
|
19
19
|
const cfg = shouldReduceMotion ? { type: "no-animation" } : disabledTransition(transition) ?? { type: "spring" };
|
|
20
20
|
disabledProgress.value = resolveTransition(cfg, target);
|
|
21
21
|
}, [isDisabled, shouldReduceMotion, transitionSig, disabledProgress]);
|
|
22
|
+
const statesSig = stableSig(states);
|
|
22
23
|
const meta = useMemo(() => {
|
|
23
24
|
const layers = {
|
|
24
25
|
rest: states.rest,
|
|
@@ -58,14 +59,7 @@ function useGestureLayer(states, options = {}) {
|
|
|
58
59
|
restValues[k] = restRaw !== void 0 ? restRaw : isColor ? "transparent" : 0;
|
|
59
60
|
}
|
|
60
61
|
return { layers, keys, types, restValues };
|
|
61
|
-
}, [
|
|
62
|
-
states.rest,
|
|
63
|
-
states.hovered,
|
|
64
|
-
states.focused,
|
|
65
|
-
states.focusVisible,
|
|
66
|
-
states.pressed,
|
|
67
|
-
states.disabled
|
|
68
|
-
]);
|
|
62
|
+
}, [statesSig]);
|
|
69
63
|
const style = useAnimatedStyle(() => {
|
|
70
64
|
const { layers, keys, types, restValues } = meta;
|
|
71
65
|
const ph = gesture.hovered.value;
|