@onlynative/inertia 0.0.1-alpha.4 → 0.0.1-alpha.6
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/dist/index.d.mts +30 -4
- package/dist/index.d.ts +30 -4
- package/dist/index.js +123 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +123 -25
- package/dist/index.mjs.map +1 -1
- package/dist/motion/Image.d.mts +1 -1
- package/dist/motion/Image.d.ts +1 -1
- package/dist/motion/Image.js +100 -24
- package/dist/motion/Image.js.map +1 -1
- package/dist/motion/Image.mjs +100 -24
- package/dist/motion/Image.mjs.map +1 -1
- package/dist/motion/Pressable.d.mts +1 -1
- package/dist/motion/Pressable.d.ts +1 -1
- package/dist/motion/Pressable.js +100 -24
- package/dist/motion/Pressable.js.map +1 -1
- package/dist/motion/Pressable.mjs +100 -24
- package/dist/motion/Pressable.mjs.map +1 -1
- package/dist/motion/ScrollView.d.mts +1 -1
- package/dist/motion/ScrollView.d.ts +1 -1
- package/dist/motion/ScrollView.js +100 -24
- package/dist/motion/ScrollView.js.map +1 -1
- package/dist/motion/ScrollView.mjs +100 -24
- package/dist/motion/ScrollView.mjs.map +1 -1
- package/dist/motion/Text.d.mts +1 -1
- package/dist/motion/Text.d.ts +1 -1
- package/dist/motion/Text.js +100 -24
- package/dist/motion/Text.js.map +1 -1
- package/dist/motion/Text.mjs +100 -24
- package/dist/motion/Text.mjs.map +1 -1
- package/dist/motion/View.d.mts +1 -1
- package/dist/motion/View.d.ts +1 -1
- package/dist/motion/View.js +100 -24
- package/dist/motion/View.js.map +1 -1
- package/dist/motion/View.mjs +100 -24
- package/dist/motion/View.mjs.map +1 -1
- package/dist/{types-CjztO3RW.d.mts → types-NmNeJjo1.d.mts} +23 -2
- package/dist/{types-CjztO3RW.d.ts → types-NmNeJjo1.d.ts} +23 -2
- package/jest-preset.js +33 -0
- package/jest-setup.js +209 -0
- package/package.json +5 -1
- package/src/index.ts +1 -0
- package/src/motion/createMotionComponent.tsx +172 -26
- package/src/transitions/easing.ts +25 -3
- package/src/transitions/index.ts +1 -0
- package/src/transitions/runtime.ts +63 -0
- package/src/transitions/spring.ts +1 -0
- package/src/types.ts +23 -1
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
5
|
-
import { M as MotionComponent, A as AnimatableValue, T as TransitionConfig, G as GestureLayerTransitions, S as SpringTransition, V as VariantController } from './types-
|
|
6
|
-
export { a as AnimateStyle, b as AnimationCallbackInfo, D as DecayTransition, c as GestureSubStates, d as MotionProps, N as NoAnimationTransition, P as PerPropertyTransition, R as RepeatConfig, e as SequenceStep, f as TimingTransition, g as Transition, h as VariantsMap } from './types-
|
|
5
|
+
import { M as MotionComponent, A as AnimatableValue, T as TransitionConfig, E as EasingInput, G as GestureLayerTransitions, S as SpringTransition, V as VariantController } from './types-NmNeJjo1.mjs';
|
|
6
|
+
export { a as AnimateStyle, b as AnimationCallbackInfo, D as DecayTransition, c as GestureSubStates, d as MotionProps, N as NoAnimationTransition, P as PerPropertyTransition, R as RepeatConfig, e as SequenceStep, f as TimingTransition, g as Transition, h as VariantsMap } from './types-NmNeJjo1.mjs';
|
|
7
7
|
import { SharedValue } from 'react-native-reanimated';
|
|
8
8
|
export { MotionImage } from './motion/Image.mjs';
|
|
9
9
|
export { MotionPressable } from './motion/Pressable.mjs';
|
|
@@ -165,10 +165,36 @@ declare function resolveAnimatableValue<V extends number | string>(value: Animat
|
|
|
165
165
|
* the consumer's worklets babel plugin (the default Expo/RN setup), the
|
|
166
166
|
* wrapper becomes a real worklet that captures the user fn via closure.
|
|
167
167
|
*
|
|
168
|
+
* Reanimated 4 changed `Easing.bezier(...)` to return an
|
|
169
|
+
* `EasingFunctionFactory` (`{ factory: () => EasingFunction }`) rather than
|
|
170
|
+
* the function itself. The helper accepts both shapes — `EasingFunction` and
|
|
171
|
+
* `EasingFunctionFactory` — and unwraps the factory automatically so
|
|
172
|
+
* consumers don't have to call `.factory()` manually.
|
|
173
|
+
*
|
|
168
174
|
* The user fn must be pure: no JS-thread captured refs, no shared mutable
|
|
169
175
|
* state, no calls to non-worklet APIs.
|
|
170
176
|
*/
|
|
171
|
-
declare function ensureWorkletEasing(easing:
|
|
177
|
+
declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: number) => number) | undefined;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Worklet-safe single-step animation builder. Mirrors a subset of
|
|
181
|
+
* `resolveTransition` for the UI-thread path where the transition config is
|
|
182
|
+
* picked at gesture-release time, not at render time.
|
|
183
|
+
*
|
|
184
|
+
* Supported: spring / timing / decay / no-animation, single-step only.
|
|
185
|
+
* Not supported: sequences, top-level repeat, easing-function
|
|
186
|
+
* auto-worklet-wrapping (pass an already-worklet easing if you need a custom
|
|
187
|
+
* one — most release transitions don't).
|
|
188
|
+
*
|
|
189
|
+
* Use this from gesture worklets (`useDrag` / `usePan` release callbacks, or
|
|
190
|
+
* any custom `Gesture.Pan().onEnd(() => ...)` worklet) to animate a shared
|
|
191
|
+
* value with an Inertia transition without the JS round-trip that would lose
|
|
192
|
+
* the release velocity.
|
|
193
|
+
*
|
|
194
|
+
* For decay transitions, `toValue` is ignored — decay decelerates from the
|
|
195
|
+
* SV's current position via its own physics. Pass `0` if you don't have one.
|
|
196
|
+
*/
|
|
197
|
+
declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number): unknown;
|
|
172
198
|
|
|
173
199
|
/**
|
|
174
200
|
* Drive a `SharedValue<number>` toward `target` with **any** transition shape
|
|
@@ -437,4 +463,4 @@ declare function useScroll(): UseScrollResult;
|
|
|
437
463
|
*/
|
|
438
464
|
declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
|
|
439
465
|
|
|
440
|
-
export { AnimatableValue, type ExtrapolationMode, Motion, MotionComponent, MotionConfig, type MotionConfigValue, Presence, type PresenceContextValue, type ReducedMotion, SpringTransition, TransitionConfig, type UseGestureHandlers, type UseGestureResult, type UseScrollResult, type UseTransformOptions, VariantController, createMotionComponent, ensureWorkletEasing, resolveAnimatableValue, resolveTransition, useAnimation, useGesture, useMotionConfig, useMotionValue, usePresence, useScroll, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
|
466
|
+
export { AnimatableValue, type ExtrapolationMode, Motion, MotionComponent, MotionConfig, type MotionConfigValue, Presence, type PresenceContextValue, type ReducedMotion, SpringTransition, TransitionConfig, type UseGestureHandlers, type UseGestureResult, type UseScrollResult, type UseTransformOptions, VariantController, buildReleaseAnimation, createMotionComponent, ensureWorkletEasing, resolveAnimatableValue, resolveTransition, useAnimation, useGesture, useMotionConfig, useMotionValue, usePresence, useScroll, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react from 'react';
|
|
|
2
2
|
import { ComponentType, ReactNode } from 'react';
|
|
3
3
|
import * as react_native from 'react-native';
|
|
4
4
|
import { NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
|
|
5
|
-
import { M as MotionComponent, A as AnimatableValue, T as TransitionConfig, G as GestureLayerTransitions, S as SpringTransition, V as VariantController } from './types-
|
|
6
|
-
export { a as AnimateStyle, b as AnimationCallbackInfo, D as DecayTransition, c as GestureSubStates, d as MotionProps, N as NoAnimationTransition, P as PerPropertyTransition, R as RepeatConfig, e as SequenceStep, f as TimingTransition, g as Transition, h as VariantsMap } from './types-
|
|
5
|
+
import { M as MotionComponent, A as AnimatableValue, T as TransitionConfig, E as EasingInput, G as GestureLayerTransitions, S as SpringTransition, V as VariantController } from './types-NmNeJjo1.js';
|
|
6
|
+
export { a as AnimateStyle, b as AnimationCallbackInfo, D as DecayTransition, c as GestureSubStates, d as MotionProps, N as NoAnimationTransition, P as PerPropertyTransition, R as RepeatConfig, e as SequenceStep, f as TimingTransition, g as Transition, h as VariantsMap } from './types-NmNeJjo1.js';
|
|
7
7
|
import { SharedValue } from 'react-native-reanimated';
|
|
8
8
|
export { MotionImage } from './motion/Image.js';
|
|
9
9
|
export { MotionPressable } from './motion/Pressable.js';
|
|
@@ -165,10 +165,36 @@ declare function resolveAnimatableValue<V extends number | string>(value: Animat
|
|
|
165
165
|
* the consumer's worklets babel plugin (the default Expo/RN setup), the
|
|
166
166
|
* wrapper becomes a real worklet that captures the user fn via closure.
|
|
167
167
|
*
|
|
168
|
+
* Reanimated 4 changed `Easing.bezier(...)` to return an
|
|
169
|
+
* `EasingFunctionFactory` (`{ factory: () => EasingFunction }`) rather than
|
|
170
|
+
* the function itself. The helper accepts both shapes — `EasingFunction` and
|
|
171
|
+
* `EasingFunctionFactory` — and unwraps the factory automatically so
|
|
172
|
+
* consumers don't have to call `.factory()` manually.
|
|
173
|
+
*
|
|
168
174
|
* The user fn must be pure: no JS-thread captured refs, no shared mutable
|
|
169
175
|
* state, no calls to non-worklet APIs.
|
|
170
176
|
*/
|
|
171
|
-
declare function ensureWorkletEasing(easing:
|
|
177
|
+
declare function ensureWorkletEasing(easing: EasingInput | undefined): ((t: number) => number) | undefined;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Worklet-safe single-step animation builder. Mirrors a subset of
|
|
181
|
+
* `resolveTransition` for the UI-thread path where the transition config is
|
|
182
|
+
* picked at gesture-release time, not at render time.
|
|
183
|
+
*
|
|
184
|
+
* Supported: spring / timing / decay / no-animation, single-step only.
|
|
185
|
+
* Not supported: sequences, top-level repeat, easing-function
|
|
186
|
+
* auto-worklet-wrapping (pass an already-worklet easing if you need a custom
|
|
187
|
+
* one — most release transitions don't).
|
|
188
|
+
*
|
|
189
|
+
* Use this from gesture worklets (`useDrag` / `usePan` release callbacks, or
|
|
190
|
+
* any custom `Gesture.Pan().onEnd(() => ...)` worklet) to animate a shared
|
|
191
|
+
* value with an Inertia transition without the JS round-trip that would lose
|
|
192
|
+
* the release velocity.
|
|
193
|
+
*
|
|
194
|
+
* For decay transitions, `toValue` is ignored — decay decelerates from the
|
|
195
|
+
* SV's current position via its own physics. Pass `0` if you don't have one.
|
|
196
|
+
*/
|
|
197
|
+
declare function buildReleaseAnimation(transition: TransitionConfig, toValue: number): unknown;
|
|
172
198
|
|
|
173
199
|
/**
|
|
174
200
|
* Drive a `SharedValue<number>` toward `target` with **any** transition shape
|
|
@@ -437,4 +463,4 @@ declare function useScroll(): UseScrollResult;
|
|
|
437
463
|
*/
|
|
438
464
|
declare function useVariants<V extends Readonly<Record<string, object>>>(variants: V, initial?: keyof V & string): VariantController<keyof V & string>;
|
|
439
465
|
|
|
440
|
-
export { AnimatableValue, type ExtrapolationMode, Motion, MotionComponent, MotionConfig, type MotionConfigValue, Presence, type PresenceContextValue, type ReducedMotion, SpringTransition, TransitionConfig, type UseGestureHandlers, type UseGestureResult, type UseScrollResult, type UseTransformOptions, VariantController, createMotionComponent, ensureWorkletEasing, resolveAnimatableValue, resolveTransition, useAnimation, useGesture, useMotionConfig, useMotionValue, usePresence, useScroll, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
|
466
|
+
export { AnimatableValue, type ExtrapolationMode, Motion, MotionComponent, MotionConfig, type MotionConfigValue, Presence, type PresenceContextValue, type ReducedMotion, SpringTransition, TransitionConfig, type UseGestureHandlers, type UseGestureResult, type UseScrollResult, type UseTransformOptions, VariantController, buildReleaseAnimation, createMotionComponent, ensureWorkletEasing, resolveAnimatableValue, resolveTransition, useAnimation, useGesture, useMotionConfig, useMotionValue, usePresence, useScroll, useShouldReduceMotion, useSpring, useTransform, useVariants };
|
package/dist/index.js
CHANGED
|
@@ -1461,13 +1461,17 @@ if (globalThis._ALWAYS_FALSE) {
|
|
|
1461
1461
|
// src/transitions/easing.ts
|
|
1462
1462
|
function ensureWorkletEasing(easing) {
|
|
1463
1463
|
if (!easing) return void 0;
|
|
1464
|
-
|
|
1464
|
+
const fn = isEasingFactory(easing) ? easing.factory() : easing;
|
|
1465
|
+
if (isWorkletFunction(fn)) return fn;
|
|
1465
1466
|
const wrapped = (t) => {
|
|
1466
1467
|
"worklet";
|
|
1467
|
-
return
|
|
1468
|
+
return fn(t);
|
|
1468
1469
|
};
|
|
1469
1470
|
return wrapped;
|
|
1470
1471
|
}
|
|
1472
|
+
function isEasingFactory(value) {
|
|
1473
|
+
return typeof value === "object" && value !== null && "factory" in value && typeof value.factory === "function";
|
|
1474
|
+
}
|
|
1471
1475
|
|
|
1472
1476
|
// src/transitions/spring.ts
|
|
1473
1477
|
var DEFAULT_SPRING = {
|
|
@@ -1476,6 +1480,7 @@ var DEFAULT_SPRING = {
|
|
|
1476
1480
|
mass: 1
|
|
1477
1481
|
};
|
|
1478
1482
|
function springToReanimated(t) {
|
|
1483
|
+
"worklet";
|
|
1479
1484
|
return {
|
|
1480
1485
|
stiffness: t.tension ?? DEFAULT_SPRING.tension,
|
|
1481
1486
|
damping: t.friction ?? DEFAULT_SPRING.friction,
|
|
@@ -1730,6 +1735,28 @@ function isTopLevelTransition(t) {
|
|
|
1730
1735
|
if (keys.length === 0) return false;
|
|
1731
1736
|
return keys.every((k) => TRANSITION_CONFIG_KEYS.has(k));
|
|
1732
1737
|
}
|
|
1738
|
+
var DEFAULT_TIMING_DURATION2 = 250;
|
|
1739
|
+
function buildReleaseAnimation(transition, toValue) {
|
|
1740
|
+
"worklet";
|
|
1741
|
+
if (transition.type === "no-animation") return toValue;
|
|
1742
|
+
if (transition.type === "decay") {
|
|
1743
|
+
const cfg = { velocity: transition.velocity ?? 0 };
|
|
1744
|
+
if (transition.deceleration !== void 0) {
|
|
1745
|
+
cfg.deceleration = transition.deceleration;
|
|
1746
|
+
}
|
|
1747
|
+
if (transition.clamp !== void 0) cfg.clamp = transition.clamp;
|
|
1748
|
+
return Animated.withDecay(cfg);
|
|
1749
|
+
}
|
|
1750
|
+
if (transition.type === "timing") {
|
|
1751
|
+
const e = transition.easing;
|
|
1752
|
+
const easingFn = e && typeof e === "object" && "factory" in e ? e.factory() : e ?? Animated.Easing.inOut(Animated.Easing.ease);
|
|
1753
|
+
return Animated.withTiming(toValue, {
|
|
1754
|
+
duration: transition.duration ?? DEFAULT_TIMING_DURATION2,
|
|
1755
|
+
easing: easingFn
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
return Animated.withSpring(toValue, springToReanimated(transition));
|
|
1759
|
+
}
|
|
1733
1760
|
|
|
1734
1761
|
// src/transitions/sig.ts
|
|
1735
1762
|
function stableSig(value) {
|
|
@@ -1801,21 +1828,28 @@ var NUMERIC_TOP_LEVEL_KEYS = [
|
|
|
1801
1828
|
"opacity",
|
|
1802
1829
|
"width",
|
|
1803
1830
|
"height",
|
|
1804
|
-
"borderRadius"
|
|
1831
|
+
"borderRadius",
|
|
1832
|
+
"shadowOpacity",
|
|
1833
|
+
"shadowRadius",
|
|
1834
|
+
"elevation"
|
|
1805
1835
|
];
|
|
1806
1836
|
var COLOR_KEYS = [
|
|
1807
1837
|
"backgroundColor",
|
|
1808
1838
|
"borderColor",
|
|
1809
1839
|
"color",
|
|
1810
|
-
"tintColor"
|
|
1840
|
+
"tintColor",
|
|
1841
|
+
"shadowColor"
|
|
1811
1842
|
];
|
|
1843
|
+
var SHADOW_OFFSET_KEYS = ["shadowOffsetWidth", "shadowOffsetHeight"];
|
|
1812
1844
|
var ALL_KEYS = [
|
|
1813
1845
|
...TRANSFORM_KEYS,
|
|
1814
1846
|
...NUMERIC_TOP_LEVEL_KEYS,
|
|
1815
|
-
...COLOR_KEYS
|
|
1847
|
+
...COLOR_KEYS,
|
|
1848
|
+
...SHADOW_OFFSET_KEYS
|
|
1816
1849
|
];
|
|
1817
1850
|
var TRANSFORM_KEY_SET = new Set(TRANSFORM_KEYS);
|
|
1818
1851
|
var COLOR_KEY_SET = new Set(COLOR_KEYS);
|
|
1852
|
+
var SHADOW_OFFSET_KEY_SET = new Set(SHADOW_OFFSET_KEYS);
|
|
1819
1853
|
var GESTURE_LAYER_NAMES = [
|
|
1820
1854
|
"hovered",
|
|
1821
1855
|
"focused",
|
|
@@ -1837,6 +1871,9 @@ var DEFAULT_RESTING = {
|
|
|
1837
1871
|
width: 0,
|
|
1838
1872
|
height: 0,
|
|
1839
1873
|
borderRadius: 0,
|
|
1874
|
+
shadowOpacity: 0,
|
|
1875
|
+
shadowRadius: 0,
|
|
1876
|
+
elevation: 0,
|
|
1840
1877
|
// 'transparent' is the only safe universal default for colors: it works as
|
|
1841
1878
|
// an initial seed for any color animation (no jarring opaque flash on mount
|
|
1842
1879
|
// when `initial` is omitted) and rgba(0,0,0,0) interpolates cleanly into
|
|
@@ -1844,7 +1881,10 @@ var DEFAULT_RESTING = {
|
|
|
1844
1881
|
backgroundColor: "transparent",
|
|
1845
1882
|
borderColor: "transparent",
|
|
1846
1883
|
color: "transparent",
|
|
1847
|
-
tintColor: "transparent"
|
|
1884
|
+
tintColor: "transparent",
|
|
1885
|
+
shadowColor: "transparent",
|
|
1886
|
+
shadowOffsetWidth: 0,
|
|
1887
|
+
shadowOffsetHeight: 0
|
|
1848
1888
|
};
|
|
1849
1889
|
function transitionFor(prop, transition) {
|
|
1850
1890
|
if (!transition) return void 0;
|
|
@@ -1898,16 +1938,12 @@ function createMotionComponent(Component) {
|
|
|
1898
1938
|
const activeKeysRef = react.useRef(null);
|
|
1899
1939
|
if (activeKeysRef.current === null) {
|
|
1900
1940
|
const touched = /* @__PURE__ */ new Set();
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
if (initialRecord && k in initialRecord) touched.add(k);
|
|
1904
|
-
}
|
|
1941
|
+
collectTouchedKeys(touched, animateRecord);
|
|
1942
|
+
if (initialRecord) collectTouchedKeys(touched, initialRecord);
|
|
1905
1943
|
if (variants) {
|
|
1906
1944
|
for (const variant of Object.values(variants)) {
|
|
1907
1945
|
if (!variant) continue;
|
|
1908
|
-
|
|
1909
|
-
if (k in variant) touched.add(k);
|
|
1910
|
-
}
|
|
1946
|
+
collectTouchedKeys(touched, variant);
|
|
1911
1947
|
}
|
|
1912
1948
|
}
|
|
1913
1949
|
if (gesture) {
|
|
@@ -1918,22 +1954,29 @@ function createMotionComponent(Component) {
|
|
|
1918
1954
|
gesture.hovered
|
|
1919
1955
|
]) {
|
|
1920
1956
|
if (!subState) continue;
|
|
1921
|
-
|
|
1922
|
-
if (k in subState) touched.add(k);
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
if (exitRecord) {
|
|
1927
|
-
for (const k of ALL_KEYS) {
|
|
1928
|
-
if (k in exitRecord) touched.add(k);
|
|
1957
|
+
collectTouchedKeys(touched, subState);
|
|
1929
1958
|
}
|
|
1930
1959
|
}
|
|
1960
|
+
if (exitRecord) collectTouchedKeys(touched, exitRecord);
|
|
1931
1961
|
activeKeysRef.current = ALL_KEYS.filter((k) => touched.has(k));
|
|
1932
1962
|
}
|
|
1933
1963
|
const hasTransformRef = react.useRef(
|
|
1934
1964
|
activeKeysRef.current.some((k) => TRANSFORM_KEY_SET.has(k))
|
|
1935
1965
|
);
|
|
1966
|
+
const hasShadowOffsetRef = react.useRef(
|
|
1967
|
+
activeKeysRef.current.some((k) => SHADOW_OFFSET_KEY_SET.has(k))
|
|
1968
|
+
);
|
|
1936
1969
|
const sharedValues = useAnimatableSharedValues((key) => {
|
|
1970
|
+
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
1971
|
+
const axis = shadowOffsetAxisFor(key);
|
|
1972
|
+
if (initial === false) {
|
|
1973
|
+
return shadowOffsetAxisValue(animateRecord.shadowOffset, axis) ?? DEFAULT_RESTING[key];
|
|
1974
|
+
}
|
|
1975
|
+
return shadowOffsetAxisValue(
|
|
1976
|
+
initialRecord?.shadowOffset,
|
|
1977
|
+
axis
|
|
1978
|
+
) ?? shadowOffsetAxisValue(animateRecord.shadowOffset, axis) ?? DEFAULT_RESTING[key];
|
|
1979
|
+
}
|
|
1937
1980
|
if (initial === false) {
|
|
1938
1981
|
const a = animateRecord[key];
|
|
1939
1982
|
return restValue(a) ?? DEFAULT_RESTING[key];
|
|
@@ -1979,9 +2022,15 @@ function createMotionComponent(Component) {
|
|
|
1979
2022
|
}
|
|
1980
2023
|
const transformGroup = transformPending > 0 ? { remaining: transformPending } : void 0;
|
|
1981
2024
|
for (const key of ALL_KEYS) {
|
|
1982
|
-
const target =
|
|
2025
|
+
const target = SHADOW_OFFSET_KEY_SET.has(key) ? shadowOffsetAxisValue(
|
|
2026
|
+
baseRecord.shadowOffset,
|
|
2027
|
+
shadowOffsetAxisFor(key)
|
|
2028
|
+
) : baseRecord[key];
|
|
1983
2029
|
if (target === void 0) continue;
|
|
1984
|
-
const cfg = shouldReduceMotion ? { type: "no-animation" } : transitionFor(
|
|
2030
|
+
const cfg = shouldReduceMotion ? { type: "no-animation" } : transitionFor(
|
|
2031
|
+
SHADOW_OFFSET_KEY_SET.has(key) ? "shadowOffset" : key,
|
|
2032
|
+
transition
|
|
2033
|
+
);
|
|
1985
2034
|
if (isExiting) pending++;
|
|
1986
2035
|
const factory = makeKeyCallbackFactory(
|
|
1987
2036
|
key,
|
|
@@ -2044,8 +2093,11 @@ function createMotionComponent(Component) {
|
|
|
2044
2093
|
const animatedStyle = Animated.useAnimatedStyle(() => {
|
|
2045
2094
|
const activeKeys = activeKeysRef.current;
|
|
2046
2095
|
const hasTransform = hasTransformRef.current;
|
|
2096
|
+
const hasShadowOffset = hasShadowOffsetRef.current;
|
|
2047
2097
|
const out = {};
|
|
2048
2098
|
const transform = [];
|
|
2099
|
+
let shadowOffsetW = 0;
|
|
2100
|
+
let shadowOffsetH = 0;
|
|
2049
2101
|
const ph = hoveredProgress.value;
|
|
2050
2102
|
const pf = focusedProgress.value;
|
|
2051
2103
|
const pfv = focusVisibleProgress.value;
|
|
@@ -2078,11 +2130,18 @@ function createMotionComponent(Component) {
|
|
|
2078
2130
|
transform.push(
|
|
2079
2131
|
ROTATION_KEYS.has(key) ? { [key]: `${v}deg` } : { [key]: v }
|
|
2080
2132
|
);
|
|
2133
|
+
} else if (key === "shadowOffsetWidth") {
|
|
2134
|
+
shadowOffsetW = v;
|
|
2135
|
+
} else if (key === "shadowOffsetHeight") {
|
|
2136
|
+
shadowOffsetH = v;
|
|
2081
2137
|
} else {
|
|
2082
2138
|
out[key] = v;
|
|
2083
2139
|
}
|
|
2084
2140
|
}
|
|
2085
2141
|
if (hasTransform) out.transform = transform;
|
|
2142
|
+
if (hasShadowOffset) {
|
|
2143
|
+
out.shadowOffset = { width: shadowOffsetW, height: shadowOffsetH };
|
|
2144
|
+
}
|
|
2086
2145
|
return out;
|
|
2087
2146
|
});
|
|
2088
2147
|
const mergedStyle = react.useMemo(
|
|
@@ -2130,12 +2189,22 @@ function useAnimatableSharedValues(init2) {
|
|
|
2130
2189
|
const width = Animated.useSharedValue(init2("width"));
|
|
2131
2190
|
const height = Animated.useSharedValue(init2("height"));
|
|
2132
2191
|
const borderRadius = Animated.useSharedValue(init2("borderRadius"));
|
|
2192
|
+
const shadowOpacity = Animated.useSharedValue(init2("shadowOpacity"));
|
|
2193
|
+
const shadowRadius = Animated.useSharedValue(init2("shadowRadius"));
|
|
2194
|
+
const elevation = Animated.useSharedValue(init2("elevation"));
|
|
2133
2195
|
const backgroundColor = Animated.useSharedValue(
|
|
2134
2196
|
init2("backgroundColor")
|
|
2135
2197
|
);
|
|
2136
2198
|
const borderColor = Animated.useSharedValue(init2("borderColor"));
|
|
2137
2199
|
const color = Animated.useSharedValue(init2("color"));
|
|
2138
2200
|
const tintColor = Animated.useSharedValue(init2("tintColor"));
|
|
2201
|
+
const shadowColor = Animated.useSharedValue(init2("shadowColor"));
|
|
2202
|
+
const shadowOffsetWidth = Animated.useSharedValue(
|
|
2203
|
+
init2("shadowOffsetWidth")
|
|
2204
|
+
);
|
|
2205
|
+
const shadowOffsetHeight = Animated.useSharedValue(
|
|
2206
|
+
init2("shadowOffsetHeight")
|
|
2207
|
+
);
|
|
2139
2208
|
const ref = react.useRef(null);
|
|
2140
2209
|
if (ref.current === null) {
|
|
2141
2210
|
ref.current = {
|
|
@@ -2151,10 +2220,16 @@ function useAnimatableSharedValues(init2) {
|
|
|
2151
2220
|
width,
|
|
2152
2221
|
height,
|
|
2153
2222
|
borderRadius,
|
|
2223
|
+
shadowOpacity,
|
|
2224
|
+
shadowRadius,
|
|
2225
|
+
elevation,
|
|
2154
2226
|
backgroundColor,
|
|
2155
2227
|
borderColor,
|
|
2156
2228
|
color,
|
|
2157
|
-
tintColor
|
|
2229
|
+
tintColor,
|
|
2230
|
+
shadowColor,
|
|
2231
|
+
shadowOffsetWidth,
|
|
2232
|
+
shadowOffsetHeight
|
|
2158
2233
|
};
|
|
2159
2234
|
}
|
|
2160
2235
|
return ref.current;
|
|
@@ -2222,6 +2297,22 @@ function makeKeyCallbackFactory(key, sharedValue, target, onAnimationEndRef, met
|
|
|
2222
2297
|
return cb;
|
|
2223
2298
|
};
|
|
2224
2299
|
}
|
|
2300
|
+
function shadowOffsetAxisFor(key) {
|
|
2301
|
+
return key === "shadowOffsetWidth" ? "width" : "height";
|
|
2302
|
+
}
|
|
2303
|
+
function shadowOffsetAxisValue(source, axis) {
|
|
2304
|
+
return source?.[axis];
|
|
2305
|
+
}
|
|
2306
|
+
function collectTouchedKeys(touched, record) {
|
|
2307
|
+
for (const k of ALL_KEYS) {
|
|
2308
|
+
if (k in record) touched.add(k);
|
|
2309
|
+
}
|
|
2310
|
+
if ("shadowOffset" in record && record.shadowOffset) {
|
|
2311
|
+
const so = record.shadowOffset;
|
|
2312
|
+
if (so.width !== void 0) touched.add("shadowOffsetWidth");
|
|
2313
|
+
if (so.height !== void 0) touched.add("shadowOffsetHeight");
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2225
2316
|
function stepCountOf(v) {
|
|
2226
2317
|
if (Array.isArray(v)) return v.length;
|
|
2227
2318
|
return 1;
|
|
@@ -2291,6 +2382,13 @@ function resolveGestureLayers(gesture) {
|
|
|
2291
2382
|
if (!subState) continue;
|
|
2292
2383
|
const resolved = {};
|
|
2293
2384
|
for (const key of ALL_KEYS) {
|
|
2385
|
+
if (SHADOW_OFFSET_KEY_SET.has(key)) {
|
|
2386
|
+
const axis = shadowOffsetAxisFor(key);
|
|
2387
|
+
const so = subState.shadowOffset;
|
|
2388
|
+
const v = shadowOffsetAxisValue(so, axis);
|
|
2389
|
+
if (v !== void 0) resolved[key] = v;
|
|
2390
|
+
continue;
|
|
2391
|
+
}
|
|
2294
2392
|
const raw = subState[key];
|
|
2295
2393
|
if (raw === void 0) continue;
|
|
2296
2394
|
const t = targetEndValue(raw);
|
|
@@ -2578,6 +2676,7 @@ exports.MotionScrollView = MotionScrollView;
|
|
|
2578
2676
|
exports.MotionText = MotionText;
|
|
2579
2677
|
exports.MotionView = MotionView;
|
|
2580
2678
|
exports.Presence = Presence;
|
|
2679
|
+
exports.buildReleaseAnimation = buildReleaseAnimation;
|
|
2581
2680
|
exports.createMotionComponent = createMotionComponent;
|
|
2582
2681
|
exports.ensureWorkletEasing = ensureWorkletEasing;
|
|
2583
2682
|
exports.resolveAnimatableValue = resolveAnimatableValue;
|