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,350 @@
|
|
|
1
|
+
// The `layout` transitions beyond `LinearTransition`: `CurvedTransition`,
|
|
2
|
+
// `FadingTransition`, `JumpingTransition`, `SequencedTransition` and
|
|
3
|
+
// `EntryExitTransition`.
|
|
4
|
+
//
|
|
5
|
+
// All five emit the same four properties `LinearTransition` does — `originX`,
|
|
6
|
+
// `originY`, `width`, `height` — and differ only in the curve each takes to
|
|
7
|
+
// get there, so they need nothing from the runtime that is not already
|
|
8
|
+
// wired. The one thing they inherit with that is its documented difference:
|
|
9
|
+
// the position animates (as a paint-only translation) and a size change lands
|
|
10
|
+
// immediately, because a Yoga pass per frame costs what the TREE costs rather
|
|
11
|
+
// than what the value costs (docs/research/animated-colors.md). Where a
|
|
12
|
+
// transition's only parameter is a size curve — `CurvedTransition`'s
|
|
13
|
+
// `.easingWidth()`/`.easingHeight()` — that parameter is therefore accepted
|
|
14
|
+
// and ignored, and the row is in docs/api.md's differences table.
|
|
15
|
+
//
|
|
16
|
+
// Parameters are upstream's, from react-native-reanimated 4.5.3
|
|
17
|
+
// (src/layoutReanimation/defaultTransitions/): the four default easings of a
|
|
18
|
+
// curved transition, the 500 ms default of a fading and a sequenced one
|
|
19
|
+
// against the 300 ms everything else uses, the out-exp/bounce pair a jump
|
|
20
|
+
// arcs through.
|
|
21
|
+
import { withDelay, withSequence, withTiming } from "./animation";
|
|
22
|
+
import { Easing, } from "./easing";
|
|
23
|
+
import { AnimationBuilder, FadeIn, FadeOut, } from "./layout-animation";
|
|
24
|
+
const resolveBuilder = (source) => source;
|
|
25
|
+
/**
|
|
26
|
+
* Walks a view to its new rect with a SEPARATE easing per axis, which is what
|
|
27
|
+
* makes the path a curve rather than a straight line: an ease-in on x against
|
|
28
|
+
* an ease-out on y bends the trajectory.
|
|
29
|
+
*
|
|
30
|
+
* `.easingWidth()` and `.easingHeight()` are accepted and ignored — see the
|
|
31
|
+
* header, and docs/api.md.
|
|
32
|
+
*/
|
|
33
|
+
export class CurvedTransition extends AnimationBuilder {
|
|
34
|
+
easingXV = Easing.in(Easing.ease);
|
|
35
|
+
easingYV = Easing.out(Easing.ease);
|
|
36
|
+
easingWidthV = Easing.in(Easing.exp);
|
|
37
|
+
easingHeightV = Easing.out(Easing.exp);
|
|
38
|
+
easingX(easing) {
|
|
39
|
+
this.easingXV = easing;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
easingY(easing) {
|
|
43
|
+
this.easingYV = easing;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
easingWidth(easing) {
|
|
47
|
+
this.easingWidthV = easing;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
easingHeight(easing) {
|
|
51
|
+
this.easingHeightV = easing;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
static easingX(easing) {
|
|
55
|
+
return new CurvedTransition().easingX(easing);
|
|
56
|
+
}
|
|
57
|
+
static easingY(easing) {
|
|
58
|
+
return new CurvedTransition().easingY(easing);
|
|
59
|
+
}
|
|
60
|
+
static easingWidth(easing) {
|
|
61
|
+
return new CurvedTransition().easingWidth(easing);
|
|
62
|
+
}
|
|
63
|
+
static easingHeight(easing) {
|
|
64
|
+
return new CurvedTransition().easingHeight(easing);
|
|
65
|
+
}
|
|
66
|
+
build() {
|
|
67
|
+
const delayMs = this.getDelay();
|
|
68
|
+
const duration = this.getDuration();
|
|
69
|
+
const callback = this.callbackV;
|
|
70
|
+
const easingX = this.easingXV;
|
|
71
|
+
const easingY = this.easingYV;
|
|
72
|
+
const easingWidth = this.easingWidthV;
|
|
73
|
+
const easingHeight = this.easingHeightV;
|
|
74
|
+
return (values) => ({
|
|
75
|
+
initialValues: {
|
|
76
|
+
originX: values.currentOriginX,
|
|
77
|
+
originY: values.currentOriginY,
|
|
78
|
+
width: values.currentWidth,
|
|
79
|
+
height: values.currentHeight,
|
|
80
|
+
},
|
|
81
|
+
animations: {
|
|
82
|
+
originX: this.delayed(delayMs, withTiming(values.targetOriginX, { duration, easing: easingX })),
|
|
83
|
+
originY: this.delayed(delayMs, withTiming(values.targetOriginY, { duration, easing: easingY })),
|
|
84
|
+
width: this.delayed(delayMs, withTiming(values.targetWidth, { duration, easing: easingWidth })),
|
|
85
|
+
height: this.delayed(delayMs, withTiming(values.targetHeight, { duration, easing: easingHeight })),
|
|
86
|
+
},
|
|
87
|
+
callback,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Fades the view out, moves it while it is invisible, and fades it back in —
|
|
93
|
+
* the transition for a rect change too large to be worth watching. Upstream's
|
|
94
|
+
* default length is 500 ms rather than the 300 ms everything else uses.
|
|
95
|
+
*/
|
|
96
|
+
export class FadingTransition extends AnimationBuilder {
|
|
97
|
+
/** Upstream's own default for this transition, and only this one. */
|
|
98
|
+
getDuration() {
|
|
99
|
+
return this.durationV ?? 500;
|
|
100
|
+
}
|
|
101
|
+
build() {
|
|
102
|
+
const delayMs = this.getDelay();
|
|
103
|
+
const halfDuration = this.getDuration() / 2;
|
|
104
|
+
const callback = this.callbackV;
|
|
105
|
+
// The rect lands at the bottom of the fade, so it is a zero-length timing
|
|
106
|
+
// held behind the first half — not a curve at all.
|
|
107
|
+
const snap = (target) => withDelay(delayMs + halfDuration, withTiming(target, { duration: 0 }));
|
|
108
|
+
return (values) => ({
|
|
109
|
+
initialValues: {
|
|
110
|
+
opacity: 1,
|
|
111
|
+
originX: values.currentOriginX,
|
|
112
|
+
originY: values.currentOriginY,
|
|
113
|
+
width: values.currentWidth,
|
|
114
|
+
height: values.currentHeight,
|
|
115
|
+
},
|
|
116
|
+
animations: {
|
|
117
|
+
opacity: this.delayed(delayMs, withSequence(withTiming(0, { duration: halfDuration }), withTiming(1, { duration: halfDuration }))),
|
|
118
|
+
originX: snap(values.targetOriginX),
|
|
119
|
+
originY: snap(values.targetOriginY),
|
|
120
|
+
width: snap(values.targetWidth),
|
|
121
|
+
height: snap(values.targetHeight),
|
|
122
|
+
},
|
|
123
|
+
callback,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Arcs the view to its new position: it leaps clear of both the old and the
|
|
129
|
+
* new row on an ease-out-exp, then drops onto the target on a bounce. The
|
|
130
|
+
* height of the leap is the distance travelled, so a short move barely hops.
|
|
131
|
+
*/
|
|
132
|
+
export class JumpingTransition extends AnimationBuilder {
|
|
133
|
+
build() {
|
|
134
|
+
const delayMs = this.getDelay();
|
|
135
|
+
const duration = this.getDuration();
|
|
136
|
+
const halfDuration = duration / 2;
|
|
137
|
+
const callback = this.callbackV;
|
|
138
|
+
return (values) => {
|
|
139
|
+
const distance = Math.max(Math.abs(values.targetOriginX - values.currentOriginX), Math.abs(values.targetOriginY - values.currentOriginY));
|
|
140
|
+
return {
|
|
141
|
+
initialValues: {
|
|
142
|
+
originX: values.currentOriginX,
|
|
143
|
+
originY: values.currentOriginY,
|
|
144
|
+
width: values.currentWidth,
|
|
145
|
+
height: values.currentHeight,
|
|
146
|
+
},
|
|
147
|
+
animations: {
|
|
148
|
+
originX: this.delayed(delayMs, withTiming(values.targetOriginX, { duration })),
|
|
149
|
+
originY: this.delayed(delayMs, withSequence(withTiming(Math.min(values.targetOriginY, values.currentOriginY) -
|
|
150
|
+
distance, { duration: halfDuration, easing: Easing.out(Easing.exp) }), withTiming(values.targetOriginY, {
|
|
151
|
+
duration: halfDuration,
|
|
152
|
+
easing: Easing.bounce,
|
|
153
|
+
}))),
|
|
154
|
+
width: this.delayed(delayMs, withTiming(values.targetWidth, { duration })),
|
|
155
|
+
height: this.delayed(delayMs, withTiming(values.targetHeight, { duration })),
|
|
156
|
+
},
|
|
157
|
+
callback,
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Moves one axis at a time: x first and then y, or the reverse with
|
|
164
|
+
* `.reverse()`. Upstream's default length is 500 ms, split evenly.
|
|
165
|
+
*/
|
|
166
|
+
export class SequencedTransition extends AnimationBuilder {
|
|
167
|
+
reversed = false;
|
|
168
|
+
reverse() {
|
|
169
|
+
this.reversed = !this.reversed;
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
static reverse() {
|
|
173
|
+
return new SequencedTransition().reverse();
|
|
174
|
+
}
|
|
175
|
+
/** Upstream's own default for this transition. */
|
|
176
|
+
getDuration() {
|
|
177
|
+
return this.durationV ?? 500;
|
|
178
|
+
}
|
|
179
|
+
build() {
|
|
180
|
+
const delayMs = this.getDelay();
|
|
181
|
+
const config = { duration: this.getDuration() / 2 };
|
|
182
|
+
const callback = this.callbackV;
|
|
183
|
+
const reverse = this.reversed;
|
|
184
|
+
// Each property runs two halves; the one that moves in the FIRST half is
|
|
185
|
+
// the one whose intermediate target is already the destination.
|
|
186
|
+
const twoStep = (first, target) => this.delayed(delayMs, withSequence(withTiming(first, config), withTiming(target, config)));
|
|
187
|
+
return (values) => ({
|
|
188
|
+
initialValues: {
|
|
189
|
+
originX: values.currentOriginX,
|
|
190
|
+
originY: values.currentOriginY,
|
|
191
|
+
width: values.currentWidth,
|
|
192
|
+
height: values.currentHeight,
|
|
193
|
+
},
|
|
194
|
+
animations: {
|
|
195
|
+
originX: twoStep(reverse ? values.currentOriginX : values.targetOriginX, values.targetOriginX),
|
|
196
|
+
originY: twoStep(reverse ? values.targetOriginY : values.currentOriginY, values.targetOriginY),
|
|
197
|
+
width: twoStep(reverse ? values.currentWidth : values.targetWidth, values.targetWidth),
|
|
198
|
+
height: twoStep(reverse ? values.targetHeight : values.currentHeight, values.targetHeight),
|
|
199
|
+
},
|
|
200
|
+
callback,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// The value a transform slot returns to between an exit and an entry, decided
|
|
205
|
+
// from the KEY. Upstream reads it off the animation object's `current`, which
|
|
206
|
+
// is a field of ITS animation representation; the descriptors here are plain
|
|
207
|
+
// data with no running value, and the key answers the same question — a
|
|
208
|
+
// translate rests at 0, a scale at 1, an angle at 0.
|
|
209
|
+
const neutralTransformValue = (key) => key.startsWith("scale") ? 1 : 0;
|
|
210
|
+
const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
|
|
211
|
+
/**
|
|
212
|
+
* Plays a full exit animation and then a full entry animation on the SAME
|
|
213
|
+
* view when its layout changes — the transition for a view whose content
|
|
214
|
+
* changed so much that moving it would read as the wrong thing moving.
|
|
215
|
+
*
|
|
216
|
+
* `.entering()` and `.exiting()` take any builder (or builder class); the
|
|
217
|
+
* defaults are `FadeIn` and `FadeOut`. The two built configs are composed
|
|
218
|
+
* here rather than run one after the other, so the whole thing is still one
|
|
219
|
+
* animation with one callback.
|
|
220
|
+
*/
|
|
221
|
+
export class EntryExitTransition extends AnimationBuilder {
|
|
222
|
+
enteringV = FadeIn;
|
|
223
|
+
exitingV = FadeOut;
|
|
224
|
+
entering(animation) {
|
|
225
|
+
this.enteringV = animation;
|
|
226
|
+
return this;
|
|
227
|
+
}
|
|
228
|
+
exiting(animation) {
|
|
229
|
+
this.exitingV = animation;
|
|
230
|
+
return this;
|
|
231
|
+
}
|
|
232
|
+
static entering(animation) {
|
|
233
|
+
return new EntryExitTransition().entering(animation);
|
|
234
|
+
}
|
|
235
|
+
static exiting(animation) {
|
|
236
|
+
return new EntryExitTransition().exiting(animation);
|
|
237
|
+
}
|
|
238
|
+
build() {
|
|
239
|
+
const delayMs = this.getDelay();
|
|
240
|
+
const callback = this.callbackV;
|
|
241
|
+
const enteringBuild = resolveBuilder(this.enteringV).build();
|
|
242
|
+
const exitingBuild = resolveBuilder(this.exitingV).build();
|
|
243
|
+
const exitingDuration = resolveBuilder(this.exitingV).getDuration();
|
|
244
|
+
return (values) => {
|
|
245
|
+
const entering = enteringBuild(values);
|
|
246
|
+
const exiting = exitingBuild(values);
|
|
247
|
+
const animations = {};
|
|
248
|
+
const transform = [];
|
|
249
|
+
const eachTransform = (source, visit) => {
|
|
250
|
+
if (!Array.isArray(source)) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
source.forEach((entry, index) => {
|
|
254
|
+
if (typeof entry === "object" && entry !== null) {
|
|
255
|
+
for (const [key, value] of Object.entries(entry)) {
|
|
256
|
+
visit(index, key, value);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
};
|
|
261
|
+
const initialTransformValue = (config, index, key) => {
|
|
262
|
+
const slots = config.initialValues.transform;
|
|
263
|
+
const slot = Array.isArray(slots)
|
|
264
|
+
? slots[index]
|
|
265
|
+
: undefined;
|
|
266
|
+
const value = slot?.[key];
|
|
267
|
+
return isFiniteNumber(value) ? value : 0;
|
|
268
|
+
};
|
|
269
|
+
// The exit runs first, and every property it touched is snapped back to
|
|
270
|
+
// where the ENTRY wants to begin before the entry plays.
|
|
271
|
+
eachTransform(exiting.animations.transform, (index, key, value) => {
|
|
272
|
+
transform.push({
|
|
273
|
+
[key]: this.delayed(delayMs, withSequence(value, withTiming(initialTransformValue(exiting, index, key), {
|
|
274
|
+
duration: 0,
|
|
275
|
+
}))),
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
for (const [property, value] of Object.entries(exiting.animations)) {
|
|
279
|
+
if (property === "transform") {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const enteringAnimation = entering.animations[property];
|
|
283
|
+
const bridgeTo = enteringAnimation !== undefined
|
|
284
|
+
? entering.initialValues[property]
|
|
285
|
+
: (values[property] ??
|
|
286
|
+
exiting.initialValues[property]);
|
|
287
|
+
const steps = [
|
|
288
|
+
value,
|
|
289
|
+
withTiming(isFiniteNumber(bridgeTo) ? bridgeTo : 0, { duration: 0 }),
|
|
290
|
+
];
|
|
291
|
+
if (enteringAnimation !== undefined) {
|
|
292
|
+
steps.push(enteringAnimation);
|
|
293
|
+
}
|
|
294
|
+
animations[property] = this.delayed(delayMs, withSequence(...steps));
|
|
295
|
+
}
|
|
296
|
+
// …then the entry, held back by the length of the exit.
|
|
297
|
+
eachTransform(entering.animations.transform, (index, key, value) => {
|
|
298
|
+
transform.push({
|
|
299
|
+
[key]: this.delayed(delayMs + exitingDuration, withSequence(withTiming(initialTransformValue(entering, index, key), {
|
|
300
|
+
duration: exitingDuration,
|
|
301
|
+
}), value)),
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
for (const [property, value] of Object.entries(entering.animations)) {
|
|
305
|
+
if (property === "transform" || animations[property] !== undefined) {
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const initial = entering.initialValues[property];
|
|
309
|
+
animations[property] = this.delayed(delayMs, withSequence(withTiming(isFiniteNumber(initial) ? initial : 0, { duration: 0 }), value));
|
|
310
|
+
}
|
|
311
|
+
const initialTransform = [
|
|
312
|
+
...(Array.isArray(exiting.initialValues.transform)
|
|
313
|
+
? exiting.initialValues.transform
|
|
314
|
+
: []),
|
|
315
|
+
...(Array.isArray(entering.animations.transform)
|
|
316
|
+
? entering.animations.transform.map((slot) => {
|
|
317
|
+
const key = Object.keys(slot)[0];
|
|
318
|
+
return key === undefined
|
|
319
|
+
? slot
|
|
320
|
+
: { [key]: neutralTransformValue(key) };
|
|
321
|
+
})
|
|
322
|
+
: []),
|
|
323
|
+
];
|
|
324
|
+
return {
|
|
325
|
+
initialValues: {
|
|
326
|
+
...exiting.initialValues,
|
|
327
|
+
originX: values.currentOriginX,
|
|
328
|
+
originY: values.currentOriginY,
|
|
329
|
+
width: values.currentWidth,
|
|
330
|
+
height: values.currentHeight,
|
|
331
|
+
transform: initialTransform,
|
|
332
|
+
},
|
|
333
|
+
animations: {
|
|
334
|
+
originX: withDelay(delayMs + exitingDuration, withTiming(values.targetOriginX, { duration: exitingDuration })),
|
|
335
|
+
originY: withDelay(delayMs + exitingDuration, withTiming(values.targetOriginY, { duration: exitingDuration })),
|
|
336
|
+
width: withDelay(delayMs + exitingDuration, withTiming(values.targetWidth, { duration: exitingDuration })),
|
|
337
|
+
height: withDelay(delayMs + exitingDuration, withTiming(values.targetHeight, { duration: exitingDuration })),
|
|
338
|
+
...animations,
|
|
339
|
+
...(transform.length > 0 ? { transform } : {}),
|
|
340
|
+
},
|
|
341
|
+
callback,
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
/** The exit and the entry run one after the other, so the lengths add. */
|
|
346
|
+
getMaxDuration() {
|
|
347
|
+
return super.getMaxDuration() + resolveBuilder(this.exitingV).getDuration();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
//# sourceMappingURL=layout-transitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout-transitions.js","sourceRoot":"","sources":["../../src/reanimated-compat/layout-transitions.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,qEAAqE;AACrE,yBAAyB;AACzB,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,uEAAuE;AACvE,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,wEAAwE;AACxE,qEAAqE;AACrE,4EAA4E;AAC5E,kEAAkE;AAClE,EAAE;AACF,gEAAgE;AAChE,6EAA6E;AAC7E,wEAAwE;AACxE,0EAA0E;AAC1E,gBAAgB;AAChB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACjE,OAAO,EACL,MAAM,GAGP,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,gBAAgB,EAChB,MAAM,EACN,OAAO,GAIR,MAAM,oBAAoB,CAAA;AAuB3B,MAAM,cAAc,GAAG,CAAC,MAA6B,EAAmB,EAAE,CACxE,MAAoC,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,OAAO,gBAAiB,SAAQ,gBAAgB;IACpD,QAAQ,GAAc,MAAM,CAAC,EAAE,CAAC,MAAM,CA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aACR,CAAA;YAED,OAAO;gBACL,aAAa,EAAE;oBACb,GAAG,OAAO,CAAC,aAAa;oBACxB,OAAO,EAAE,MAAM,CAAC,cAAc;oBAC9B,OAAO,EAAE,MAAM,CAAC,cAAc;oBAC9B,KAAK,EAAE,MAAM,CAAC,YAAY;oBAC1B,MAAM,EAAE,MAAM,CAAC,aAAa;oBAC5B,SAAS,EAAE,gBAAgB;iBAC5B;gBACD,UAAU,EAAE;oBACV,OAAO,EAAE,SAAS,CAChB,OAAO,GAAG,eAAe,EACzB,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAChE;oBACD,OAAO,EAAE,SAAS,CAChB,OAAO,GAAG,eAAe,EACzB,UAAU,CAAC,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAChE;oBACD,KAAK,EAAE,SAAS,CACd,OAAO,GAAG,eAAe,EACzB,UAAU,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAC9D;oBACD,MAAM,EAAE,SAAS,CACf,OAAO,GAAG,eAAe,EACzB,UAAU,CAAC,MAAM,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAC/D;oBACD,GAAG,UAAU;oBACb,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAC/C;gBACD,QAAQ;aACT,CAAA;QACH,CAAC,CAAA;IACH,CAAC;IAED,0EAA0E;IACjE,cAAc;QACrB,OAAO,KAAK,CAAC,cAAc,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;IAC7E,CAAC;CACF","sourcesContent":["// The `layout` transitions beyond `LinearTransition`: `CurvedTransition`,\n// `FadingTransition`, `JumpingTransition`, `SequencedTransition` and\n// `EntryExitTransition`.\n//\n// All five emit the same four properties `LinearTransition` does — `originX`,\n// `originY`, `width`, `height` — and differ only in the curve each takes to\n// get there, so they need nothing from the runtime that is not already\n// wired. The one thing they inherit with that is its documented difference:\n// the position animates (as a paint-only translation) and a size change lands\n// immediately, because a Yoga pass per frame costs what the TREE costs rather\n// than what the value costs (docs/research/animated-colors.md). Where a\n// transition's only parameter is a size curve — `CurvedTransition`'s\n// `.easingWidth()`/`.easingHeight()` — that parameter is therefore accepted\n// and ignored, and the row is in docs/api.md's differences table.\n//\n// Parameters are upstream's, from react-native-reanimated 4.5.3\n// (src/layoutReanimation/defaultTransitions/): the four default easings of a\n// curved transition, the 500 ms default of a fading and a sequenced one\n// against the 300 ms everything else uses, the out-exp/bounce pair a jump\n// arcs through.\nimport { withDelay, withSequence, withTiming } from \"./animation\"\nimport {\n Easing,\n type EasingFunction,\n type EasingFunctionFactory,\n} from \"./easing\"\nimport {\n AnimationBuilder,\n FadeIn,\n FadeOut,\n type BuiltLayoutAnimation,\n type LayoutAnimationBuilderLike,\n type LayoutAnimationValues,\n} from \"./layout-animation\"\n\ntype AnyEasing = EasingFunction | EasingFunctionFactory\n\n/**\n * A builder, or the builder CLASS itself: `.entering(FadeIn)` and\n * `.entering(FadeIn.duration(400))` are both upstream's call surface.\n */\nexport type LayoutAnimationSource =\n LayoutAnimationBuilderLike | typeof AnimationBuilder\n\n/**\n * The two methods {@link EntryExitTransition} needs off either shape. They\n * exist on both — `AnimationBuilder` declares each one twice, as an instance\n * method and as a static that makes an instance first — but the statics carry\n * a `this` constraint that no structural type can satisfy, so the split is\n * bridged here once rather than at every call.\n */\ntype ResolvedBuilder = {\n build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation\n getDuration(): number\n}\n\nconst resolveBuilder = (source: LayoutAnimationSource): ResolvedBuilder =>\n source as unknown as ResolvedBuilder\n\n/**\n * Walks a view to its new rect with a SEPARATE easing per axis, which is what\n * makes the path a curve rather than a straight line: an ease-in on x against\n * an ease-out on y bends the trajectory.\n *\n * `.easingWidth()` and `.easingHeight()` are accepted and ignored — see the\n * header, and docs/api.md.\n */\nexport class CurvedTransition extends AnimationBuilder {\n easingXV: AnyEasing = Easing.in(Easing.ease)\n easingYV: AnyEasing = Easing.out(Easing.ease)\n easingWidthV: AnyEasing = Easing.in(Easing.exp)\n easingHeightV: AnyEasing = Easing.out(Easing.exp)\n\n easingX(easing: AnyEasing): this {\n this.easingXV = easing\n return this\n }\n\n easingY(easing: AnyEasing): this {\n this.easingYV = easing\n return this\n }\n\n easingWidth(easing: AnyEasing): this {\n this.easingWidthV = easing\n return this\n }\n\n easingHeight(easing: AnyEasing): this {\n this.easingHeightV = easing\n return this\n }\n\n static easingX(easing: AnyEasing): CurvedTransition {\n return new CurvedTransition().easingX(easing)\n }\n\n static easingY(easing: AnyEasing): CurvedTransition {\n return new CurvedTransition().easingY(easing)\n }\n\n static easingWidth(easing: AnyEasing): CurvedTransition {\n return new CurvedTransition().easingWidth(easing)\n }\n\n static easingHeight(easing: AnyEasing): CurvedTransition {\n return new CurvedTransition().easingHeight(easing)\n }\n\n override build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation {\n const delayMs = this.getDelay()\n const duration = this.getDuration()\n const callback = this.callbackV\n const easingX = this.easingXV\n const easingY = this.easingYV\n const easingWidth = this.easingWidthV\n const easingHeight = this.easingHeightV\n return (values) => ({\n initialValues: {\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n },\n animations: {\n originX: this.delayed(\n delayMs,\n withTiming(values.targetOriginX, { duration, easing: easingX }),\n ),\n originY: this.delayed(\n delayMs,\n withTiming(values.targetOriginY, { duration, easing: easingY }),\n ),\n width: this.delayed(\n delayMs,\n withTiming(values.targetWidth, { duration, easing: easingWidth }),\n ),\n height: this.delayed(\n delayMs,\n withTiming(values.targetHeight, { duration, easing: easingHeight }),\n ),\n },\n callback,\n })\n }\n}\n\n/**\n * Fades the view out, moves it while it is invisible, and fades it back in —\n * the transition for a rect change too large to be worth watching. Upstream's\n * default length is 500 ms rather than the 300 ms everything else uses.\n */\nexport class FadingTransition extends AnimationBuilder {\n /** Upstream's own default for this transition, and only this one. */\n override getDuration(): number {\n return this.durationV ?? 500\n }\n\n override build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation {\n const delayMs = this.getDelay()\n const halfDuration = this.getDuration() / 2\n const callback = this.callbackV\n // The rect lands at the bottom of the fade, so it is a zero-length timing\n // held behind the first half — not a curve at all.\n const snap = (target: number): number =>\n withDelay(delayMs + halfDuration, withTiming(target, { duration: 0 }))\n return (values) => ({\n initialValues: {\n opacity: 1,\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n },\n animations: {\n opacity: this.delayed(\n delayMs,\n withSequence(\n withTiming(0, { duration: halfDuration }),\n withTiming(1, { duration: halfDuration }),\n ),\n ),\n originX: snap(values.targetOriginX),\n originY: snap(values.targetOriginY),\n width: snap(values.targetWidth),\n height: snap(values.targetHeight),\n },\n callback,\n })\n }\n}\n\n/**\n * Arcs the view to its new position: it leaps clear of both the old and the\n * new row on an ease-out-exp, then drops onto the target on a bounce. The\n * height of the leap is the distance travelled, so a short move barely hops.\n */\nexport class JumpingTransition extends AnimationBuilder {\n override build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation {\n const delayMs = this.getDelay()\n const duration = this.getDuration()\n const halfDuration = duration / 2\n const callback = this.callbackV\n return (values) => {\n const distance = Math.max(\n Math.abs(values.targetOriginX - values.currentOriginX),\n Math.abs(values.targetOriginY - values.currentOriginY),\n )\n return {\n initialValues: {\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n },\n animations: {\n originX: this.delayed(\n delayMs,\n withTiming(values.targetOriginX, { duration }),\n ),\n originY: this.delayed(\n delayMs,\n withSequence(\n withTiming(\n Math.min(values.targetOriginY, values.currentOriginY) -\n distance,\n { duration: halfDuration, easing: Easing.out(Easing.exp) },\n ),\n withTiming(values.targetOriginY, {\n duration: halfDuration,\n easing: Easing.bounce,\n }),\n ),\n ),\n width: this.delayed(\n delayMs,\n withTiming(values.targetWidth, { duration }),\n ),\n height: this.delayed(\n delayMs,\n withTiming(values.targetHeight, { duration }),\n ),\n },\n callback,\n }\n }\n }\n}\n\n/**\n * Moves one axis at a time: x first and then y, or the reverse with\n * `.reverse()`. Upstream's default length is 500 ms, split evenly.\n */\nexport class SequencedTransition extends AnimationBuilder {\n reversed = false\n\n reverse(): this {\n this.reversed = !this.reversed\n return this\n }\n\n static reverse(): SequencedTransition {\n return new SequencedTransition().reverse()\n }\n\n /** Upstream's own default for this transition. */\n override getDuration(): number {\n return this.durationV ?? 500\n }\n\n override build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation {\n const delayMs = this.getDelay()\n const config = { duration: this.getDuration() / 2 }\n const callback = this.callbackV\n const reverse = this.reversed\n // Each property runs two halves; the one that moves in the FIRST half is\n // the one whose intermediate target is already the destination.\n const twoStep = (first: number, target: number): number =>\n this.delayed(\n delayMs,\n withSequence(withTiming(first, config), withTiming(target, config)),\n )\n return (values) => ({\n initialValues: {\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n },\n animations: {\n originX: twoStep(\n reverse ? values.currentOriginX : values.targetOriginX,\n values.targetOriginX,\n ),\n originY: twoStep(\n reverse ? values.targetOriginY : values.currentOriginY,\n values.targetOriginY,\n ),\n width: twoStep(\n reverse ? values.currentWidth : values.targetWidth,\n values.targetWidth,\n ),\n height: twoStep(\n reverse ? values.targetHeight : values.currentHeight,\n values.targetHeight,\n ),\n },\n callback,\n })\n }\n}\n\n// The value a transform slot returns to between an exit and an entry, decided\n// from the KEY. Upstream reads it off the animation object's `current`, which\n// is a field of ITS animation representation; the descriptors here are plain\n// data with no running value, and the key answers the same question — a\n// translate rests at 0, a scale at 1, an angle at 0.\nconst neutralTransformValue = (key: string): number =>\n key.startsWith(\"scale\") ? 1 : 0\n\nconst isFiniteNumber = (value: unknown): value is number =>\n typeof value === \"number\" && Number.isFinite(value)\n\n/**\n * Plays a full exit animation and then a full entry animation on the SAME\n * view when its layout changes — the transition for a view whose content\n * changed so much that moving it would read as the wrong thing moving.\n *\n * `.entering()` and `.exiting()` take any builder (or builder class); the\n * defaults are `FadeIn` and `FadeOut`. The two built configs are composed\n * here rather than run one after the other, so the whole thing is still one\n * animation with one callback.\n */\nexport class EntryExitTransition extends AnimationBuilder {\n enteringV: LayoutAnimationSource = FadeIn\n exitingV: LayoutAnimationSource = FadeOut\n\n entering(animation: LayoutAnimationSource): this {\n this.enteringV = animation\n return this\n }\n\n exiting(animation: LayoutAnimationSource): this {\n this.exitingV = animation\n return this\n }\n\n static entering(animation: LayoutAnimationSource): EntryExitTransition {\n return new EntryExitTransition().entering(animation)\n }\n\n static exiting(animation: LayoutAnimationSource): EntryExitTransition {\n return new EntryExitTransition().exiting(animation)\n }\n\n override build(): (values: LayoutAnimationValues) => BuiltLayoutAnimation {\n const delayMs = this.getDelay()\n const callback = this.callbackV\n const enteringBuild = resolveBuilder(this.enteringV).build()\n const exitingBuild = resolveBuilder(this.exitingV).build()\n const exitingDuration = resolveBuilder(this.exitingV).getDuration()\n\n return (values) => {\n const entering = enteringBuild(values)\n const exiting = exitingBuild(values)\n const animations: Record<string, unknown> = {}\n const transform: Record<string, unknown>[] = []\n\n const eachTransform = (\n source: unknown,\n visit: (index: number, key: string, value: unknown) => void,\n ): void => {\n if (!Array.isArray(source)) {\n return\n }\n source.forEach((entry, index) => {\n if (typeof entry === \"object\" && entry !== null) {\n for (const [key, value] of Object.entries(entry)) {\n visit(index, key, value)\n }\n }\n })\n }\n\n const initialTransformValue = (\n config: BuiltLayoutAnimation,\n index: number,\n key: string,\n ): number => {\n const slots = config.initialValues.transform\n const slot = Array.isArray(slots)\n ? (slots[index] as Record<string, unknown> | undefined)\n : undefined\n const value = slot?.[key]\n return isFiniteNumber(value) ? value : 0\n }\n\n // The exit runs first, and every property it touched is snapped back to\n // where the ENTRY wants to begin before the entry plays.\n eachTransform(exiting.animations.transform, (index, key, value) => {\n transform.push({\n [key]: this.delayed(\n delayMs,\n withSequence(\n value as number,\n withTiming(initialTransformValue(exiting, index, key), {\n duration: 0,\n }),\n ),\n ),\n })\n })\n for (const [property, value] of Object.entries(exiting.animations)) {\n if (property === \"transform\") {\n continue\n }\n const enteringAnimation = entering.animations[property]\n const bridgeTo =\n enteringAnimation !== undefined\n ? entering.initialValues[property]\n : (values[property as keyof LayoutAnimationValues] ??\n exiting.initialValues[property])\n const steps: unknown[] = [\n value,\n withTiming(isFiniteNumber(bridgeTo) ? bridgeTo : 0, { duration: 0 }),\n ]\n if (enteringAnimation !== undefined) {\n steps.push(enteringAnimation)\n }\n animations[property] = this.delayed(\n delayMs,\n withSequence(...(steps as number[])),\n )\n }\n\n // …then the entry, held back by the length of the exit.\n eachTransform(entering.animations.transform, (index, key, value) => {\n transform.push({\n [key]: this.delayed(\n delayMs + exitingDuration,\n withSequence(\n withTiming(initialTransformValue(entering, index, key), {\n duration: exitingDuration,\n }),\n value as number,\n ),\n ),\n })\n })\n for (const [property, value] of Object.entries(entering.animations)) {\n if (property === \"transform\" || animations[property] !== undefined) {\n continue\n }\n const initial = entering.initialValues[property]\n animations[property] = this.delayed(\n delayMs,\n withSequence(\n withTiming(isFiniteNumber(initial) ? initial : 0, { duration: 0 }),\n value as number,\n ),\n )\n }\n\n const initialTransform = [\n ...(Array.isArray(exiting.initialValues.transform)\n ? (exiting.initialValues.transform as Record<string, unknown>[])\n : []),\n ...(Array.isArray(entering.animations.transform)\n ? (entering.animations.transform as Record<string, unknown>[]).map(\n (slot) => {\n const key = Object.keys(slot)[0]\n return key === undefined\n ? slot\n : { [key]: neutralTransformValue(key) }\n },\n )\n : []),\n ]\n\n return {\n initialValues: {\n ...exiting.initialValues,\n originX: values.currentOriginX,\n originY: values.currentOriginY,\n width: values.currentWidth,\n height: values.currentHeight,\n transform: initialTransform,\n },\n animations: {\n originX: withDelay(\n delayMs + exitingDuration,\n withTiming(values.targetOriginX, { duration: exitingDuration }),\n ),\n originY: withDelay(\n delayMs + exitingDuration,\n withTiming(values.targetOriginY, { duration: exitingDuration }),\n ),\n width: withDelay(\n delayMs + exitingDuration,\n withTiming(values.targetWidth, { duration: exitingDuration }),\n ),\n height: withDelay(\n delayMs + exitingDuration,\n withTiming(values.targetHeight, { duration: exitingDuration }),\n ),\n ...animations,\n ...(transform.length > 0 ? { transform } : {}),\n },\n callback,\n }\n }\n }\n\n /** The exit and the entry run one after the other, so the lengths add. */\n override getMaxDuration(): number {\n return super.getMaxDuration() + resolveBuilder(this.exitingV).getDuration()\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AnimatedApi, FrameScheduler } from "../animated/index";
|
|
2
|
+
import { type Trackable } from "./tracking";
|
|
3
|
+
/** The platform's animated-node listener shape. */
|
|
4
|
+
export type NodeListener<T> = (state: {
|
|
5
|
+
value: T;
|
|
6
|
+
}) => void;
|
|
7
|
+
/** Upstream's shared-value listener shape. */
|
|
8
|
+
export type ValueListener<T> = (value: T) => void;
|
|
9
|
+
export type SharedValue<T = unknown> = Trackable & {
|
|
10
|
+
value: T;
|
|
11
|
+
get(): T;
|
|
12
|
+
set(next: T | ((current: T) => T)): void;
|
|
13
|
+
modify(modifier?: (current: T) => T, forceUpdate?: boolean): void;
|
|
14
|
+
addListener(listener: NodeListener<T>): string;
|
|
15
|
+
addListener(listenerID: number | string, listener: ValueListener<T>): string;
|
|
16
|
+
removeListener(listenerID: number | string): void;
|
|
17
|
+
/** @internal The platform's animated-node read. Never registers a mapper. */
|
|
18
|
+
__getValue(): T;
|
|
19
|
+
/** @internal Stops a running animation, leaving the value where it is. */
|
|
20
|
+
__cancelAnimation(): void;
|
|
21
|
+
/** Upstream's brand, which `isSharedValue` and consumer libraries check. */
|
|
22
|
+
_isReanimatedSharedValue: true;
|
|
23
|
+
};
|
|
24
|
+
/** A shared value a `useDerivedValue` owns: readable, not writable. */
|
|
25
|
+
export type DerivedValue<T = unknown> = Readonly<SharedValue<T>>;
|
|
26
|
+
export declare const createMakeMutable: (api: AnimatedApi, scheduler: FrameScheduler) => <T>(initial: T) => SharedValue<T>;
|
|
27
|
+
export declare const isSharedValue: <T = unknown>(value: unknown) => value is SharedValue<T>;
|
|
28
|
+
/** Stops the animation running on a shared value, leaving it where it is. */
|
|
29
|
+
export declare const cancelAnimation: (sharedValue: unknown) => void;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { buildAnimation, isAnimationSpec, } from "./animation";
|
|
2
|
+
import { trackRead } from "./tracking";
|
|
3
|
+
export const createMakeMutable = (api, scheduler) => {
|
|
4
|
+
// Both halves of the one clock: the api for the animations the platform
|
|
5
|
+
// already implements, the scheduler for `withDecay`, whose per-frame step is
|
|
6
|
+
// Reanimated's own rather than RN's. See animation.ts.
|
|
7
|
+
const engine = { api, scheduler };
|
|
8
|
+
const makeMutable = (initial) => {
|
|
9
|
+
let current = initial;
|
|
10
|
+
const mappers = new Set();
|
|
11
|
+
const listeners = new Map();
|
|
12
|
+
let nextNodeListenerId = 1;
|
|
13
|
+
let running = null;
|
|
14
|
+
const notify = () => {
|
|
15
|
+
// Copied before iterating: a listener or a mapper may subscribe or
|
|
16
|
+
// unsubscribe while the write is being published.
|
|
17
|
+
for (const listener of [...listeners.values()]) {
|
|
18
|
+
listener(current);
|
|
19
|
+
}
|
|
20
|
+
for (const mapper of [...mappers]) {
|
|
21
|
+
mapper.run();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const commit = (next) => {
|
|
25
|
+
if (Object.is(next, current)) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
current = next;
|
|
29
|
+
notify();
|
|
30
|
+
};
|
|
31
|
+
const stopAnimation = () => {
|
|
32
|
+
const animation = running;
|
|
33
|
+
running = null;
|
|
34
|
+
animation?.stop();
|
|
35
|
+
};
|
|
36
|
+
const startAnimation = (spec) => {
|
|
37
|
+
stopAnimation();
|
|
38
|
+
if (typeof current !== "number") {
|
|
39
|
+
throw new Error("react-native-reanimated: an animation can only be assigned to a shared value holding a number " +
|
|
40
|
+
`(this one holds ${typeof current}). Colors and layout values cannot be animated on this platform yet — see docs/api.md.`);
|
|
41
|
+
}
|
|
42
|
+
// A fresh driver per run, constructed at the current value: restarting
|
|
43
|
+
// an animation must pick up from wherever the value is now, and the
|
|
44
|
+
// platform's engine derives its start value from the node it drives.
|
|
45
|
+
const driver = new api.Value(current);
|
|
46
|
+
const driverListener = driver.addListener(({ value }) => {
|
|
47
|
+
commit(value);
|
|
48
|
+
});
|
|
49
|
+
const animation = buildAnimation(engine, driver, spec);
|
|
50
|
+
const handle = { stop: () => animation.stop() };
|
|
51
|
+
running = handle;
|
|
52
|
+
animation.start(() => {
|
|
53
|
+
driver.removeListener(driverListener);
|
|
54
|
+
if (running === handle) {
|
|
55
|
+
running = null;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const write = (next) => {
|
|
60
|
+
if (isAnimationSpec(next)) {
|
|
61
|
+
startAnimation(next);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
// A plain write cancels whatever was running, exactly as upstream's
|
|
65
|
+
// valueSetter does — assigning a value is how you stop an animation.
|
|
66
|
+
stopAnimation();
|
|
67
|
+
commit(next);
|
|
68
|
+
};
|
|
69
|
+
const shared = {
|
|
70
|
+
_isReanimatedSharedValue: true,
|
|
71
|
+
get value() {
|
|
72
|
+
trackRead(shared);
|
|
73
|
+
return current;
|
|
74
|
+
},
|
|
75
|
+
set value(next) {
|
|
76
|
+
write(next);
|
|
77
|
+
},
|
|
78
|
+
get() {
|
|
79
|
+
trackRead(shared);
|
|
80
|
+
return current;
|
|
81
|
+
},
|
|
82
|
+
set(next) {
|
|
83
|
+
write(typeof next === "function"
|
|
84
|
+
? next(current)
|
|
85
|
+
: next);
|
|
86
|
+
},
|
|
87
|
+
modify(modifier, forceUpdate = true) {
|
|
88
|
+
const next = modifier ? modifier(current) : current;
|
|
89
|
+
if (!forceUpdate) {
|
|
90
|
+
commit(next);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// forceUpdate republishes even when the modifier mutated the value in
|
|
94
|
+
// place and `Object.is` therefore still holds — the case the method
|
|
95
|
+
// exists for.
|
|
96
|
+
current = next;
|
|
97
|
+
notify();
|
|
98
|
+
},
|
|
99
|
+
addListener(first, second) {
|
|
100
|
+
if (typeof first === "function") {
|
|
101
|
+
const id = `#${nextNodeListenerId++}`;
|
|
102
|
+
listeners.set(id, (value) => first({ value }));
|
|
103
|
+
return id;
|
|
104
|
+
}
|
|
105
|
+
const id = String(first);
|
|
106
|
+
if (second) {
|
|
107
|
+
listeners.set(id, second);
|
|
108
|
+
}
|
|
109
|
+
return id;
|
|
110
|
+
},
|
|
111
|
+
removeListener(listenerID) {
|
|
112
|
+
listeners.delete(String(listenerID));
|
|
113
|
+
},
|
|
114
|
+
__getValue() {
|
|
115
|
+
return current;
|
|
116
|
+
},
|
|
117
|
+
__addMapper(mapper) {
|
|
118
|
+
mappers.add(mapper);
|
|
119
|
+
},
|
|
120
|
+
__removeMapper(mapper) {
|
|
121
|
+
mappers.delete(mapper);
|
|
122
|
+
},
|
|
123
|
+
__cancelAnimation() {
|
|
124
|
+
stopAnimation();
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
return shared;
|
|
128
|
+
};
|
|
129
|
+
return makeMutable;
|
|
130
|
+
};
|
|
131
|
+
export const isSharedValue = (value) => value
|
|
132
|
+
?._isReanimatedSharedValue === true;
|
|
133
|
+
/** Stops the animation running on a shared value, leaving it where it is. */
|
|
134
|
+
export const cancelAnimation = (sharedValue) => {
|
|
135
|
+
if (isSharedValue(sharedValue)) {
|
|
136
|
+
sharedValue.__cancelAnimation();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=mutable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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,MAAM,EAAE,CAAC;oBACX,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,CAAA;gBAC3B,CAAC;gBACD,OAAO,EAAE,CAAA;YACX,CAAC;YAED,cAAc,CAAC,UAAU;gBACvB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;YACtC,CAAC;YAED,UAAU;gBACR,OAAO,OAAO,CAAA;YAChB,CAAC;YAED,WAAW,CAAC,MAAM;gBAChB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACrB,CAAC;YAED,cAAc,CAAC,MAAM;gBACnB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACxB,CAAC;YAED,iBAAiB;gBACf,aAAa,EAAE,CAAA;YACjB,CAAC;SACF,CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAED,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAc,EACW,EAAE,CAC1B,KAAoD;IACnD,EAAE,wBAAwB,KAAK,IAAI,CAAA;AAEvC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAoB,EAAQ,EAAE;IAC5D,IAAI,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,WAAW,CAAC,iBAAiB,EAAE,CAAA;IACjC,CAAC;AACH,CAAC,CAAA","sourcesContent":["// The shared value: an observable box, and the single place where the\n// worklet architecture actually collapses into something.\n//\n// On mobile a SharedValue is a bridge between two runtimes, with guest/host\n// decorators and a serializer behind `.value`. Here it is a closure over a\n// number with two kinds of subscriber — mappers (re-run on write) and\n// listeners (notified on write) — because GTK's main loop IS the JS thread,\n// so a write is a synchronous function call that walks its subscribers.\n//\n// The one deliberate shape decision, and it is load-bearing:\n// `addListener`/`removeListener` accept BOTH calling conventions.\n//\n// - Upstream's is `addListener(listenerID, listener)` with the listener\n// called with the raw value. Library code written against Reanimated\n// uses that one.\n// - This platform's animated nodes use `addListener(callback) => id` with\n// `{ value }`, and `src/components/animated.tsx` recognises an animated\n// node STRUCTURALLY (`addListener` + `__getValue`). Supporting it is what\n// makes a shared value drivable by the existing `Animated.View` with no\n// change to the view layer — the load-bearing discovery behind this whole\n// epic (docs/research/reanimated.md).\n//\n// Implementing only one of the two would not fail loudly; it would fail\n// silently, which this repo treats as the worst outcome. The convention is\n// picked from what actually arrived, and the two id spaces are kept apart so\n// a caller-chosen numeric id cannot collide with a generated one.\nimport type {\n AnimatedApi,\n AnimatedValue,\n FrameScheduler,\n} from \"../animated/index\"\nimport {\n buildAnimation,\n isAnimationSpec,\n type AnimationEngine,\n type AnimationSpec,\n} from \"./animation\"\nimport { trackRead, type Mapper, type Trackable } from \"./tracking\"\n\n/** The platform's animated-node listener shape. */\nexport type NodeListener<T> = (state: { value: T }) => void\n\n/** Upstream's shared-value listener shape. */\nexport type ValueListener<T> = (value: T) => void\n\nexport type SharedValue<T = unknown> = Trackable & {\n value: T\n get(): T\n set(next: T | ((current: T) => T)): void\n modify(modifier?: (current: T) => T, forceUpdate?: boolean): void\n addListener(listener: NodeListener<T>): string\n addListener(listenerID: number | string, listener: ValueListener<T>): string\n removeListener(listenerID: number | string): void\n /** @internal The platform's animated-node read. Never registers a mapper. */\n __getValue(): T\n /** @internal Stops a running animation, leaving the value where it is. */\n __cancelAnimation(): void\n /** Upstream's brand, which `isSharedValue` and consumer libraries check. */\n _isReanimatedSharedValue: true\n}\n\n/** A shared value a `useDerivedValue` owns: readable, not writable. */\nexport type DerivedValue<T = unknown> = Readonly<SharedValue<T>>\n\ntype RunningAnimation = { stop(): void }\n\nexport const createMakeMutable = (\n api: AnimatedApi,\n scheduler: FrameScheduler,\n) => {\n // Both halves of the one clock: the api for the animations the platform\n // already implements, the scheduler for `withDecay`, whose per-frame step is\n // Reanimated's own rather than RN's. See animation.ts.\n const engine: AnimationEngine = { api, scheduler }\n\n const makeMutable = <T>(initial: T): SharedValue<T> => {\n let current = initial\n const mappers = new Set<Mapper>()\n const listeners = new Map<string, ValueListener<T>>()\n let nextNodeListenerId = 1\n let running: RunningAnimation | null = null\n\n const notify = (): void => {\n // Copied before iterating: a listener or a mapper may subscribe or\n // unsubscribe while the write is being published.\n for (const listener of [...listeners.values()]) {\n listener(current)\n }\n for (const mapper of [...mappers]) {\n mapper.run()\n }\n }\n\n const commit = (next: T): void => {\n if (Object.is(next, current)) {\n return\n }\n current = next\n notify()\n }\n\n const stopAnimation = (): void => {\n const animation = running\n running = null\n animation?.stop()\n }\n\n const startAnimation = (spec: AnimationSpec): void => {\n stopAnimation()\n if (typeof current !== \"number\") {\n throw new Error(\n \"react-native-reanimated: an animation can only be assigned to a shared value holding a number \" +\n `(this one holds ${typeof current}). Colors and layout values cannot be animated on this platform yet — see docs/api.md.`,\n )\n }\n // A fresh driver per run, constructed at the current value: restarting\n // an animation must pick up from wherever the value is now, and the\n // platform's engine derives its start value from the node it drives.\n const driver: AnimatedValue = new api.Value(current)\n const driverListener = driver.addListener(({ value }) => {\n commit(value as T)\n })\n const animation = buildAnimation(engine, driver, spec)\n const handle: RunningAnimation = { stop: () => animation.stop() }\n running = handle\n animation.start(() => {\n driver.removeListener(driverListener)\n if (running === handle) {\n running = null\n }\n })\n }\n\n const write = (next: T): void => {\n if (isAnimationSpec(next)) {\n startAnimation(next)\n return\n }\n // A plain write cancels whatever was running, exactly as upstream's\n // valueSetter does — assigning a value is how you stop an animation.\n stopAnimation()\n commit(next)\n }\n\n const shared: SharedValue<T> = {\n _isReanimatedSharedValue: true,\n\n get value() {\n trackRead(shared)\n return current\n },\n set value(next: T) {\n write(next)\n },\n\n get() {\n trackRead(shared)\n return current\n },\n set(next) {\n write(\n typeof next === \"function\"\n ? (next as (currentValue: T) => T)(current)\n : next,\n )\n },\n\n modify(modifier, forceUpdate = true) {\n const next = modifier ? modifier(current) : current\n if (!forceUpdate) {\n commit(next)\n return\n }\n // forceUpdate republishes even when the modifier mutated the value in\n // place and `Object.is` therefore still holds — the case the method\n // exists for.\n current = next\n notify()\n },\n\n addListener(\n first: NodeListener<T> | number | string,\n second?: ValueListener<T>,\n ): string {\n if (typeof first === \"function\") {\n const id = `#${nextNodeListenerId++}`\n listeners.set(id, (value) => first({ value }))\n return id\n }\n const id = String(first)\n if (second) {\n listeners.set(id, second)\n }\n return id\n },\n\n removeListener(listenerID) {\n listeners.delete(String(listenerID))\n },\n\n __getValue() {\n return current\n },\n\n __addMapper(mapper) {\n mappers.add(mapper)\n },\n\n __removeMapper(mapper) {\n mappers.delete(mapper)\n },\n\n __cancelAnimation() {\n stopAnimation()\n },\n }\n\n return shared\n }\n\n return makeMutable\n}\n\nexport const isSharedValue = <T = unknown>(\n value: unknown,\n): value is SharedValue<T> =>\n (value as Record<string, unknown> | null | undefined)\n ?._isReanimatedSharedValue === true\n\n/** Stops the animation running on a shared value, leaving it where it is. */\nexport const cancelAnimation = (sharedValue: unknown): void => {\n if (isSharedValue(sharedValue)) {\n sharedValue.__cancelAnimation()\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type StyleNode } from "./style";
|
|
2
|
+
export type PropsObject = Record<string, unknown>;
|
|
3
|
+
/** @internal Test seam: the warning is once per session by design. */
|
|
4
|
+
export declare const resetUndriveablePropWarnings: () => void;
|
|
5
|
+
export type AnimatedPropsObject = {
|
|
6
|
+
/** Stable object spread onto the component; never replaced in place. */
|
|
7
|
+
readonly props: PropsObject;
|
|
8
|
+
/** The nodes behind it, reusable when the props have to be rebuilt. */
|
|
9
|
+
readonly nodes: ReadonlyMap<string, StyleNode>;
|
|
10
|
+
/**
|
|
11
|
+
* Publishes a fresh updater result. Returns false when the SHAPE changed
|
|
12
|
+
* (a prop became numeric, stopped being numeric, or appeared) and the
|
|
13
|
+
* caller must rebuild — the nodes the component subscribed to no longer
|
|
14
|
+
* describe these props.
|
|
15
|
+
*/
|
|
16
|
+
apply(next: PropsObject): boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const createAnimatedProps: (source: PropsObject, reuse?: ReadonlyMap<string, StyleNode>) => AnimatedPropsObject;
|