react-native-gtkx 0.2.0-alpha.2 → 0.3.0-alpha.1
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/README.md +5 -2
- package/dist/aliases/index.d.ts +84 -0
- package/dist/aliases/index.js +208 -0
- package/dist/aliases/index.js.map +1 -0
- package/dist/animated/index.d.ts +2 -0
- package/dist/animated/index.js +5 -0
- package/dist/animated/index.js.map +1 -1
- package/dist/animated/types.d.ts +1 -0
- package/dist/animated/types.js.map +1 -1
- package/dist/animated/value-animation.js +17 -4
- package/dist/animated/value-animation.js.map +1 -1
- package/dist/apis/host.gtkx.js +9 -12
- package/dist/apis/host.gtkx.js.map +1 -1
- package/dist/apis/index.d.ts +4 -2
- package/dist/apis/index.js +2 -0
- package/dist/apis/index.js.map +1 -1
- package/dist/apis/keyboard.d.ts +60 -0
- package/dist/apis/keyboard.js +63 -0
- package/dist/apis/keyboard.js.map +1 -0
- package/dist/apis/log-box.d.ts +15 -0
- package/dist/apis/log-box.js +46 -0
- package/dist/apis/log-box.js.map +1 -0
- package/dist/apis/platform.d.ts +18 -1
- package/dist/apis/platform.js.map +1 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +24 -1
- package/dist/common/index.js.map +1 -1
- package/dist/components/animated.d.ts +70 -6
- package/dist/components/animated.js +559 -46
- package/dist/components/animated.js.map +1 -1
- package/dist/components/driven-size.d.ts +27 -0
- package/dist/components/driven-size.js +85 -0
- package/dist/components/driven-size.js.map +1 -0
- package/dist/components/find-node-handle.d.ts +11 -0
- package/dist/components/find-node-handle.js +53 -0
- package/dist/components/find-node-handle.js.map +1 -0
- package/dist/components/flat-list.d.ts +3 -2
- package/dist/components/flat-list.js.map +1 -1
- package/dist/components/frame-scheduler.d.ts +16 -0
- package/dist/components/frame-scheduler.js +37 -0
- package/dist/components/frame-scheduler.js.map +1 -0
- package/dist/components/image.d.ts +6 -1
- package/dist/components/image.js +15 -4
- package/dist/components/image.js.map +1 -1
- package/dist/components/index.d.ts +7 -5
- package/dist/components/index.js +5 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/measure.d.ts +51 -1
- package/dist/components/measure.js +101 -2
- package/dist/components/measure.js.map +1 -1
- package/dist/components/pressable.d.ts +61 -1
- package/dist/components/pressable.js +151 -4
- package/dist/components/pressable.js.map +1 -1
- package/dist/components/rect-store.d.ts +58 -0
- package/dist/components/rect-store.js +124 -3
- package/dist/components/rect-store.js.map +1 -1
- package/dist/components/root.js +6 -1
- package/dist/components/root.js.map +1 -1
- package/dist/components/scroll-phase.d.ts +35 -0
- package/dist/components/scroll-phase.js +26 -0
- package/dist/components/scroll-phase.js.map +1 -0
- package/dist/components/scroll-view.d.ts +39 -3
- package/dist/components/scroll-view.js +378 -43
- package/dist/components/scroll-view.js.map +1 -1
- package/dist/components/text-input.js +9 -25
- package/dist/components/text-input.js.map +1 -1
- package/dist/components/text.d.ts +6 -2
- package/dist/components/text.js +43 -8
- package/dist/components/text.js.map +1 -1
- package/dist/components/use-focus.d.ts +27 -0
- package/dist/components/use-focus.js +116 -0
- package/dist/components/use-focus.js.map +1 -0
- package/dist/components/use-layout-child.d.ts +13 -1
- package/dist/components/use-layout-child.js +188 -5
- package/dist/components/use-layout-child.js.map +1 -1
- package/dist/components/view.d.ts +5 -2
- package/dist/components/view.js +18 -13
- package/dist/components/view.js.map +1 -1
- package/dist/components/virtualized-list.d.ts +45 -5
- package/dist/components/virtualized-list.js +90 -24
- package/dist/components/virtualized-list.js.map +1 -1
- package/dist/components/wheel-scroll-session.d.ts +7 -0
- package/dist/components/wheel-scroll-session.js +53 -0
- package/dist/components/wheel-scroll-session.js.map +1 -0
- package/dist/components/widget-retention.d.ts +35 -0
- package/dist/components/widget-retention.js +169 -0
- package/dist/components/widget-retention.js.map +1 -0
- package/dist/contracts.d.ts +4 -0
- package/dist/contracts.js.map +1 -1
- package/dist/dnd/context.d.ts +69 -0
- package/dist/dnd/context.js +149 -0
- package/dist/dnd/context.js.map +1 -0
- package/dist/dnd/draggable.d.ts +59 -0
- package/dist/dnd/draggable.js +149 -0
- package/dist/dnd/draggable.js.map +1 -0
- package/dist/dnd/droppable.d.ts +24 -0
- package/dist/dnd/droppable.js +74 -0
- package/dist/dnd/droppable.js.map +1 -0
- package/dist/dnd/gtk-controllers.d.ts +39 -0
- package/dist/dnd/gtk-controllers.js +110 -0
- package/dist/dnd/gtk-controllers.js.map +1 -0
- package/dist/dnd/index.d.ts +6 -0
- package/dist/dnd/index.js +31 -0
- package/dist/dnd/index.js.map +1 -0
- package/dist/dnd/order.d.ts +7 -0
- package/dist/dnd/order.js +20 -0
- package/dist/dnd/order.js.map +1 -0
- package/dist/dnd/payload.d.ts +14 -0
- package/dist/dnd/payload.js +41 -0
- package/dist/dnd/payload.js.map +1 -0
- package/dist/dnd/sortable.d.ts +49 -0
- package/dist/dnd/sortable.js +307 -0
- package/dist/dnd/sortable.js.map +1 -0
- package/dist/dnd/types.d.ts +290 -0
- package/dist/dnd/types.js +25 -0
- package/dist/dnd/types.js.map +1 -0
- package/dist/gesture-handler-compat/builder.d.ts +251 -0
- package/dist/gesture-handler-compat/builder.js +513 -0
- package/dist/gesture-handler-compat/builder.js.map +1 -0
- package/dist/gesture-handler-compat/composition.d.ts +23 -0
- package/dist/gesture-handler-compat/composition.js +111 -0
- package/dist/gesture-handler-compat/composition.js.map +1 -0
- package/dist/gesture-handler-compat/deciders.d.ts +3 -0
- package/dist/gesture-handler-compat/deciders.js +47 -0
- package/dist/gesture-handler-compat/deciders.js.map +1 -0
- package/dist/gesture-handler-compat/detector-runtime.d.ts +44 -0
- package/dist/gesture-handler-compat/detector-runtime.js +374 -0
- package/dist/gesture-handler-compat/detector-runtime.js.map +1 -0
- package/dist/gesture-handler-compat/detector.d.ts +22 -0
- package/dist/gesture-handler-compat/detector.js +104 -0
- package/dist/gesture-handler-compat/detector.js.map +1 -0
- package/dist/gesture-handler-compat/fling.d.ts +24 -0
- package/dist/gesture-handler-compat/fling.js +123 -0
- package/dist/gesture-handler-compat/fling.js.map +1 -0
- package/dist/gesture-handler-compat/force-touch.d.ts +13 -0
- package/dist/gesture-handler-compat/force-touch.js +40 -0
- package/dist/gesture-handler-compat/force-touch.js.map +1 -0
- package/dist/gesture-handler-compat/hooks.d.ts +157 -0
- package/dist/gesture-handler-compat/hooks.js +268 -0
- package/dist/gesture-handler-compat/hooks.js.map +1 -0
- package/dist/gesture-handler-compat/hover.d.ts +2 -0
- package/dist/gesture-handler-compat/hover.js +22 -0
- package/dist/gesture-handler-compat/hover.js.map +1 -0
- package/dist/gesture-handler-compat/index.d.ts +98 -0
- package/dist/gesture-handler-compat/index.js +255 -0
- package/dist/gesture-handler-compat/index.js.map +1 -0
- package/dist/gesture-handler-compat/long-press.d.ts +6 -0
- package/dist/gesture-handler-compat/long-press.js +21 -0
- package/dist/gesture-handler-compat/long-press.js.map +1 -0
- package/dist/gesture-handler-compat/manual.d.ts +2 -0
- package/dist/gesture-handler-compat/manual.js +18 -0
- package/dist/gesture-handler-compat/manual.js.map +1 -0
- package/dist/gesture-handler-compat/native.d.ts +7 -0
- package/dist/gesture-handler-compat/native.js +34 -0
- package/dist/gesture-handler-compat/native.js.map +1 -0
- package/dist/gesture-handler-compat/orchestrator.d.ts +77 -0
- package/dist/gesture-handler-compat/orchestrator.js +284 -0
- package/dist/gesture-handler-compat/orchestrator.js.map +1 -0
- package/dist/gesture-handler-compat/pan.d.ts +23 -0
- package/dist/gesture-handler-compat/pan.js +116 -0
- package/dist/gesture-handler-compat/pan.js.map +1 -0
- package/dist/gesture-handler-compat/recognizer.d.ts +268 -0
- package/dist/gesture-handler-compat/recognizer.js +1056 -0
- package/dist/gesture-handler-compat/recognizer.js.map +1 -0
- package/dist/gesture-handler-compat/relations.d.ts +43 -0
- package/dist/gesture-handler-compat/relations.js +128 -0
- package/dist/gesture-handler-compat/relations.js.map +1 -0
- package/dist/gesture-handler-compat/tap.d.ts +6 -0
- package/dist/gesture-handler-compat/tap.js +29 -0
- package/dist/gesture-handler-compat/tap.js.map +1 -0
- package/dist/gesture-handler-compat/touchpad.d.ts +41 -0
- package/dist/gesture-handler-compat/touchpad.js +64 -0
- package/dist/gesture-handler-compat/touchpad.js.map +1 -0
- package/dist/gesture-handler-compat/types.d.ts +441 -0
- package/dist/gesture-handler-compat/types.js +167 -0
- package/dist/gesture-handler-compat/types.js.map +1 -0
- package/dist/gtk/controllers.d.ts +39 -0
- package/dist/gtk/controllers.js +92 -0
- package/dist/gtk/controllers.js.map +1 -0
- package/dist/gtk/index.d.ts +2 -1
- package/dist/gtk/index.js +7 -1
- package/dist/gtk/index.js.map +1 -1
- package/dist/gtkx/bridge/geometry.js +6 -4
- package/dist/gtkx/bridge/geometry.js.map +1 -1
- package/dist/gtkx/bridge/index.d.ts +5 -3
- package/dist/gtkx/bridge/index.js +6 -3
- package/dist/gtkx/bridge/index.js.map +1 -1
- package/dist/gtkx/bridge/slot-portal.js.map +1 -1
- package/dist/gtkx/bridge/use-signal.js +1 -1
- package/dist/gtkx/bridge/use-signal.js.map +1 -1
- package/dist/gtkx/bridge/view-box.d.ts +56 -0
- package/dist/gtkx/bridge/view-box.js +394 -9
- package/dist/gtkx/bridge/view-box.js.map +1 -1
- package/dist/gtkx/bridge/widget-css.d.ts +17 -0
- package/dist/gtkx/bridge/widget-css.js +72 -0
- package/dist/gtkx/bridge/widget-css.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/layout/driven-size.d.ts +12 -0
- package/dist/layout/driven-size.js +70 -0
- package/dist/layout/driven-size.js.map +1 -0
- package/dist/layout/engine.d.ts +17 -1
- package/dist/layout/engine.js +3 -20
- package/dist/layout/engine.js.map +1 -1
- package/dist/layout/node.d.ts +13 -0
- package/dist/layout/node.js +14 -0
- package/dist/layout/node.js.map +1 -1
- package/dist/layout/yoga.d.ts +3 -2
- package/dist/layout/yoga.js +5 -2
- package/dist/layout/yoga.js.map +1 -1
- package/dist/mcp/data/generated.d.ts +257 -60
- package/dist/mcp/data/generated.js +306 -62
- package/dist/mcp/data/generated.js.map +1 -1
- package/dist/metro/index.d.ts +10 -0
- package/dist/metro/index.js +21 -12
- package/dist/metro/index.js.map +1 -1
- package/dist/navigation/sidebar.d.ts +16 -0
- package/dist/navigation/sidebar.js +65 -1
- package/dist/navigation/sidebar.js.map +1 -1
- package/dist/reanimated-compat/animated-ref.d.ts +32 -0
- package/dist/reanimated-compat/animated-ref.js +57 -0
- package/dist/reanimated-compat/animated-ref.js.map +1 -0
- package/dist/reanimated-compat/animation.d.ts +177 -0
- package/dist/reanimated-compat/animation.js +540 -0
- package/dist/reanimated-compat/animation.js.map +1 -0
- package/dist/reanimated-compat/color.d.ts +28 -0
- package/dist/reanimated-compat/color.js +249 -0
- package/dist/reanimated-compat/color.js.map +1 -0
- package/dist/reanimated-compat/decay.d.ts +39 -0
- package/dist/reanimated-compat/decay.js +96 -0
- package/dist/reanimated-compat/decay.js.map +1 -0
- package/dist/reanimated-compat/easing.d.ts +30 -0
- package/dist/reanimated-compat/easing.js +76 -0
- package/dist/reanimated-compat/easing.js.map +1 -0
- package/dist/reanimated-compat/hooks.d.ts +14 -0
- package/dist/reanimated-compat/hooks.js +217 -0
- package/dist/reanimated-compat/hooks.js.map +1 -0
- package/dist/reanimated-compat/index.d.ts +258 -0
- package/dist/reanimated-compat/index.js +464 -0
- package/dist/reanimated-compat/index.js.map +1 -0
- package/dist/reanimated-compat/interpolation.d.ts +18 -0
- package/dist/reanimated-compat/interpolation.js +122 -0
- package/dist/reanimated-compat/interpolation.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-config.d.ts +43 -0
- package/dist/reanimated-compat/layout-animation-config.js +78 -0
- package/dist/reanimated-compat/layout-animation-config.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-presets.d.ts +117 -0
- package/dist/reanimated-compat/layout-animation-presets.js +498 -0
- package/dist/reanimated-compat/layout-animation-presets.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-runtime.d.ts +21 -0
- package/dist/reanimated-compat/layout-animation-runtime.js +311 -0
- package/dist/reanimated-compat/layout-animation-runtime.js.map +1 -0
- package/dist/reanimated-compat/layout-animation-view.d.ts +27 -0
- package/dist/reanimated-compat/layout-animation-view.js +266 -0
- package/dist/reanimated-compat/layout-animation-view.js.map +1 -0
- package/dist/reanimated-compat/layout-animation.d.ts +171 -0
- package/dist/reanimated-compat/layout-animation.js +469 -0
- package/dist/reanimated-compat/layout-animation.js.map +1 -0
- package/dist/reanimated-compat/layout-transitions.d.ts +83 -0
- package/dist/reanimated-compat/layout-transitions.js +350 -0
- package/dist/reanimated-compat/layout-transitions.js.map +1 -0
- package/dist/reanimated-compat/mutable.d.ts +29 -0
- package/dist/reanimated-compat/mutable.js +139 -0
- package/dist/reanimated-compat/mutable.js.map +1 -0
- package/dist/reanimated-compat/props.d.ts +18 -0
- package/dist/reanimated-compat/props.js +111 -0
- package/dist/reanimated-compat/props.js.map +1 -0
- package/dist/reanimated-compat/scroll-handler.d.ts +119 -0
- package/dist/reanimated-compat/scroll-handler.js +274 -0
- package/dist/reanimated-compat/scroll-handler.js.map +1 -0
- package/dist/reanimated-compat/scroll-offset.d.ts +12 -0
- package/dist/reanimated-compat/scroll-offset.js +104 -0
- package/dist/reanimated-compat/scroll-offset.js.map +1 -0
- package/dist/reanimated-compat/style.d.ts +90 -0
- package/dist/reanimated-compat/style.js +452 -0
- package/dist/reanimated-compat/style.js.map +1 -0
- package/dist/reanimated-compat/test-timers.d.ts +28 -0
- package/dist/reanimated-compat/test-timers.js +136 -0
- package/dist/reanimated-compat/test-timers.js.map +1 -0
- package/dist/reanimated-compat/threads.d.ts +13 -0
- package/dist/reanimated-compat/threads.js +41 -0
- package/dist/reanimated-compat/threads.js.map +1 -0
- package/dist/reanimated-compat/tracking.d.ts +41 -0
- package/dist/reanimated-compat/tracking.js +106 -0
- package/dist/reanimated-compat/tracking.js.map +1 -0
- package/dist/reanimated-compat/updater-animations.d.ts +36 -0
- package/dist/reanimated-compat/updater-animations.js +273 -0
- package/dist/reanimated-compat/updater-animations.js.map +1 -0
- package/dist/responder/system.d.ts +80 -7
- package/dist/responder/system.js +143 -23
- package/dist/responder/system.js.map +1 -1
- package/dist/responder/use-responder.d.ts +11 -0
- package/dist/responder/use-responder.js +225 -6
- package/dist/responder/use-responder.js.map +1 -1
- package/dist/runner/host-dev.js +1 -1
- package/dist/runner/host-dev.js.map +1 -1
- package/dist/runner/host.js +1 -1
- package/dist/runner/host.js.map +1 -1
- package/dist/runner/index.js +3 -3
- package/dist/runner/index.js.map +1 -1
- package/dist/sea/gtkx-config-module.js +1 -1
- package/dist/sea/gtkx-config-module.js.map +1 -1
- package/dist/style/absolute-insets.d.ts +26 -0
- package/dist/style/absolute-insets.js +113 -0
- package/dist/style/absolute-insets.js.map +1 -0
- package/dist/style/animated-size.d.ts +25 -0
- package/dist/style/animated-size.js +225 -0
- package/dist/style/animated-size.js.map +1 -0
- package/dist/style/colors.d.ts +17 -0
- package/dist/style/colors.js +25 -6
- package/dist/style/colors.js.map +1 -1
- package/dist/style/imperative-css.d.ts +21 -0
- package/dist/style/imperative-css.js +63 -0
- package/dist/style/imperative-css.js.map +1 -0
- package/dist/style/index.d.ts +2 -1
- package/dist/style/index.js +2 -1
- package/dist/style/index.js.map +1 -1
- package/dist/style/split-style.js +5 -0
- package/dist/style/split-style.js.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unsupported-export.d.ts +8 -0
- package/dist/unsupported-export.js +66 -0
- package/dist/unsupported-export.js.map +1 -0
- package/dist/vite/index.d.ts +21 -8
- package/dist/vite/index.js +127 -82
- package/dist/vite/index.js.map +1 -1
- package/dist/vitest/index.d.ts +2 -2
- package/dist/vitest/index.js.map +1 -1
- package/dist/worklets-compat/index.d.ts +4 -0
- package/dist/worklets-compat/index.js +28 -0
- package/dist/worklets-compat/index.js.map +1 -0
- package/dist/worklets-compat/surface.d.ts +110 -0
- package/dist/worklets-compat/surface.js +153 -0
- package/dist/worklets-compat/surface.js.map +1 -0
- package/package.json +25 -9
- package/types.d.ts +9 -0
- package/dist/common/list.d.ts +0 -82
- package/dist/common/list.js +0 -166
- package/dist/common/list.js.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// `interpolate`, `Extrapolation` and `clamp` — pure functions over numbers,
|
|
2
|
+
// portable from upstream as-is (nothing in them touches a runtime, a thread
|
|
3
|
+
// or the DOM).
|
|
4
|
+
//
|
|
5
|
+
// Not `src/animated/interpolate.ts`: that one COMPILES an
|
|
6
|
+
// InterpolationConfig into a node-to-node mapping for `Animated.Value`, takes
|
|
7
|
+
// a single `extrapolate` for both edges and produces suffixed strings.
|
|
8
|
+
// Reanimated's is a plain `number → number` call taken inside a mapper, with
|
|
9
|
+
// independently configurable left and right extrapolation. Different shape,
|
|
10
|
+
// different call site; the two do not fold into one.
|
|
11
|
+
/** Behaviour for inputs outside `inputRange`. */
|
|
12
|
+
export var Extrapolation;
|
|
13
|
+
(function (Extrapolation) {
|
|
14
|
+
Extrapolation["IDENTITY"] = "identity";
|
|
15
|
+
Extrapolation["CLAMP"] = "clamp";
|
|
16
|
+
Extrapolation["EXTEND"] = "extend";
|
|
17
|
+
})(Extrapolation || (Extrapolation = {}));
|
|
18
|
+
const SUPPORTED = 'Supported values: "extend", "clamp", "identity", Extrapolation.CLAMP, ' +
|
|
19
|
+
"Extrapolation.EXTEND, Extrapolation.IDENTITY";
|
|
20
|
+
const isExtrapolation = (value) => value === Extrapolation.EXTEND ||
|
|
21
|
+
value === Extrapolation.CLAMP ||
|
|
22
|
+
value === Extrapolation.IDENTITY;
|
|
23
|
+
const resolveExtrapolation = (type) => {
|
|
24
|
+
const resolved = {
|
|
25
|
+
extrapolateLeft: Extrapolation.EXTEND,
|
|
26
|
+
extrapolateRight: Extrapolation.EXTEND,
|
|
27
|
+
};
|
|
28
|
+
if (!type) {
|
|
29
|
+
return resolved;
|
|
30
|
+
}
|
|
31
|
+
if (typeof type === "string") {
|
|
32
|
+
if (!isExtrapolation(type)) {
|
|
33
|
+
throw new Error(`react-native-reanimated: unsupported extrapolation "${type}" for interpolate(). ${SUPPORTED}`);
|
|
34
|
+
}
|
|
35
|
+
resolved.extrapolateLeft = type;
|
|
36
|
+
resolved.extrapolateRight = type;
|
|
37
|
+
return resolved;
|
|
38
|
+
}
|
|
39
|
+
const { extrapolateLeft, extrapolateRight } = type;
|
|
40
|
+
if ((extrapolateLeft && !isExtrapolation(extrapolateLeft)) ||
|
|
41
|
+
(extrapolateRight && !isExtrapolation(extrapolateRight))) {
|
|
42
|
+
throw new Error(`react-native-reanimated: unsupported extrapolation for interpolate(). ${SUPPORTED}`);
|
|
43
|
+
}
|
|
44
|
+
if (extrapolateLeft) {
|
|
45
|
+
resolved.extrapolateLeft = extrapolateLeft;
|
|
46
|
+
}
|
|
47
|
+
if (extrapolateRight) {
|
|
48
|
+
resolved.extrapolateRight = extrapolateRight;
|
|
49
|
+
}
|
|
50
|
+
return resolved;
|
|
51
|
+
};
|
|
52
|
+
const extrapolated = (type, direction, value, leftEdgeOutput, rightEdgeOutput, input) => {
|
|
53
|
+
switch (type) {
|
|
54
|
+
case Extrapolation.IDENTITY:
|
|
55
|
+
return input;
|
|
56
|
+
case Extrapolation.CLAMP:
|
|
57
|
+
return direction * value < direction * leftEdgeOutput
|
|
58
|
+
? leftEdgeOutput
|
|
59
|
+
: rightEdgeOutput;
|
|
60
|
+
default:
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const interpolateSegment = (input, segment, config) => {
|
|
65
|
+
const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } = segment;
|
|
66
|
+
if (rightEdgeInput - leftEdgeInput === 0) {
|
|
67
|
+
return leftEdgeOutput;
|
|
68
|
+
}
|
|
69
|
+
const progress = (input - leftEdgeInput) / (rightEdgeInput - leftEdgeInput);
|
|
70
|
+
const value = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput);
|
|
71
|
+
// Which way the output range runs, so "past the left edge" is a comparison
|
|
72
|
+
// that works for a descending outputRange too.
|
|
73
|
+
const direction = rightEdgeOutput >= leftEdgeOutput ? 1 : -1;
|
|
74
|
+
if (direction * value < direction * leftEdgeOutput) {
|
|
75
|
+
return extrapolated(config.extrapolateLeft, direction, value, leftEdgeOutput, rightEdgeOutput, input);
|
|
76
|
+
}
|
|
77
|
+
if (direction * value > direction * rightEdgeOutput) {
|
|
78
|
+
return extrapolated(config.extrapolateRight, direction, value, leftEdgeOutput, rightEdgeOutput, input);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Maps `value` from `inputRange` onto `outputRange` with linear
|
|
84
|
+
* interpolation between the two enclosing stops.
|
|
85
|
+
*/
|
|
86
|
+
export const interpolate = (value, inputRange, outputRange, type) => {
|
|
87
|
+
if (inputRange.length < 2 || outputRange.length < 2) {
|
|
88
|
+
throw new Error("react-native-reanimated: interpolate() input and output ranges must contain at least two values");
|
|
89
|
+
}
|
|
90
|
+
const config = resolveExtrapolation(type);
|
|
91
|
+
const length = inputRange.length;
|
|
92
|
+
if (value > inputRange[length - 1]) {
|
|
93
|
+
return interpolateSegment(value, {
|
|
94
|
+
leftEdgeInput: inputRange[length - 2],
|
|
95
|
+
rightEdgeInput: inputRange[length - 1],
|
|
96
|
+
leftEdgeOutput: outputRange[length - 2],
|
|
97
|
+
rightEdgeOutput: outputRange[length - 1],
|
|
98
|
+
}, config);
|
|
99
|
+
}
|
|
100
|
+
// Binary search for the first stop at or above the value: an interpolation
|
|
101
|
+
// taken per frame over a long keyframe list should not be linear in it.
|
|
102
|
+
let left = 1;
|
|
103
|
+
let right = length - 1;
|
|
104
|
+
while (left < right) {
|
|
105
|
+
const middle = Math.floor((left + right) / 2);
|
|
106
|
+
if (value <= inputRange[middle]) {
|
|
107
|
+
right = middle;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
left = middle + 1;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return interpolateSegment(value, {
|
|
114
|
+
leftEdgeInput: inputRange[left - 1],
|
|
115
|
+
rightEdgeInput: inputRange[left],
|
|
116
|
+
leftEdgeOutput: outputRange[left - 1],
|
|
117
|
+
rightEdgeOutput: outputRange[left],
|
|
118
|
+
}, config);
|
|
119
|
+
};
|
|
120
|
+
/** Constrains `value` to `[min, max]`. */
|
|
121
|
+
export const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
122
|
+
//# sourceMappingURL=interpolation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolation.js","sourceRoot":"","sources":["../../src/reanimated-compat/interpolation.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,eAAe;AACf,EAAE;AACF,0DAA0D;AAC1D,8EAA8E;AAC9E,uEAAuE;AACvE,6EAA6E;AAC7E,4EAA4E;AAC5E,qDAAqD;AAErD,iDAAiD;AACjD,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,sCAAqB,CAAA;IACrB,gCAAe,CAAA;IACf,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AA2BD,MAAM,SAAS,GACb,wEAAwE;IACxE,8CAA8C,CAAA;AAEhD,MAAM,eAAe,GAAG,CAAC,KAAa,EAA0B,EAAE,CAChE,KAAK,KAAK,aAAa,CAAC,MAAM;IAC9B,KAAK,KAAK,aAAa,CAAC,KAAK;IAC7B,KAAK,KAAK,aAAa,CAAC,QAAQ,CAAA;AAElC,MAAM,oBAAoB,GAAG,CAC3B,IAAuB,EACA,EAAE;IACzB,MAAM,QAAQ,GAA0B;QACtC,eAAe,EAAE,aAAa,CAAC,MAAM;QACrC,gBAAgB,EAAE,aAAa,CAAC,MAAM;KACvC,CAAA;IACD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,IAAI,OAA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AAU,EAAE,CACvE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA","sourcesContent":["// `interpolate`, `Extrapolation` and `clamp` — pure functions over numbers,\n// portable from upstream as-is (nothing in them touches a runtime, a thread\n// or the DOM).\n//\n// Not `src/animated/interpolate.ts`: that one COMPILES an\n// InterpolationConfig into a node-to-node mapping for `Animated.Value`, takes\n// a single `extrapolate` for both edges and produces suffixed strings.\n// Reanimated's is a plain `number → number` call taken inside a mapper, with\n// independently configurable left and right extrapolation. Different shape,\n// different call site; the two do not fold into one.\n\n/** Behaviour for inputs outside `inputRange`. */\nexport enum Extrapolation {\n IDENTITY = \"identity\",\n CLAMP = \"clamp\",\n EXTEND = \"extend\",\n}\n\nexport type ExtrapolationConfig = {\n extrapolateLeft?: Extrapolation | string\n extrapolateRight?: Extrapolation | string\n}\n\nexport type ExtrapolationType =\n | ExtrapolationConfig\n | Extrapolation\n | \"identity\"\n | \"clamp\"\n | \"extend\"\n | undefined\n\ntype ResolvedExtrapolation = {\n extrapolateLeft: Extrapolation\n extrapolateRight: Extrapolation\n}\n\ntype Segment = {\n leftEdgeInput: number\n rightEdgeInput: number\n leftEdgeOutput: number\n rightEdgeOutput: number\n}\n\nconst SUPPORTED =\n 'Supported values: \"extend\", \"clamp\", \"identity\", Extrapolation.CLAMP, ' +\n \"Extrapolation.EXTEND, Extrapolation.IDENTITY\"\n\nconst isExtrapolation = (value: string): value is Extrapolation =>\n value === Extrapolation.EXTEND ||\n value === Extrapolation.CLAMP ||\n value === Extrapolation.IDENTITY\n\nconst resolveExtrapolation = (\n type: ExtrapolationType,\n): ResolvedExtrapolation => {\n const resolved: ResolvedExtrapolation = {\n extrapolateLeft: Extrapolation.EXTEND,\n extrapolateRight: Extrapolation.EXTEND,\n }\n if (!type) {\n return resolved\n }\n if (typeof type === \"string\") {\n if (!isExtrapolation(type)) {\n throw new Error(\n `react-native-reanimated: unsupported extrapolation \"${type}\" for interpolate(). ${SUPPORTED}`,\n )\n }\n resolved.extrapolateLeft = type\n resolved.extrapolateRight = type\n return resolved\n }\n const { extrapolateLeft, extrapolateRight } = type\n if (\n (extrapolateLeft && !isExtrapolation(extrapolateLeft)) ||\n (extrapolateRight && !isExtrapolation(extrapolateRight))\n ) {\n throw new Error(\n `react-native-reanimated: unsupported extrapolation for interpolate(). ${SUPPORTED}`,\n )\n }\n if (extrapolateLeft) {\n resolved.extrapolateLeft = extrapolateLeft as Extrapolation\n }\n if (extrapolateRight) {\n resolved.extrapolateRight = extrapolateRight as Extrapolation\n }\n return resolved\n}\n\nconst extrapolated = (\n type: Extrapolation,\n direction: number,\n value: number,\n leftEdgeOutput: number,\n rightEdgeOutput: number,\n input: number,\n): number => {\n switch (type) {\n case Extrapolation.IDENTITY:\n return input\n case Extrapolation.CLAMP:\n return direction * value < direction * leftEdgeOutput\n ? leftEdgeOutput\n : rightEdgeOutput\n default:\n return value\n }\n}\n\nconst interpolateSegment = (\n input: number,\n segment: Segment,\n config: ResolvedExtrapolation,\n): number => {\n const { leftEdgeInput, rightEdgeInput, leftEdgeOutput, rightEdgeOutput } =\n segment\n if (rightEdgeInput - leftEdgeInput === 0) {\n return leftEdgeOutput\n }\n const progress = (input - leftEdgeInput) / (rightEdgeInput - leftEdgeInput)\n const value = leftEdgeOutput + progress * (rightEdgeOutput - leftEdgeOutput)\n // Which way the output range runs, so \"past the left edge\" is a comparison\n // that works for a descending outputRange too.\n const direction = rightEdgeOutput >= leftEdgeOutput ? 1 : -1\n\n if (direction * value < direction * leftEdgeOutput) {\n return extrapolated(\n config.extrapolateLeft,\n direction,\n value,\n leftEdgeOutput,\n rightEdgeOutput,\n input,\n )\n }\n if (direction * value > direction * rightEdgeOutput) {\n return extrapolated(\n config.extrapolateRight,\n direction,\n value,\n leftEdgeOutput,\n rightEdgeOutput,\n input,\n )\n }\n return value\n}\n\n/**\n * Maps `value` from `inputRange` onto `outputRange` with linear\n * interpolation between the two enclosing stops.\n */\nexport const interpolate = (\n value: number,\n inputRange: readonly number[],\n outputRange: readonly number[],\n type?: ExtrapolationType,\n): number => {\n if (inputRange.length < 2 || outputRange.length < 2) {\n throw new Error(\n \"react-native-reanimated: interpolate() input and output ranges must contain at least two values\",\n )\n }\n const config = resolveExtrapolation(type)\n const length = inputRange.length\n\n if (value > inputRange[length - 1]!) {\n return interpolateSegment(\n value,\n {\n leftEdgeInput: inputRange[length - 2]!,\n rightEdgeInput: inputRange[length - 1]!,\n leftEdgeOutput: outputRange[length - 2]!,\n rightEdgeOutput: outputRange[length - 1]!,\n },\n config,\n )\n }\n\n // Binary search for the first stop at or above the value: an interpolation\n // taken per frame over a long keyframe list should not be linear in it.\n let left = 1\n let right = length - 1\n while (left < right) {\n const middle = Math.floor((left + right) / 2)\n if (value <= inputRange[middle]!) {\n right = middle\n } else {\n left = middle + 1\n }\n }\n\n return interpolateSegment(\n value,\n {\n leftEdgeInput: inputRange[left - 1]!,\n rightEdgeInput: inputRange[left]!,\n leftEdgeOutput: outputRange[left - 1]!,\n rightEdgeOutput: outputRange[left]!,\n },\n config,\n )\n}\n\n/** Constrains `value` to `[min, max]`. */\nexport const clamp = (value: number, min: number, max: number): number =>\n Math.min(Math.max(value, min), max)\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ReactNode, type RefObject } from "react";
|
|
2
|
+
export type LayoutAnimationSkip = {
|
|
3
|
+
/** True for the one commit a `skipEntering` wrapper mounts in. */
|
|
4
|
+
entering: RefObject<boolean>;
|
|
5
|
+
/** True once a `skipExiting` wrapper has begun unmounting. */
|
|
6
|
+
exiting: RefObject<boolean>;
|
|
7
|
+
};
|
|
8
|
+
/** @internal Read by `withLayoutAnimations`; not part of upstream's surface. */
|
|
9
|
+
export declare const useLayoutAnimationSkip: () => LayoutAnimationSkip | null;
|
|
10
|
+
export type LayoutAnimationConfigProps = {
|
|
11
|
+
/** Suppresses the `entering` of children that mount with this wrapper. */
|
|
12
|
+
skipEntering?: boolean;
|
|
13
|
+
/** Suppresses the `exiting` of children when this wrapper unmounts. */
|
|
14
|
+
skipExiting?: boolean;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Suppresses `entering` and/or `exiting` for the subtree below it.
|
|
19
|
+
*
|
|
20
|
+
* The classic use is a screen that mounts with a list already populated: the
|
|
21
|
+
* rows should animate when they are ADDED, not when the screen appears.
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <LayoutAnimationConfig skipEntering>
|
|
25
|
+
* {items.map((item) => (
|
|
26
|
+
* <Animated.View key={item.id} entering={FadeIn} />
|
|
27
|
+
* ))}
|
|
28
|
+
* </LayoutAnimationConfig>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Adds no widget to the tree — it renders its children and nothing else.
|
|
32
|
+
*/
|
|
33
|
+
export declare const LayoutAnimationConfig: ({ skipEntering, skipExiting, children, }: LayoutAnimationConfigProps) => ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* Deprecated upstream, where it warns and does nothing — the allow-list it
|
|
36
|
+
* used to write to is gone from Reanimated itself. Mirrored exactly: refusing
|
|
37
|
+
* would break startup code calling it for a setting that changes nothing on
|
|
38
|
+
* any platform, and honouring it would be inventing behaviour upstream
|
|
39
|
+
* removed. Use {@link LayoutAnimationConfig} to actually skip animations.
|
|
40
|
+
*/
|
|
41
|
+
export declare const enableLayoutAnimations: () => void;
|
|
42
|
+
/** @internal Test seam: the deprecation warning is once per session. */
|
|
43
|
+
export declare const resetEnableLayoutAnimationsWarning: () => void;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// `<LayoutAnimationConfig>`: turning entering and exiting animations off for a
|
|
3
|
+
// subtree, and `enableLayoutAnimations`.
|
|
4
|
+
//
|
|
5
|
+
// Both halves are ordinary React here, where upstream needs the native side
|
|
6
|
+
// for one of them. `skipEntering` is a context whose ref is true for exactly
|
|
7
|
+
// one commit — children mounted WITH the wrapper read it from their layout
|
|
8
|
+
// effect and skip; children mounted later find it already false. `skipExiting`
|
|
9
|
+
// is the same trick backwards: React runs a deleted subtree's layout-effect
|
|
10
|
+
// cleanups from the OUTSIDE IN, so this component's own cleanup runs before
|
|
11
|
+
// any of its descendants' and can tell them, through the same context, that
|
|
12
|
+
// the whole subtree is going. Upstream reaches for `findNodeHandle` plus
|
|
13
|
+
// `setShouldAnimateExitingForTag` for that second half only because its
|
|
14
|
+
// exiting animations are configured on the native shadow node, one commit
|
|
15
|
+
// earlier than the information exists; nothing here is configured that early.
|
|
16
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
17
|
+
const LayoutAnimationSkipContext = createContext(null);
|
|
18
|
+
/** @internal Read by `withLayoutAnimations`; not part of upstream's surface. */
|
|
19
|
+
export const useLayoutAnimationSkip = () => useContext(LayoutAnimationSkipContext);
|
|
20
|
+
/**
|
|
21
|
+
* Suppresses `entering` and/or `exiting` for the subtree below it.
|
|
22
|
+
*
|
|
23
|
+
* The classic use is a screen that mounts with a list already populated: the
|
|
24
|
+
* rows should animate when they are ADDED, not when the screen appears.
|
|
25
|
+
*
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <LayoutAnimationConfig skipEntering>
|
|
28
|
+
* {items.map((item) => (
|
|
29
|
+
* <Animated.View key={item.id} entering={FadeIn} />
|
|
30
|
+
* ))}
|
|
31
|
+
* </LayoutAnimationConfig>
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Adds no widget to the tree — it renders its children and nothing else.
|
|
35
|
+
*/
|
|
36
|
+
export const LayoutAnimationConfig = ({ skipEntering, skipExiting, children, }) => {
|
|
37
|
+
const entering = useRef(skipEntering ?? false);
|
|
38
|
+
const exiting = useRef(false);
|
|
39
|
+
// A passive effect, deliberately: every layout effect in the mounting
|
|
40
|
+
// commit — which is where a child's `entering` starts — has already run by
|
|
41
|
+
// the time this fires, so the flag covers that commit and no other.
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
entering.current = false;
|
|
44
|
+
});
|
|
45
|
+
useLayoutEffect(() => {
|
|
46
|
+
return () => {
|
|
47
|
+
if (skipExiting) {
|
|
48
|
+
exiting.current = true;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}, [skipExiting]);
|
|
52
|
+
// `useState` rather than `useRef` for the context VALUE: it has to be
|
|
53
|
+
// stable (a new object would remount every consumer's effects) and it has
|
|
54
|
+
// to be readable during render, and a ref is only the first of those.
|
|
55
|
+
const [skip] = useState(() => ({ entering, exiting }));
|
|
56
|
+
return (_jsx(LayoutAnimationSkipContext, { value: skip, children: children }));
|
|
57
|
+
};
|
|
58
|
+
let warnedAboutEnable = false;
|
|
59
|
+
/**
|
|
60
|
+
* Deprecated upstream, where it warns and does nothing — the allow-list it
|
|
61
|
+
* used to write to is gone from Reanimated itself. Mirrored exactly: refusing
|
|
62
|
+
* would break startup code calling it for a setting that changes nothing on
|
|
63
|
+
* any platform, and honouring it would be inventing behaviour upstream
|
|
64
|
+
* removed. Use {@link LayoutAnimationConfig} to actually skip animations.
|
|
65
|
+
*/
|
|
66
|
+
export const enableLayoutAnimations = () => {
|
|
67
|
+
const isProduction = typeof process !== "undefined" && process.env.NODE_ENV === "production";
|
|
68
|
+
if (warnedAboutEnable || isProduction) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
warnedAboutEnable = true;
|
|
72
|
+
console.warn("`enableLayoutAnimations` is deprecated and will be removed in the future.");
|
|
73
|
+
};
|
|
74
|
+
/** @internal Test seam: the deprecation warning is once per session. */
|
|
75
|
+
export const resetEnableLayoutAnimationsWarning = () => {
|
|
76
|
+
warnedAboutEnable = false;
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=layout-animation-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-animation-config.js","sourceRoot":"","sources":["../../src/reanimated-comp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AAE,OAAO,EAAE,CAAC,CAAC,CAAA;IAC3E,OAAO,CACL,KAAC,0BAA0B,IAAC,KAAK,EAAE,IAAI,YACpC,QAAQ,GACkB,CAC9B,CAAA;AACH,CAAC,CAAA;AAED,IAAI,iBAAiB,GAAG,KAAK,CAAA;AAE7B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAS,EAAE;IAC/C,MAAM,YAAY,GAChB,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;IACzE,IAAI,iBAAiB,IAAI,YAAY,EAAE,CAAC;QACtC,OAAM;IACR,CAAC;IACD,iBAAiB,GAAG,IAAI,CAAA;IACxB,OAAO,CAAC,IAAI,CACV,2EAA2E,CAC5E,CAAA;AACH,CAAC,CAAA;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,kCAAkC,GAAG,GAAS,EAAE;IAC3D,iBAAiB,GAAG,KAAK,CAAA;AAC3B,CAAC,CAAA","sourcesContent":["// `<LayoutAnimationConfig>`: turning entering and exiting animations off for a\n// subtree, and `enableLayoutAnimations`.\n//\n// Both halves are ordinary React here, where upstream needs the native side\n// for one of them. `skipEntering` is a context whose ref is true for exactly\n// one commit — children mounted WITH the wrapper read it from their layout\n// effect and skip; children mounted later find it already false. `skipExiting`\n// is the same trick backwards: React runs a deleted subtree's layout-effect\n// cleanups from the OUTSIDE IN, so this component's own cleanup runs before\n// any of its descendants' and can tell them, through the same context, that\n// the whole subtree is going. Upstream reaches for `findNodeHandle` plus\n// `setShouldAnimateExitingForTag` for that second half only because its\n// exiting animations are configured on the native shadow node, one commit\n// earlier than the information exists; nothing here is configured that early.\nimport {\n createContext,\n useContext,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type ReactNode,\n type RefObject,\n} from \"react\"\n\nexport type LayoutAnimationSkip = {\n /** True for the one commit a `skipEntering` wrapper mounts in. */\n entering: RefObject<boolean>\n /** True once a `skipExiting` wrapper has begun unmounting. */\n exiting: RefObject<boolean>\n}\n\nconst LayoutAnimationSkipContext = createContext<LayoutAnimationSkip | null>(\n null,\n)\n\n/** @internal Read by `withLayoutAnimations`; not part of upstream's surface. */\nexport const useLayoutAnimationSkip = (): LayoutAnimationSkip | null =>\n useContext(LayoutAnimationSkipContext)\n\nexport type LayoutAnimationConfigProps = {\n /** Suppresses the `entering` of children that mount with this wrapper. */\n skipEntering?: boolean\n /** Suppresses the `exiting` of children when this wrapper unmounts. */\n skipExiting?: boolean\n children?: ReactNode\n}\n\n/**\n * Suppresses `entering` and/or `exiting` for the subtree below it.\n *\n * The classic use is a screen that mounts with a list already populated: the\n * rows should animate when they are ADDED, not when the screen appears.\n *\n * ```tsx\n * <LayoutAnimationConfig skipEntering>\n * {items.map((item) => (\n * <Animated.View key={item.id} entering={FadeIn} />\n * ))}\n * </LayoutAnimationConfig>\n * ```\n *\n * Adds no widget to the tree — it renders its children and nothing else.\n */\nexport const LayoutAnimationConfig = ({\n skipEntering,\n skipExiting,\n children,\n}: LayoutAnimationConfigProps): ReactNode => {\n const entering = useRef(skipEntering ?? false)\n const exiting = useRef(false)\n // A passive effect, deliberately: every layout effect in the mounting\n // commit — which is where a child's `entering` starts — has already run by\n // the time this fires, so the flag covers that commit and no other.\n useEffect(() => {\n entering.current = false\n })\n useLayoutEffect(() => {\n return () => {\n if (skipExiting) {\n exiting.current = true\n }\n }\n }, [skipExiting])\n // `useState` rather than `useRef` for the context VALUE: it has to be\n // stable (a new object would remount every consumer's effects) and it has\n // to be readable during render, and a ref is only the first of those.\n const [skip] = useState<LayoutAnimationSkip>(() => ({ entering, exiting }))\n return (\n <LayoutAnimationSkipContext value={skip}>\n {children}\n </LayoutAnimationSkipContext>\n )\n}\n\nlet warnedAboutEnable = false\n\n/**\n * Deprecated upstream, where it warns and does nothing — the allow-list it\n * used to write to is gone from Reanimated itself. Mirrored exactly: refusing\n * would break startup code calling it for a setting that changes nothing on\n * any platform, and honouring it would be inventing behaviour upstream\n * removed. Use {@link LayoutAnimationConfig} to actually skip animations.\n */\nexport const enableLayoutAnimations = (): void => {\n const isProduction =\n typeof process !== \"undefined\" && process.env.NODE_ENV === \"production\"\n if (warnedAboutEnable || isProduction) {\n return\n }\n warnedAboutEnable = true\n console.warn(\n \"`enableLayoutAnimations` is deprecated and will be removed in the future.\",\n )\n}\n\n/** @internal Test seam: the deprecation warning is once per session. */\nexport const resetEnableLayoutAnimationsWarning = (): void => {\n warnedAboutEnable = false\n}\n"]}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { AnimationBuilder, type BuiltLayoutAnimation, type LayoutAnimationValues } from "./layout-animation";
|
|
2
|
+
/** A constant, or a number derived from the rects the builder was handed. */
|
|
3
|
+
type Measure = number | ((values: LayoutAnimationValues) => number);
|
|
4
|
+
/**
|
|
5
|
+
* One animated property: where it starts, and where it goes.
|
|
6
|
+
*
|
|
7
|
+
* `to` is animated with the BUILDER's animation, so `.springify()`,
|
|
8
|
+
* `.duration()` and `.easing()` all reach it. `steps` is an explicit timing
|
|
9
|
+
* track — upstream writes the bounce curves as literal `withTiming`
|
|
10
|
+
* sequences, and a spring has no way to express "overshoot to 1.2, settle
|
|
11
|
+
* through 0.9 and 1.1" — where each step is a target plus the fraction of the
|
|
12
|
+
* builder's duration it takes.
|
|
13
|
+
*/
|
|
14
|
+
type Track = {
|
|
15
|
+
from: Measure;
|
|
16
|
+
to?: Measure;
|
|
17
|
+
steps?: readonly (readonly [Measure, number])[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The transform keys the catalogue uses, which are exactly the keys
|
|
21
|
+
* src/style/transform.ts folds into its matrix. `rotate` is in DEGREES here:
|
|
22
|
+
* upstream spells it `'-90deg'`/`'5rad'`, and a string cannot go through a
|
|
23
|
+
* numeric animation — `parseAngle` reads a bare number as degrees, so the
|
|
24
|
+
* matrix that reaches GTK is the same one either spelling produces.
|
|
25
|
+
*/
|
|
26
|
+
type TransformKey = "translateX" | "translateY" | "scale" | "scaleX" | "scaleY" | "rotate";
|
|
27
|
+
type TransformTrack = Track & {
|
|
28
|
+
key: TransformKey;
|
|
29
|
+
};
|
|
30
|
+
type PresetSpec = {
|
|
31
|
+
opacity?: Track;
|
|
32
|
+
/** `SlideIn*`/`SlideOut*`: the only presets that move the layout origin. */
|
|
33
|
+
origin?: Track & {
|
|
34
|
+
axis: "x" | "y";
|
|
35
|
+
};
|
|
36
|
+
transform?: readonly TransformTrack[];
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The one preset body. Every entry in the catalogue is an empty subclass of
|
|
40
|
+
* this carrying its own {@link PresetSpec}.
|
|
41
|
+
*/
|
|
42
|
+
export declare class LayoutAnimationPreset extends AnimationBuilder {
|
|
43
|
+
/**
|
|
44
|
+
* Replaced by every generated subclass — see `definePreset`. A method
|
|
45
|
+
* rather than a field so the two `.rotate()`-aware presets can compute
|
|
46
|
+
* theirs from builder state that is only settled by the time `build()` runs.
|
|
47
|
+
*/
|
|
48
|
+
protected spec(): PresetSpec;
|
|
49
|
+
build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation;
|
|
50
|
+
}
|
|
51
|
+
export declare const FadeInRight: typeof LayoutAnimationPreset;
|
|
52
|
+
export declare const FadeInLeft: typeof LayoutAnimationPreset;
|
|
53
|
+
export declare const FadeInUp: typeof LayoutAnimationPreset;
|
|
54
|
+
export declare const FadeInDown: typeof LayoutAnimationPreset;
|
|
55
|
+
export declare const FadeOutRight: typeof LayoutAnimationPreset;
|
|
56
|
+
export declare const FadeOutLeft: typeof LayoutAnimationPreset;
|
|
57
|
+
export declare const FadeOutUp: typeof LayoutAnimationPreset;
|
|
58
|
+
export declare const FadeOutDown: typeof LayoutAnimationPreset;
|
|
59
|
+
export declare const BounceIn: typeof LayoutAnimationPreset;
|
|
60
|
+
export declare const BounceInDown: typeof LayoutAnimationPreset;
|
|
61
|
+
export declare const BounceInUp: typeof LayoutAnimationPreset;
|
|
62
|
+
export declare const BounceInLeft: typeof LayoutAnimationPreset;
|
|
63
|
+
export declare const BounceInRight: typeof LayoutAnimationPreset;
|
|
64
|
+
export declare const BounceOut: typeof LayoutAnimationPreset;
|
|
65
|
+
export declare const BounceOutDown: typeof LayoutAnimationPreset;
|
|
66
|
+
export declare const BounceOutUp: typeof LayoutAnimationPreset;
|
|
67
|
+
export declare const BounceOutLeft: typeof LayoutAnimationPreset;
|
|
68
|
+
export declare const BounceOutRight: typeof LayoutAnimationPreset;
|
|
69
|
+
export declare const PinwheelIn: typeof LayoutAnimationPreset;
|
|
70
|
+
export declare const PinwheelOut: typeof LayoutAnimationPreset;
|
|
71
|
+
export declare const RollInLeft: typeof LayoutAnimationPreset;
|
|
72
|
+
export declare const RollInRight: typeof LayoutAnimationPreset;
|
|
73
|
+
export declare const RollOutLeft: typeof LayoutAnimationPreset;
|
|
74
|
+
export declare const RollOutRight: typeof LayoutAnimationPreset;
|
|
75
|
+
export declare const RotateInDownLeft: typeof LayoutAnimationPreset;
|
|
76
|
+
export declare const RotateInDownRight: typeof LayoutAnimationPreset;
|
|
77
|
+
export declare const RotateInUpLeft: typeof LayoutAnimationPreset;
|
|
78
|
+
export declare const RotateInUpRight: typeof LayoutAnimationPreset;
|
|
79
|
+
export declare const RotateOutDownLeft: typeof LayoutAnimationPreset;
|
|
80
|
+
export declare const RotateOutDownRight: typeof LayoutAnimationPreset;
|
|
81
|
+
export declare const RotateOutUpLeft: typeof LayoutAnimationPreset;
|
|
82
|
+
export declare const RotateOutUpRight: typeof LayoutAnimationPreset;
|
|
83
|
+
export declare const SlideInRight: typeof LayoutAnimationPreset;
|
|
84
|
+
export declare const SlideInLeft: typeof LayoutAnimationPreset;
|
|
85
|
+
export declare const SlideOutRight: typeof LayoutAnimationPreset;
|
|
86
|
+
export declare const SlideOutLeft: typeof LayoutAnimationPreset;
|
|
87
|
+
export declare const SlideInUp: typeof LayoutAnimationPreset;
|
|
88
|
+
export declare const SlideInDown: typeof LayoutAnimationPreset;
|
|
89
|
+
export declare const SlideOutUp: typeof LayoutAnimationPreset;
|
|
90
|
+
export declare const SlideOutDown: typeof LayoutAnimationPreset;
|
|
91
|
+
export declare const StretchInX: typeof LayoutAnimationPreset;
|
|
92
|
+
export declare const StretchInY: typeof LayoutAnimationPreset;
|
|
93
|
+
export declare const StretchOutX: typeof LayoutAnimationPreset;
|
|
94
|
+
export declare const StretchOutY: typeof LayoutAnimationPreset;
|
|
95
|
+
export declare const ZoomIn: typeof LayoutAnimationPreset;
|
|
96
|
+
export declare const ZoomInLeft: typeof LayoutAnimationPreset;
|
|
97
|
+
export declare const ZoomInRight: typeof LayoutAnimationPreset;
|
|
98
|
+
export declare const ZoomInUp: typeof LayoutAnimationPreset;
|
|
99
|
+
export declare const ZoomInDown: typeof LayoutAnimationPreset;
|
|
100
|
+
export declare const ZoomInEasyUp: typeof LayoutAnimationPreset;
|
|
101
|
+
export declare const ZoomInEasyDown: typeof LayoutAnimationPreset;
|
|
102
|
+
export declare const ZoomOut: typeof LayoutAnimationPreset;
|
|
103
|
+
export declare const ZoomOutLeft: typeof LayoutAnimationPreset;
|
|
104
|
+
export declare const ZoomOutRight: typeof LayoutAnimationPreset;
|
|
105
|
+
export declare const ZoomOutUp: typeof LayoutAnimationPreset;
|
|
106
|
+
export declare const ZoomOutDown: typeof LayoutAnimationPreset;
|
|
107
|
+
export declare const ZoomOutEasyUp: typeof LayoutAnimationPreset;
|
|
108
|
+
export declare const ZoomOutEasyDown: typeof LayoutAnimationPreset;
|
|
109
|
+
/** `ZoomIn` with a spin. `.rotate()` sets the angle; upstream's default is 0.3 rad. */
|
|
110
|
+
export declare class ZoomInRotate extends LayoutAnimationPreset {
|
|
111
|
+
protected spec(): PresetSpec;
|
|
112
|
+
}
|
|
113
|
+
/** `ZoomOut` with a spin. `.rotate()` sets the angle; upstream's default is 0.3 rad. */
|
|
114
|
+
export declare class ZoomOutRotate extends LayoutAnimationPreset {
|
|
115
|
+
protected spec(): PresetSpec;
|
|
116
|
+
}
|
|
117
|
+
export {};
|