react-native-laminar 1.2.0 → 1.4.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 +9 -2
- package/lib/commonjs/hooks/use-display-units.js +1 -0
- package/lib/commonjs/hooks/use-display-units.js.map +1 -1
- package/lib/commonjs/hooks/use-inline-auto-width.js +43 -10
- package/lib/commonjs/hooks/use-inline-auto-width.js.map +1 -1
- package/lib/commonjs/hooks/use-morph-motion.js +2 -1
- package/lib/commonjs/hooks/use-morph-motion.js.map +1 -1
- package/lib/commonjs/hooks/use-morph-text-style.js +4 -0
- package/lib/commonjs/hooks/use-morph-text-style.js.map +1 -1
- package/lib/commonjs/hooks/use-numeric-lanes.js +1 -0
- package/lib/commonjs/hooks/use-numeric-lanes.js.map +1 -1
- package/lib/commonjs/hooks/use-text-glyphs.js +28 -7
- package/lib/commonjs/hooks/use-text-glyphs.js.map +1 -1
- package/lib/commonjs/index.js +54 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/model/display-units.js +7 -1
- package/lib/commonjs/model/display-units.js.map +1 -1
- package/lib/commonjs/model/numeric-lanes.js +4 -0
- package/lib/commonjs/model/numeric-lanes.js.map +1 -1
- package/lib/commonjs/model/text-keys.js +4 -0
- package/lib/commonjs/model/text-keys.js.map +1 -1
- package/lib/commonjs/motion/entry-exit-builders.js +78 -1
- package/lib/commonjs/motion/entry-exit-builders.js.map +1 -1
- package/lib/commonjs/motion/preset-map.js +7 -0
- package/lib/commonjs/motion/preset-map.js.map +1 -1
- package/lib/commonjs/view/glyph-run.js +21 -2
- package/lib/commonjs/view/glyph-run.js.map +1 -1
- package/lib/commonjs/view/morph-viewport.js +4 -0
- package/lib/commonjs/view/morph-viewport.js.map +1 -1
- package/lib/commonjs/view/number-lane.js +5 -1
- package/lib/commonjs/view/number-lane.js.map +1 -1
- package/lib/commonjs/view/number-run.js +4 -0
- package/lib/commonjs/view/number-run.js.map +1 -1
- package/lib/commonjs/view/slots-run.js +258 -0
- package/lib/commonjs/view/slots-run.js.map +1 -0
- package/lib/commonjs/view/text-run.js +35 -3
- package/lib/commonjs/view/text-run.js.map +1 -1
- package/lib/module/hooks/use-display-units.js +2 -0
- package/lib/module/hooks/use-display-units.js.map +1 -1
- package/lib/module/hooks/use-inline-auto-width.js +44 -11
- package/lib/module/hooks/use-inline-auto-width.js.map +1 -1
- package/lib/module/hooks/use-morph-motion.js +2 -1
- package/lib/module/hooks/use-morph-motion.js.map +1 -1
- package/lib/module/hooks/use-morph-text-style.js +4 -0
- package/lib/module/hooks/use-morph-text-style.js.map +1 -1
- package/lib/module/hooks/use-numeric-lanes.js +1 -0
- package/lib/module/hooks/use-numeric-lanes.js.map +1 -1
- package/lib/module/hooks/use-text-glyphs.js +28 -7
- package/lib/module/hooks/use-text-glyphs.js.map +1 -1
- package/lib/module/index.js +56 -12
- package/lib/module/index.js.map +1 -1
- package/lib/module/model/display-units.js +7 -1
- package/lib/module/model/display-units.js.map +1 -1
- package/lib/module/model/numeric-lanes.js +5 -0
- package/lib/module/model/numeric-lanes.js.map +1 -1
- package/lib/module/model/text-keys.js +4 -0
- package/lib/module/model/text-keys.js.map +1 -1
- package/lib/module/motion/entry-exit-builders.js +75 -0
- package/lib/module/motion/entry-exit-builders.js.map +1 -1
- package/lib/module/motion/preset-map.js +7 -0
- package/lib/module/motion/preset-map.js.map +1 -1
- package/lib/module/view/glyph-run.js +21 -2
- package/lib/module/view/glyph-run.js.map +1 -1
- package/lib/module/view/morph-viewport.js +4 -0
- package/lib/module/view/morph-viewport.js.map +1 -1
- package/lib/module/view/number-lane.js +5 -1
- package/lib/module/view/number-lane.js.map +1 -1
- package/lib/module/view/number-run.js +4 -0
- package/lib/module/view/number-run.js.map +1 -1
- package/lib/module/view/slots-run.js +253 -0
- package/lib/module/view/slots-run.js.map +1 -0
- package/lib/module/view/text-run.js +36 -4
- package/lib/module/view/text-run.js.map +1 -1
- package/lib/typescript/commonjs/hooks/use-display-units.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts +3 -1
- package/lib/typescript/commonjs/hooks/use-inline-auto-width.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-morph-motion.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-morph-text-style.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts +2 -1
- package/lib/typescript/commonjs/hooks/use-text-glyphs.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -3
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/model/display-units.d.ts.map +1 -1
- package/lib/typescript/commonjs/model/numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/commonjs/model/text-keys.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts +13 -0
- package/lib/typescript/commonjs/motion/entry-exit-builders.d.ts.map +1 -1
- package/lib/typescript/commonjs/motion/preset-map.d.ts.map +1 -1
- package/lib/typescript/commonjs/types.d.ts +12 -2
- package/lib/typescript/commonjs/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/glyph-run.d.ts +5 -2
- package/lib/typescript/commonjs/view/glyph-run.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/morph-viewport.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/number-lane.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/number-run.d.ts.map +1 -1
- package/lib/typescript/commonjs/view/slots-run.d.ts +15 -0
- package/lib/typescript/commonjs/view/slots-run.d.ts.map +1 -0
- package/lib/typescript/commonjs/view/text-run.d.ts +5 -1
- package/lib/typescript/commonjs/view/text-run.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-display-units.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts +3 -1
- package/lib/typescript/module/hooks/use-inline-auto-width.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-morph-motion.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-morph-text-style.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts +2 -1
- package/lib/typescript/module/hooks/use-text-glyphs.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -3
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/model/display-units.d.ts.map +1 -1
- package/lib/typescript/module/model/numeric-lanes.d.ts.map +1 -1
- package/lib/typescript/module/model/text-keys.d.ts.map +1 -1
- package/lib/typescript/module/motion/entry-exit-builders.d.ts +13 -0
- package/lib/typescript/module/motion/entry-exit-builders.d.ts.map +1 -1
- package/lib/typescript/module/motion/preset-map.d.ts.map +1 -1
- package/lib/typescript/module/types.d.ts +12 -2
- package/lib/typescript/module/types.d.ts.map +1 -1
- package/lib/typescript/module/view/glyph-run.d.ts +5 -2
- package/lib/typescript/module/view/glyph-run.d.ts.map +1 -1
- package/lib/typescript/module/view/morph-viewport.d.ts.map +1 -1
- package/lib/typescript/module/view/number-lane.d.ts.map +1 -1
- package/lib/typescript/module/view/number-run.d.ts.map +1 -1
- package/lib/typescript/module/view/slots-run.d.ts +15 -0
- package/lib/typescript/module/view/slots-run.d.ts.map +1 -0
- package/lib/typescript/module/view/text-run.d.ts +5 -1
- package/lib/typescript/module/view/text-run.d.ts.map +1 -1
- package/package.json +11 -2
- package/src/hooks/use-display-units.ts +1 -0
- package/src/hooks/use-inline-auto-width.ts +55 -12
- package/src/hooks/use-morph-motion.ts +2 -1
- package/src/hooks/use-morph-text-style.ts +3 -0
- package/src/hooks/use-numeric-lanes.ts +1 -0
- package/src/hooks/use-text-glyphs.ts +48 -10
- package/src/index.tsx +98 -17
- package/src/model/display-units.ts +4 -1
- package/src/model/numeric-lanes.ts +3 -0
- package/src/model/text-keys.ts +3 -0
- package/src/motion/entry-exit-builders.ts +73 -0
- package/src/motion/preset-map.ts +4 -0
- package/src/types.ts +14 -2
- package/src/view/glyph-run.tsx +38 -13
- package/src/view/morph-viewport.tsx +3 -0
- package/src/view/number-lane.tsx +7 -2
- package/src/view/number-run.tsx +3 -0
- package/src/view/slots-run.tsx +385 -0
- package/src/view/text-run.tsx +77 -6
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
// find the longest ordered set of shared units so edits keep nearby glyph identity
|
|
3
4
|
const computeLcsPairs = (previousUnits, nextUnits) => {
|
|
4
5
|
const previousLength = previousUnits.length;
|
|
5
6
|
const nextLength = nextUnits.length;
|
|
6
7
|
if (previousLength === 0 || nextLength === 0) {
|
|
7
8
|
return [];
|
|
8
9
|
}
|
|
10
|
+
|
|
11
|
+
// dynamic programming makes the middle edit deterministic when prefix and suffix match
|
|
9
12
|
const dp = Array.from({
|
|
10
13
|
length: previousLength + 1
|
|
11
14
|
}, () => new Array(nextLength + 1).fill(0));
|
|
@@ -33,6 +36,7 @@ const computeLcsPairs = (previousUnits, nextUnits) => {
|
|
|
33
36
|
pairs.reverse();
|
|
34
37
|
return pairs;
|
|
35
38
|
};
|
|
39
|
+
// reuse prefix, suffix, and lcs matches before allocating keys for new glyphs
|
|
36
40
|
export const reconcileTextGlyphKeys = (previousUnits, nextUnits, previousKeys, seed, namespace) => {
|
|
37
41
|
const previousLength = previousUnits.length;
|
|
38
42
|
const nextLength = nextUnits.length;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["computeLcsPairs","previousUnits","nextUnits","previousLength","length","nextLength","dp","Array","from","fill","previousIndex","nextIndex","Math","max","pairs","push","reverse","reconcileTextGlyphKeys","previousKeys","seed","namespace","nextGlyphKeys","nextSeed","sharedPrefixLength","sharedSuffixLength","previousMiddleEnd","nextMiddleEnd","previousMiddleUnits","slice","nextMiddleUnits","matches","absolutePreviousIndex","absoluteNextIndex","glyphKeys"],"sourceRoot":"../../../src","sources":["model/text-keys.ts"],"mappings":";;AAAA,MAAMA,eAAe,GAAGA,CACtBC,aAAgC,EAChCC,SAA4B,KACI;EAChC,MAAMC,cAAc,GAAGF,aAAa,CAACG,MAAM;EAC3C,MAAMC,UAAU,GAAGH,SAAS,CAACE,MAAM;EAEnC,IAAID,cAAc,KAAK,CAAC,IAAIE,UAAU,KAAK,CAAC,EAAE;IAC5C,OAAO,EAAE;EACX;
|
|
1
|
+
{"version":3,"names":["computeLcsPairs","previousUnits","nextUnits","previousLength","length","nextLength","dp","Array","from","fill","previousIndex","nextIndex","Math","max","pairs","push","reverse","reconcileTextGlyphKeys","previousKeys","seed","namespace","nextGlyphKeys","nextSeed","sharedPrefixLength","sharedSuffixLength","previousMiddleEnd","nextMiddleEnd","previousMiddleUnits","slice","nextMiddleUnits","matches","absolutePreviousIndex","absoluteNextIndex","glyphKeys"],"sourceRoot":"../../../src","sources":["model/text-keys.ts"],"mappings":";;AAAA;AACA,MAAMA,eAAe,GAAGA,CACtBC,aAAgC,EAChCC,SAA4B,KACI;EAChC,MAAMC,cAAc,GAAGF,aAAa,CAACG,MAAM;EAC3C,MAAMC,UAAU,GAAGH,SAAS,CAACE,MAAM;EAEnC,IAAID,cAAc,KAAK,CAAC,IAAIE,UAAU,KAAK,CAAC,EAAE;IAC5C,OAAO,EAAE;EACX;;EAEA;EACA,MAAMC,EAAE,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEJ,MAAM,EAAED,cAAc,GAAG;EAAE,CAAC,EAAE,MACpD,IAAII,KAAK,CAASF,UAAU,GAAG,CAAC,CAAC,CAACI,IAAI,CAAC,CAAC,CAC1C,CAAC;EAED,KAAK,IAAIC,aAAa,GAAG,CAAC,EAAEA,aAAa,IAAIP,cAAc,EAAEO,aAAa,IAAI,CAAC,EAAE;IAC/E,KAAK,IAAIC,SAAS,GAAG,CAAC,EAAEA,SAAS,IAAIN,UAAU,EAAEM,SAAS,IAAI,CAAC,EAAE;MAC/DL,EAAE,CAACI,aAAa,CAAC,CAACC,SAAS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,UAAU,GAAGmB,kBAAkB;EACrD,MAAMG,mBAAmB,GAAG1B,aAAa,CAAC2B,KAAK,CAC7CL,kBAAkB,EAClBE,iBACF,CAAC;EACD,MAAMI,eAAe,GAAG3B,SAAS,CAAC0B,KAAK,CAACL,kBAAkB,EAAEG,aAAa,CAAC;;EAE1E;EACA,MAAMI,OAAO,GAAG9B,eAAe,CAAC2B,mBAAmB,EAAEE,eAAe,CAAC;EAErE,KAAK,MAAM,CAACnB,aAAa,EAAEC,SAAS,CAAC,IAAImB,OAAO,EAAE;IAChD,MAAMC,qBAAqB,GAAGrB,aAAa,GAAGa,kBAAkB;IAChE,MAAMS,iBAAiB,GAAGrB,SAAS,GAAGY,kBAAkB;IAExDF,aAAa,CAACW,iBAAiB,CAAC,GAC9Bd,YAAY,CAACa,qBAAqB,CAAC,IAAI,GAAGX,SAAS,KAAKE,QAAQ,EAAE,EAAE;EACxE;EAEA,KAAK,IAAIX,SAAS,GAAG,CAAC,EAAEA,SAAS,GAAGU,aAAa,CAACjB,MAAM,EAAEO,SAAS,IAAI,CAAC,EAAE;IACxE,IAAI,CAACU,aAAa,CAACV,SAAS,CAAC,EAAE;MAC7BU,aAAa,CAACV,SAAS,CAAC,GAAG,GAAGS,SAAS,KAAKE,QAAQ,EAAE,EAAE;IAC1D;EACF;EAEA,OAAO;IACLW,SAAS,EAAEZ,aAAa;IACxBC;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { withDelay, withTiming } from "react-native-reanimated";
|
|
4
|
+
// leading replacements use scale while first appearance uses the regular fade path
|
|
5
|
+
export const createLeadingEnterTransition = ({
|
|
6
|
+
durationMs,
|
|
7
|
+
easing
|
|
8
|
+
}) => {
|
|
9
|
+
return () => {
|
|
10
|
+
"worklet";
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
initialValues: {
|
|
14
|
+
opacity: 0,
|
|
15
|
+
transform: [{
|
|
16
|
+
scale: 0.5
|
|
17
|
+
}]
|
|
18
|
+
},
|
|
19
|
+
animations: {
|
|
20
|
+
opacity: withTiming(1, {
|
|
21
|
+
duration: durationMs,
|
|
22
|
+
easing
|
|
23
|
+
}),
|
|
24
|
+
transform: [{
|
|
25
|
+
scale: withTiming(1, {
|
|
26
|
+
duration: durationMs,
|
|
27
|
+
easing
|
|
28
|
+
})
|
|
29
|
+
}]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// one builder covers glyph opacity, travel, scale, and optional stagger timing
|
|
4
36
|
export const createShiftTransition = ({
|
|
5
37
|
delayMs = 0,
|
|
6
38
|
durationMs,
|
|
@@ -49,4 +81,47 @@ export const createShiftTransition = ({
|
|
|
49
81
|
};
|
|
50
82
|
};
|
|
51
83
|
};
|
|
84
|
+
|
|
85
|
+
// the shared swap flag lets an exiting worklet read the current transition type
|
|
86
|
+
export const createLeadingExitTransition = ({
|
|
87
|
+
durationMs,
|
|
88
|
+
easing,
|
|
89
|
+
leadingGap,
|
|
90
|
+
scale = false
|
|
91
|
+
}) => {
|
|
92
|
+
return values => {
|
|
93
|
+
"worklet";
|
|
94
|
+
|
|
95
|
+
const shouldScale = typeof scale === "object" ? scale.value > 0.5 : scale;
|
|
96
|
+
return {
|
|
97
|
+
initialValues: {
|
|
98
|
+
opacity: 1,
|
|
99
|
+
originX: values.currentOriginX,
|
|
100
|
+
...(shouldScale ? {
|
|
101
|
+
transform: [{
|
|
102
|
+
scale: 1
|
|
103
|
+
}]
|
|
104
|
+
} : {})
|
|
105
|
+
},
|
|
106
|
+
animations: {
|
|
107
|
+
opacity: withTiming(0, {
|
|
108
|
+
duration: durationMs,
|
|
109
|
+
easing
|
|
110
|
+
}),
|
|
111
|
+
originX: withTiming(values.currentOriginX - values.currentWidth - leadingGap, {
|
|
112
|
+
duration: durationMs,
|
|
113
|
+
easing
|
|
114
|
+
}),
|
|
115
|
+
...(shouldScale ? {
|
|
116
|
+
transform: [{
|
|
117
|
+
scale: withTiming(0.5, {
|
|
118
|
+
duration: durationMs,
|
|
119
|
+
easing
|
|
120
|
+
})
|
|
121
|
+
}]
|
|
122
|
+
} : {})
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
52
127
|
//# sourceMappingURL=entry-exit-builders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["withDelay","withTiming","
|
|
1
|
+
{"version":3,"names":["withDelay","withTiming","createLeadingEnterTransition","durationMs","easing","initialValues","opacity","transform","scale","animations","duration","createShiftTransition","delayMs","fromOpacity","toOpacity","fromTranslateY","toTranslateY","fromScale","toScale","animate","toValue","translateY","createLeadingExitTransition","leadingGap","values","shouldScale","value","originX","currentOriginX","currentWidth"],"sourceRoot":"../../../src","sources":["motion/entry-exit-builders.ts"],"mappings":";;AAAA,SAIEA,SAAS,EACTC,UAAU,QACL,yBAAyB;AA2BhC;AACA,OAAO,MAAMC,4BAA4B,GAAGA,CAAC;EAC3CC,UAAU;EACVC;AAC4B,CAAC,KAAiC;EAC9D,OAAO,MAAM;IACX,SAAS;;IAET,OAAO;MACLC,aAAa,EAAE;QACbC,OAAO,EAAE,CAAC;QACVC,SAAS,EAAE,CAAC;UAAEC,KAAK,EAAE;QAAI,CAAC;MAC5B,CAAC;MACDC,UAAU,EAAE;QACVH,OAAO,EAAEL,UAAU,CAAC,CAAC,EAAE;UAAES,QAAQ,EAAEP,UAAU;UAAEC;QAAO,CAAC,CAAC;QACxDG,SAAS,EAAE,CAAC;UAAEC,KAAK,EAAEP,UAAU,CAAC,CAAC,EAAE;YAAES,QAAQ,EAAEP,UAAU;YAAEC;UAAO,CAAC;QAAE,CAAC;MACxE;IACF,CAAC;EACH,CAAC;AACH,CAAC;;AAED;AACA,OAAO,MAAMO,qBAAqB,GAAGA,CAAC;EACpCC,OAAO,GAAG,CAAC;EACXT,UAAU;EACVC,MAAM;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QAC9B,IAAIH,WAAW,GAAG;UAAElB,SAAS,EAAE,CAAC;YAAEC,KAAK,EAAE;UAAE,CAAC;QAAE,CAAC,GAAG,CAAC,CAAC;MACtD,CAAC;MACDC,UAAU,EAAE;QACVH,OAAO,EAAEL,UAAU,CAAC,CAAC,EAAE;UAAES,QAAQ,EAAEP,UAAU;UAAEC;QAAO,CAAC,CAAC;QACxDuB,OAAO,EAAE1B,UAAU,CACjBuB,MAAM,CAACI,cAAc,GAAGJ,MAAM,CAACK,YAAY,GAAGN,UAAU,EACxD;UAAEb,QAAQ,EAAEP,UAAU;UAAEC;QAAO,CACjC,CAAC;QACD,IAAIqB,WAAW,GACX;UACElB,SAAS,EAAE,CACT;YAAEC,KAAK,EAAEP,UAAU,CAAC,GAAG,EAAE;cAAES,QAAQ,EAAEP,UAAU;cAAEC;YAAO,CAAC;UAAE,CAAC;QAEhE,CAAC,GACD,CAAC,CAAC;MACR;IACF,CAAC;EACH,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Easing, LinearTransition, withDelay, withSpring, withTiming } from "react-native-reanimated";
|
|
4
|
+
// keep all presets on one curve family so layout and glyph motion agree
|
|
4
5
|
const DEFAULT_CURVE = [0.19, 1, 0.22, 1];
|
|
5
6
|
export const MOTION_PRESETS = {
|
|
6
7
|
default: {
|
|
@@ -23,8 +24,12 @@ export const MOTION_PRESETS = {
|
|
|
23
24
|
bounce: 0.3
|
|
24
25
|
}
|
|
25
26
|
};
|
|
27
|
+
|
|
28
|
+
// the public preset table uses seconds while reanimated timing uses milliseconds
|
|
26
29
|
const toMilliseconds = seconds => Math.round(seconds * 1000);
|
|
27
30
|
const toDampingRatio = bounce => Math.max(0.55, Math.min(1, 1 - bounce));
|
|
31
|
+
|
|
32
|
+
// spring and timing presets share the same opacity contract
|
|
28
33
|
const createOpacityTransition = (fromOpacity, toOpacity, durationMs, easing) => {
|
|
29
34
|
return () => {
|
|
30
35
|
"worklet";
|
|
@@ -42,6 +47,8 @@ const createOpacityTransition = (fromOpacity, toOpacity, durationMs, easing) =>
|
|
|
42
47
|
};
|
|
43
48
|
};
|
|
44
49
|
};
|
|
50
|
+
|
|
51
|
+
// convert a named preset into the builders consumed by every rendering variant
|
|
45
52
|
export const resolveMotionRecipe = (presetName = "default", durationOverride) => {
|
|
46
53
|
const preset = MOTION_PRESETS[presetName];
|
|
47
54
|
const durationMs = durationOverride ?? toMilliseconds(preset.duration);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Easing","LinearTransition","withDelay","withSpring","withTiming","DEFAULT_CURVE","MOTION_PRESETS","default","duration","ease","smooth","type","bounce","snappy","bouncy","toMilliseconds","seconds","Math","round","toDampingRatio","max","min","createOpacityTransition","fromOpacity","toOpacity","durationMs","easing","initialValues","opacity","animations","resolveMotionRecipe","presetName","durationOverride","preset","dampingRatio","bezier","layoutTransition","factory","enterTransition","exitTransition","driveNumber","toValue","delayMs","animation","overshootClamping","timingPreset","x1","y1","x2","y2"],"sourceRoot":"../../../src","sources":["motion/preset-map.ts"],"mappings":";;AAAA,SACEA,MAAM,EACNC,gBAAgB,EAGhBC,SAAS,EACTC,UAAU,EACVC,UAAU,QACL,yBAAyB;AAOhC,MAAMC,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAU;AAEjD,OAAO,MAAMC,cAGZ,GAAG;EACFC,OAAO,EAAE;IACPC,QAAQ,EAAE,IAAI;IACdC,IAAI,EAAEJ;EACR,CAAC;EACDK,MAAM,EAAE;IACNC,IAAI,EAAE,QAAQ;IACdH,QAAQ,EAAE,GAAG;IACbI,MAAM,EAAE;EACV,CAAC;EACDC,MAAM,EAAE;IACNF,IAAI,EAAE,QAAQ;IACdH,QAAQ,EAAE,IAAI;IACdI,MAAM,EAAE;EACV,CAAC;EACDE,MAAM,EAAE;IACNH,IAAI,EAAE,QAAQ;IACdH,QAAQ,EAAE,GAAG;IACbI,MAAM,EAAE;EACV;AACF,CAAU;
|
|
1
|
+
{"version":3,"names":["Easing","LinearTransition","withDelay","withSpring","withTiming","DEFAULT_CURVE","MOTION_PRESETS","default","duration","ease","smooth","type","bounce","snappy","bouncy","toMilliseconds","seconds","Math","round","toDampingRatio","max","min","createOpacityTransition","fromOpacity","toOpacity","durationMs","easing","initialValues","opacity","animations","resolveMotionRecipe","presetName","durationOverride","preset","dampingRatio","bezier","layoutTransition","factory","enterTransition","exitTransition","driveNumber","toValue","delayMs","animation","overshootClamping","timingPreset","x1","y1","x2","y2"],"sourceRoot":"../../../src","sources":["motion/preset-map.ts"],"mappings":";;AAAA,SACEA,MAAM,EACNC,gBAAgB,EAGhBC,SAAS,EACTC,UAAU,EACVC,UAAU,QACL,yBAAyB;AAOhC;AACA,MAAMC,aAAa,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAU;AAEjD,OAAO,MAAMC,cAGZ,GAAG;EACFC,OAAO,EAAE;IACPC,QAAQ,EAAE,IAAI;IACdC,IAAI,EAAEJ;EACR,CAAC;EACDK,MAAM,EAAE;IACNC,IAAI,EAAE,QAAQ;IACdH,QAAQ,EAAE,GAAG;IACbI,MAAM,EAAE;EACV,CAAC;EACDC,MAAM,EAAE;IACNF,IAAI,EAAE,QAAQ;IACdH,QAAQ,EAAE,IAAI;IACdI,MAAM,EAAE;EACV,CAAC;EACDE,MAAM,EAAE;IACNH,IAAI,EAAE,QAAQ;IACdH,QAAQ,EAAE,GAAG;IACbI,MAAM,EAAE;EACV;AACF,CAAU;;AAEV;AACA,MAAMG,cAAc,GAAIC,OAAe,IAAKC,IAAI,CAACC,KAAK,CAACF,OAAO,GAAG,IAAI,CAAC;AAEtE,MAAMG,cAAc,GAAIP,MAAc,IACpCK,IAAI,CAACG,GAAG,CAAC,IAAI,EAAEH,IAAI,CAACI,GAAG,CAAC,CAAC,EAAE,CAAC,GAAGT,MAAM,CAAC,CAA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AE;UACpCjC,QAAQ,EAAEiB,UAAU;UACpBS,YAAY;UACZU,iBAAiB,EAAEX,MAAM,CAACrB,MAAM,KAAK;QACvC,CAAC,CAAC;QAEF,OAAO8B,OAAO,GAAG,CAAC,GAAGxC,SAAS,CAACwC,OAAO,EAAEC,SAAS,CAAC,GAAGA,SAAS;MAChE;IACF,CAAC;EACH;EAEA,MAAME,YAAY,GAAGZ,MAGpB;EACD,MAAM,CAACa,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,CAAC,GAAGJ,YAAY,CAACpC,IAAI;EAC1C,MAAMiB,MAAM,GAAG1B,MAAM,CAACmC,MAAM,CAACW,EAAE,EAAEC,EAAE,EAAEC,EAAE,EAAEC,EAAE,CAAC;EAE5C,OAAO;IACLxB,UAAU;IACVC,MAAM;IACNU,gBAAgB,EAAEnC,gBAAgB,CAACO,QAAQ,CAACiB,UAAU,CAAC,CAACC,MAAM,CAC5DA,MAAM,CAACW,OAAO,CAAC,CACjB,CAAC;IACDC,eAAe,EAAEhB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAEG,UAAU,EAAEC,MAAM,CAAC;IAClEa,cAAc,EAAEjB,uBAAuB,CAAC,CAAC,EAAE,CAAC,EAAEG,UAAU,EAAEC,MAAM,CAAC;IACjEc,WAAW,EAAEA,CAACC,OAAO,EAAEC,OAAO,GAAG,CAAC,KAAK;MACrC,MAAMC,SAAS,GAAGvC,UAAU,CAACqC,OAAO,EAAE;QACpCjC,QAAQ,EAAEiB,UAAU;QACpBC;MACF,CAAC,CAAC;MAEF,OAAOgB,OAAO,GAAG,CAAC,GAAGxC,SAAS,CAACwC,OAAO,EAAEC,SAAS,CAAC,GAAGA,SAAS;IAChE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -20,17 +20,36 @@ const rowAlignStyles = {
|
|
|
20
20
|
alignSelf: "flex-end"
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
+
|
|
24
|
+
// render text and inline elements through one animated token row
|
|
23
25
|
export const GlyphRun = /*#__PURE__*/React.memo(({
|
|
24
26
|
glyphs,
|
|
25
27
|
layoutTransition,
|
|
26
28
|
enterTransition,
|
|
29
|
+
elementEnterTransition,
|
|
27
30
|
exitTransition,
|
|
31
|
+
elementExitTransition,
|
|
32
|
+
leadingGap,
|
|
28
33
|
align,
|
|
29
34
|
textStyle,
|
|
30
35
|
className
|
|
31
|
-
}) =>
|
|
36
|
+
}) =>
|
|
37
|
+
/*#__PURE__*/
|
|
38
|
+
// each token keeps its own view so reanimated can animate only changed content
|
|
39
|
+
_jsx(View, {
|
|
32
40
|
style: [rowStyle, rowAlignStyles[align]],
|
|
33
|
-
children: glyphs.map(glyph => /*#__PURE__*/_jsx(Animated.
|
|
41
|
+
children: glyphs.map((glyph, glyphIndex) => glyph.kind === "element" ? /*#__PURE__*/_jsx(Animated.View, {
|
|
42
|
+
layout: layoutTransition,
|
|
43
|
+
entering: elementEnterTransition ?? enterTransition,
|
|
44
|
+
exiting: elementExitTransition ?? exitTransition,
|
|
45
|
+
style: [{
|
|
46
|
+
alignItems: "center",
|
|
47
|
+
justifyContent: "center"
|
|
48
|
+
}, glyphIndex === 0 && (leadingGap ?? 0) > 0 ? {
|
|
49
|
+
marginRight: leadingGap
|
|
50
|
+
} : undefined],
|
|
51
|
+
children: glyph.element
|
|
52
|
+
}, glyph.id) : /*#__PURE__*/_jsx(Animated.Text, {
|
|
34
53
|
layout: layoutTransition,
|
|
35
54
|
entering: enterTransition,
|
|
36
55
|
exiting: exitTransition,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","View","Animated","jsx","_jsx","rowStyle","flexDirection","alignItems","alignSelf","rowAlignStyles","left","center","right","GlyphRun","memo","glyphs","layoutTransition","enterTransition","exitTransition","align","textStyle","className","style","children","map","glyph","
|
|
1
|
+
{"version":3,"names":["React","View","Animated","jsx","_jsx","rowStyle","flexDirection","alignItems","alignSelf","rowAlignStyles","left","center","right","GlyphRun","memo","glyphs","layoutTransition","enterTransition","elementEnterTransition","exitTransition","elementExitTransition","leadingGap","align","textStyle","className","style","children","map","glyph","glyphIndex","kind","layout","entering","exiting","justifyContent","marginRight","undefined","element","id","Text","value","displayName"],"sourceRoot":"../../../src","sources":["view/glyph-run.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAyCC,IAAI,QAAQ,cAAc;AACnE,OAAOC,QAAQ,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAO/C,MAAMC,QAAQ,GAAG;EACfC,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,cAAc,GAAG;EACrBC,IAAI,EAAE;IAAEF,SAAS,EAAE;EAAa,CAAC;EACjCG,MAAM,EAAE;IAAEH,SAAS,EAAE;EAAS,CAAC;EAC/BI,KAAK,EAAE;IAAEJ,SAAS,EAAE;EAAW;AACjC,CAAU;;AAEV;AACA,OAAO,MAAMK,QAAQ,gBAAGb,KAAK,CAACc,IAAI,CAChC,CAAC;EACCC,MAAM;EACNC,gBAAgB;EAChBC,eAAe;EACfC,sBAAsB;EACtBC,cAAc;EACdC,qBAAqB;EACrBC,UAAU;EACVC,KAAK;EACLC,SAAS;EACTC;AAYD,CAAC;AAAA;AACA;AACEpB,IAAA,CAACH,IAAI;EAACwB,KAAK,EAAE,CAACpB,QAAQ,EAAEI,cAAc,CAACa,KAAK,CAAC,CAAE;EAAAI,QAAA,EAE5CX,MAAM,CAACY,GAAG,CAAC,CAACC,KAAK,EAAEC,UAAU,KAC5BD,KAAK,CAACE,IAAI,KAAK,SAAS,gBACtB1B,IAAA,CAACF,QAAQ,CAACD,IAAI;IAEZ8B,MAAM,EAAEf,gBAAiB;IACzBgB,QAAQ,EAAEd,sBAAsB,IAAID,eAAgB;IACpDgB,OAAO,EAAEb,qBAAqB,IAAID,cAAe;IACjDM,KAAK,EAAE,CACL;MAAElB,UAAU,EAAE,QAAQ;MAAE2B,cAAc,EAAE;IAAS,CAAC,EAClDL,UAAU,KAAK,CAAC,IAAI,CAACR,UAAU,IAAI,CAAC,IAAI,CAAC,GACrC;MAAEc,WAAW,EAAEd;IAAW,CAAC,GAC3Be,SAAS,CACb;IAAAV,QAAA,EAEDE,KAAK,CAACS;EAAO,GAXTT,KAAK,CAACU,EAYE,CAAC,gBAEhBlC,IAAA,CAACF,QAAQ,CAACqC,IAAI;IAEZR,MAAM,EAAEf,gBAAiB;IACzBgB,QAAQ,EAAEf,eAAgB;IAC1BgB,OAAO,EAAEd,cAAe;IACxBM,KAAK,EAAEF,SAAU;IACjBC,SAAS,EAAEA,SAAU;IAAAE,QAAA,EAEpBE,KAAK,CAACY;EAAK,GAPPZ,KAAK,CAACU,EAQE,CAEnB;AAAC,CACG,CAEZ,CAAC;AAEDzB,QAAQ,CAAC4B,WAAW,GAAG,UAAU","ignoreList":[]}
|
|
@@ -50,6 +50,7 @@ const viewportAlignStyles = {
|
|
|
50
50
|
alignItems: "flex-end"
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
// separate hidden measurement from visible content while sharing the shell alignment
|
|
53
54
|
export const MorphViewport = /*#__PURE__*/React.memo(({
|
|
54
55
|
autoSize,
|
|
55
56
|
clipToBounds,
|
|
@@ -59,7 +60,10 @@ export const MorphViewport = /*#__PURE__*/React.memo(({
|
|
|
59
60
|
measurement,
|
|
60
61
|
children
|
|
61
62
|
}) => {
|
|
63
|
+
// compute alignment once so the animated shell and its child share one layout contract
|
|
62
64
|
const resolvedViewportStyle = useMemo(() => [viewportStyle, viewportAlignStyles[align], clipToBounds ? clippedViewportStyle : unclippedViewportStyle], [align, clipToBounds]);
|
|
65
|
+
|
|
66
|
+
// keep measurement outside the visible viewport so it cannot affect accessibility or layout
|
|
63
67
|
return /*#__PURE__*/_jsx(View, {
|
|
64
68
|
style: [shellStyle, shellAlignStyles[align], containerStyle],
|
|
65
69
|
children: autoSize ? /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","View","Animated","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","shellStyle","position","alignSelf","viewportStyle","measuredContentStyle","left","top","opacity","flexShrink","clippedViewportStyle","overflow","unclippedViewportStyle","fullWidthViewportStyle","width","shellAlignStyles","center","right","viewportAlignStyles","alignItems","MorphViewport","memo","autoSize","clipToBounds","align","containerStyle","animatedWidthStyle","measurement","children","resolvedViewportStyle","style","accessibilityElementsHidden","collapsable","importantForAccessibility","pointerEvents","displayName"],"sourceRoot":"../../../src","sources":["view/morph-viewport.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,QAAQ,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAG/C,MAAMC,UAAU,GAAG;EACjBC,QAAQ,EAAE,UAAU;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,aAAa,GAAG;EACpBD,SAAS,EAAE;AACb,CAAU;AAEV,MAAME,oBAA+B,GAAG;EACtCH,QAAQ,EAAE,UAAU;EACpBI,IAAI,EAAE,CAAC;EACPC,GAAG,EAAE,CAAC;EACNC,OAAO,EAAE,CAAC;EACVL,SAAS,EAAE,YAAY;EACvBM,UAAU,EAAE;AACd,CAAC;AAED,MAAMC,oBAA+B,GAAG;EACtCC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,sBAAiC,GAAG;EACxCD,QAAQ,EAAE;AACZ,CAAC;AAED,MAAME,sBAAiC,GAAG;EACxCC,KAAK,EAAE;AACT,CAAC;AAED,MAAMC,gBAAiD,GAAG;EACxDT,IAAI,EAAE;IAAEH,SAAS,EAAE;EAAa,CAAC;EACjCa,MAAM,EAAE;IAAEb,SAAS,EAAE;EAAS,CAAC;EAC/Bc,KAAK,EAAE;IAAEd,SAAS,EAAE;EAAW;AACjC,CAAC;AAED,MAAMe,mBAAoD,GAAG;EAC3DZ,IAAI,EAAE;IAAEa,UAAU,EAAE;EAAa,CAAC;EAClCH,MAAM,EAAE;IAAEG,UAAU,EAAE;EAAS,CAAC;EAChCF,KAAK,EAAE;IAAEE,UAAU,EAAE;EAAW;AAClC,CAAC;AAYD,OAAO,MAAMC,aAAa,gBAAG7B,KAAK,CAAC8B,IAAI,CACrC,CAAC;EACCC,QAAQ;EACRC,YAAY;EACZC,KAAK;EACLC,cAAc;EACdC,kBAAkB;EAClBC,WAAW;EACXC;AACkB,CAAC,KAAK;EACxB,MAAMC,qBAAqB,GAAGrC,OAAO,CACnC,MAAM,CACJY,aAAa,EACbc,mBAAmB,CAACM,KAAK,CAAC,EAC1BD,YAAY,GAAGb,oBAAoB,GAAGE,sBAAsB,CAC7D,EACD,CAACY,KAAK,EAAED,YAAY,CACtB,CAAC;
|
|
1
|
+
{"version":3,"names":["React","useMemo","View","Animated","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","shellStyle","position","alignSelf","viewportStyle","measuredContentStyle","left","top","opacity","flexShrink","clippedViewportStyle","overflow","unclippedViewportStyle","fullWidthViewportStyle","width","shellAlignStyles","center","right","viewportAlignStyles","alignItems","MorphViewport","memo","autoSize","clipToBounds","align","containerStyle","animatedWidthStyle","measurement","children","resolvedViewportStyle","style","accessibilityElementsHidden","collapsable","importantForAccessibility","pointerEvents","displayName"],"sourceRoot":"../../../src","sources":["view/morph-viewport.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AAEtC,SAASC,IAAI,QAAQ,cAAc;AACnC,OAAOC,QAAQ,MAAM,yBAAyB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAG/C,MAAMC,UAAU,GAAG;EACjBC,QAAQ,EAAE,UAAU;EACpBC,SAAS,E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,EAAEc,gBAAgB,CAACS,KAAK,CAAC,EAAEC,cAAc,CAAE;IAAAG,QAAA,EAChEN,QAAQ,gBACPtB,KAAA,CAAAF,SAAA;MAAA8B,QAAA,gBACEhC,IAAA,CAACH,IAAI;QACHsC,2BAA2B;QAC3BC,WAAW,EAAE,KAAM;QACnBC,yBAAyB,EAAC,qBAAqB;QAC/CC,aAAa,EAAC,MAAM;QACpBJ,KAAK,EAAEzB,oBAAqB;QAAAuB,QAAA,EAE3BD;MAAW,CACR,CAAC,eACP/B,IAAA,CAACF,QAAQ,CAACD,IAAI;QAACqC,KAAK,EAAE,CAACD,qBAAqB,EAAEH,kBAAkB,CAAE;QAAAE,QAAA,EAC/DA;MAAQ,CACI,CAAC;IAAA,CAChB,CAAC,gBAEHhC,IAAA,CAACH,IAAI;MAACqC,KAAK,EAAE,CAACD,qBAAqB,EAAEhB,sBAAsB,CAAE;MAAAe,QAAA,EAC1DA;IAAQ,CACL;EACP,CACG,CAAC;AAEX,CACF,CAAC;AAEDR,aAAa,CAACe,WAAW,GAAG,eAAe","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ const laneTokenStyle = {
|
|
|
18
18
|
top: 0,
|
|
19
19
|
left: 0
|
|
20
20
|
};
|
|
21
|
+
// render one place-value lane with a hidden layout probe and an animated token
|
|
21
22
|
export const NumberLane = /*#__PURE__*/React.memo(({
|
|
22
23
|
unit,
|
|
23
24
|
tokenKey,
|
|
@@ -30,6 +31,7 @@ export const NumberLane = /*#__PURE__*/React.memo(({
|
|
|
30
31
|
textStyle,
|
|
31
32
|
className
|
|
32
33
|
}) => {
|
|
34
|
+
// punctuation stays in place while digits travel by the shared numeric direction
|
|
33
35
|
const usesDigitTravel = isAsciiDigit(unit);
|
|
34
36
|
const verticalOffset = direction > 0 ? travelDistance : direction < 0 ? -travelDistance : 0;
|
|
35
37
|
const enterTransition = useMemo(() => createShiftTransition({
|
|
@@ -54,6 +56,8 @@ export const NumberLane = /*#__PURE__*/React.memo(({
|
|
|
54
56
|
fromScale: 1,
|
|
55
57
|
toScale: 0.6
|
|
56
58
|
}), [delayMs, motionRecipe.durationMs, motionRecipe.easing, usesDigitTravel, verticalOffset]);
|
|
59
|
+
|
|
60
|
+
// prefix units do not need an absolute lane or a duplicate probe
|
|
57
61
|
if (isLead) {
|
|
58
62
|
return /*#__PURE__*/_jsx(Text, {
|
|
59
63
|
style: textStyle,
|
|
@@ -62,7 +66,7 @@ export const NumberLane = /*#__PURE__*/React.memo(({
|
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
return /*#__PURE__*/_jsxs(Animated.View, {
|
|
65
|
-
layout: motionRecipe.layoutTransition,
|
|
69
|
+
layout: hasAnimated ? motionRecipe.layoutTransition : undefined,
|
|
66
70
|
entering: hasAnimated ? motionRecipe.enterTransition : undefined,
|
|
67
71
|
exiting: motionRecipe.exitTransition,
|
|
68
72
|
style: laneStyle,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","Text","Animated","isAsciiDigit","createShiftTransition","jsx","_jsx","jsxs","_jsxs","laneStyle","position","alignSelf","laneProbeStyle","opacity","laneTokenStyle","top","left","NumberLane","memo","unit","tokenKey","isLead","hasAnimated","delayMs","direction","travelDistance","motionRecipe","textStyle","className","usesDigitTravel","verticalOffset","enterTransition","durationMs","easing","fromOpacity","toOpacity","fromTranslateY","toTranslateY","fromScale","toScale","exitTransition","style","children","View","layout","layoutTransition","
|
|
1
|
+
{"version":3,"names":["React","useMemo","Text","Animated","isAsciiDigit","createShiftTransition","jsx","_jsx","jsxs","_jsxs","laneStyle","position","alignSelf","laneProbeStyle","opacity","laneTokenStyle","top","left","NumberLane","memo","unit","tokenKey","isLead","hasAnimated","delayMs","direction","travelDistance","motionRecipe","textStyle","className","usesDigitTravel","verticalOffset","enterTransition","durationMs","easing","fromOpacity","toOpacity","fromTranslateY","toTranslateY","fromScale","toScale","exitTransition","style","children","View","layout","layoutTransition","undefined","entering","exiting","displayName"],"sourceRoot":"../../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AACd,SAAS,EAAEb,cAAc,CAAE;MACnCc,SAAS,EAAEA,SAAU;MAAAc,QAAA,EAEpBvB;IAAI,GANA,SAASC,QAAQ,EAOT,CAAC;EAAA,CACH,CAAC;AAEpB,CACF,CAAC;AAEDH,UAAU,CAACgC,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -21,6 +21,7 @@ const rowAlignStyles = {
|
|
|
21
21
|
alignSelf: "flex-end"
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
+
// arrange numeric lanes from left to right while the hook preserves their identities
|
|
24
25
|
export const NumberRun = /*#__PURE__*/React.memo(({
|
|
25
26
|
value,
|
|
26
27
|
motionRecipe,
|
|
@@ -30,6 +31,7 @@ export const NumberRun = /*#__PURE__*/React.memo(({
|
|
|
30
31
|
staggerMs,
|
|
31
32
|
className
|
|
32
33
|
}) => {
|
|
34
|
+
// the hook owns lane identity while this component owns row placement and timing
|
|
33
35
|
const {
|
|
34
36
|
units,
|
|
35
37
|
laneKeys,
|
|
@@ -44,6 +46,8 @@ export const NumberRun = /*#__PURE__*/React.memo(({
|
|
|
44
46
|
hasAnimatedRef.current = true;
|
|
45
47
|
lastValueRef.current = value;
|
|
46
48
|
}
|
|
49
|
+
|
|
50
|
+
// scale travel from the font while keeping a minimum visible movement
|
|
47
51
|
const travelDistance = useMemo(() => Math.max(8, Math.round((fontSize ?? 16) * 0.4)), [fontSize]);
|
|
48
52
|
const hasAnimated = hasAnimatedRef.current;
|
|
49
53
|
return /*#__PURE__*/_jsx(View, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useMemo","useRef","View","useNumericLanes","NumberLane","jsx","_jsx","rowStyle","flexDirection","alignItems","alignSelf","rowAlignStyles","left","center","right","NumberRun","memo","value","motionRecipe","align","fontSize","textStyle","staggerMs","className","units","laneKeys","direction","leadLength","lastValueRef","hasAnimatedRef","current","travelDistance","Math","max","round","hasAnimated","style","children","map","unit","index","inLead","laneKey","length","tokenKey","isLead","delayMs","displayName"],"sourceRoot":"../../../src","sources":["view/number-run.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC9C,SAAyCC,IAAI,QAAQ,cAAc;AACnE,SAASC,eAAe,QAAQ,+BAA4B;AAE5D,SAASC,UAAU,QAAQ,kBAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAMC,QAAQ,GAAG;EACfC,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,cAAc,GAAG;EACrBC,IAAI,EAAE;IAAEF,SAAS,EAAE;EAAa,CAAC;EACjCG,MAAM,EAAE;IAAEH,SAAS,EAAE;EAAS,CAAC;EAC/BI,KAAK,EAAE;IAAEJ,SAAS,EAAE;EAAW;AACjC,CAAU;AAYV,OAAO,MAAMK,SAAS,gBAAGhB,KAAK,CAACiB,IAAI,CACjC,CAAC;EACCC,KAAK;EACLC,YAAY;EACZC,KAAK;EACLC,QAAQ;EACRC,SAAS;EACTC,SAAS;EACTC;AACwB,CAAC,KAAK;EAC9B,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;EAAW,CAAC,GAAGxB,eAAe,CAACc,KAAK,CAAC;EACzE,MAAMW,YAAY,GAAG3B,MAAM,CAACgB,KAAK,CAAC;EAClC,MAAMY,cAAc,GAAG5B,MAAM,CAAC,KAAK,CAAC;;EAEpC;EACA,IAAIgB,KAAK,KAAKW,YAAY,CAACE,OAAO,EAAE;IAClCD,cAAc,CAACC,OAAO,GAAG,IAAI;IAC7BF,YAAY,CAACE,OAAO,GAAGb,KAAK;EAC9B;
|
|
1
|
+
{"version":3,"names":["React","useMemo","useRef","View","useNumericLanes","NumberLane","jsx","_jsx","rowStyle","flexDirection","alignItems","alignSelf","rowAlignStyles","left","center","right","NumberRun","memo","value","motionRecipe","align","fontSize","textStyle","staggerMs","className","units","laneKeys","direction","leadLength","lastValueRef","hasAnimatedRef","current","travelDistance","Math","max","round","hasAnimated","style","children","map","unit","index","inLead","laneKey","length","tokenKey","isLead","delayMs","displayName"],"sourceRoot":"../../../src","sources":["view/number-run.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AAC9C,SAAyCC,IAAI,QAAQ,cAAc;AACnE,SAASC,eAAe,QAAQ,+BAA4B;AAE5D,SAASC,UAAU,QAAQ,kBAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAMC,QAAQ,GAAG;EACfC,aAAa,EAAE,KAAK;EACpBC,UAAU,EAAE,QAAQ;EACpBC,SAAS,EAAE;AACb,CAAU;AAEV,MAAMC,cAAc,GAAG;EACrBC,IAAI,EAAE;IAAEF,SAAS,EAAE;EAAa,CAAC;EACjCG,MAAM,EAAE;IAAEH,SAAS,EAAE;EAAS,CAAC;EAC/BI,KAAK,EAAE;IAAEJ,SAAS,EAAE;EAAW;AACjC,CAAU;AAYV;AACA,OAAO,MAAMK,SAAS,gBAAGhB,KAAK,CAACiB,IAAI,CACjC,CAAC;EACCC,KAAK;EACLC,YAAY;EACZC,KAAK;EACLC,QAAQ;EACRC,SAAS;EACTC,SAAS;EACTC;AACwB,CAAC,KAAK;EAC9B;EACA,MAAM;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,SAAS;IAAEC;EAAW,CAAC,GAAGxB,eAAe,CAACc,KAAK,CAAC;EACzE,MAAMW,YAAY,GAAG3B,MAAM,CAACgB,KAAK,CAAC;EAClC,MAAMY,cAAc,GAAG5B,MAAM,CAAC,KAAK,CAAC;;EAEpC;EACA,IAAIgB,KAAK,KAAKW,YAAY,CAACE,OAAO,EAAE;IAClCD,cAAc,CAACC,OAAO,GAAG,IAAI;IAC7BF,YAAY,CAACE,OAAO,GAAGb,KAAK;EAC9B;;EAEA;EACA,MAAMc,cAAc,GAAG/B,OAAO,CAC5B,MAAMgC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,KAAK,CAAC,CAACd,QAAQ,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,EACrD,CAACA,QAAQ,CACX,CAAC;EACD,MAAMe,WAAW,GAAGN,cAAc,CAACC,OAAO;EAE1C,oBACExB,IAAA,CAACJ,IAAI;IAACkC,KAAK,EAAE,CAAC7B,QAAQ,EAAEI,cAAc,CAACQ,KAAK,CAAC,CAAE;IAAAkB,QAAA,EAC5Cb,KAAK,CAACc,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;MAC1B,MAAMC,MAAM,GAAGD,KAAK,GAAGb,UAAU;MACjC,MAAMe,OAAO,GAAGD,MAAM,GAClB,QAAQD,KAAK,EAAE,GACf,QAAQhB,KAAK,CAACmB,MAAM,GAAG,CAAC,GAAGH,KAAK,EAAE;MAEtC,oBACElC,IAAA,CAACF,UAAU;QAETmC,IAAI,EAAEA,IAAK;QACXK,QAAQ,EAAEnB,QAAQ,CAACe,KAAK,CAAE;QAC1BK,MAAM,EAAEJ,MAAO;QACfN,WAAW,EAAEA,WAAY;QACzBW,OAAO,EAAEN,KAAK,GAAGlB,SAAU;QAC3BI,SAAS,EAAEA,SAAU;QACrBK,cAAc,EAAEA,cAAe;QAC/Bb,YAAY,EAAEA,YAAa;QAC3BG,SAAS,EAAEA,SAAU;QACrBE,SAAS,EAAEA;MAAU,GAVhBmB,OAWN,CAAC;IAEN,CAAC;EAAC,CACE,CAAC;AAEX,CACF,CAAC;AAED3B,SAAS,CAACgC,WAAW,GAAG,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
5
|
+
import Animated, { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
6
|
+
import { useNumericLanes } from "../hooks/use-numeric-lanes.js";
|
|
7
|
+
import { isAsciiDigit } from "../model/display-units.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
const rowStyle = {
|
|
10
|
+
flexDirection: "row",
|
|
11
|
+
alignItems: "center",
|
|
12
|
+
alignSelf: "flex-start"
|
|
13
|
+
};
|
|
14
|
+
const rowAlignStyles = {
|
|
15
|
+
left: {
|
|
16
|
+
alignSelf: "flex-start"
|
|
17
|
+
},
|
|
18
|
+
center: {
|
|
19
|
+
alignSelf: "center"
|
|
20
|
+
},
|
|
21
|
+
right: {
|
|
22
|
+
alignSelf: "flex-end"
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const slotFrameStyle = {
|
|
26
|
+
position: "relative",
|
|
27
|
+
alignSelf: "flex-start",
|
|
28
|
+
overflow: "hidden"
|
|
29
|
+
};
|
|
30
|
+
const slotProbeStyle = {
|
|
31
|
+
opacity: 0
|
|
32
|
+
};
|
|
33
|
+
const slotDigitStyle = {
|
|
34
|
+
textAlign: "center"
|
|
35
|
+
};
|
|
36
|
+
const REEL_MIN = -12;
|
|
37
|
+
const REEL_MAX = 22;
|
|
38
|
+
const REEL_POSITIONS = Array.from({
|
|
39
|
+
length: 30
|
|
40
|
+
}, (_, index) => index - 10);
|
|
41
|
+
|
|
42
|
+
// wrap reel positions so a bounded strip can represent an endless digit wheel
|
|
43
|
+
const mod = (value, divisor) => (value % divisor + divisor) % divisor;
|
|
44
|
+
// compare flattened style values without treating a new array as a visual change
|
|
45
|
+
const equalStyleValue = (left, right) => left === right || Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => value === right[index]);
|
|
46
|
+
|
|
47
|
+
// prevent every parent update from rebuilding the thirty-text reel
|
|
48
|
+
const areSlotReelPropsEqual = (previous, next) => {
|
|
49
|
+
if (previous.current !== next.current || previous.slotHeight !== next.slotHeight || previous.className !== next.className) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const previousStyle = StyleSheet.flatten(previous.textStyle) ?? {};
|
|
53
|
+
const nextStyle = StyleSheet.flatten(next.textStyle) ?? {};
|
|
54
|
+
const previousKeys = Object.keys(previousStyle);
|
|
55
|
+
const nextKeys = Object.keys(nextStyle);
|
|
56
|
+
return previousKeys.length === nextKeys.length && previousKeys.every(key => equalStyleValue(previousStyle[key], nextStyle[key]));
|
|
57
|
+
};
|
|
58
|
+
const SlotReel = /*#__PURE__*/React.memo(function SlotReel({
|
|
59
|
+
current,
|
|
60
|
+
slotHeight,
|
|
61
|
+
textStyle,
|
|
62
|
+
className
|
|
63
|
+
}) {
|
|
64
|
+
// translate one bounded reel instead of mounting a new animated digit per update
|
|
65
|
+
const animatedStyle = useAnimatedStyle(() => ({
|
|
66
|
+
transform: [{
|
|
67
|
+
translateY: (-10 - current.value) * slotHeight
|
|
68
|
+
}]
|
|
69
|
+
}), [slotHeight]);
|
|
70
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
71
|
+
pointerEvents: "none",
|
|
72
|
+
style: [{
|
|
73
|
+
position: "absolute",
|
|
74
|
+
top: 0,
|
|
75
|
+
left: 0,
|
|
76
|
+
right: 0
|
|
77
|
+
}, animatedStyle],
|
|
78
|
+
children: REEL_POSITIONS.map((position, index) => /*#__PURE__*/_jsx(Text, {
|
|
79
|
+
numberOfLines: 1,
|
|
80
|
+
style: [textStyle, slotDigitStyle, {
|
|
81
|
+
position: "absolute",
|
|
82
|
+
top: index * slotHeight,
|
|
83
|
+
left: 0,
|
|
84
|
+
right: 0,
|
|
85
|
+
height: slotHeight,
|
|
86
|
+
lineHeight: slotHeight
|
|
87
|
+
}],
|
|
88
|
+
className: className,
|
|
89
|
+
children: mod(position, 10)
|
|
90
|
+
}, position))
|
|
91
|
+
});
|
|
92
|
+
}, areSlotReelPropsEqual);
|
|
93
|
+
function SlotColumn({
|
|
94
|
+
digit,
|
|
95
|
+
direction,
|
|
96
|
+
delayMs,
|
|
97
|
+
animateIn,
|
|
98
|
+
motionRecipe,
|
|
99
|
+
slotHeight,
|
|
100
|
+
textStyle,
|
|
101
|
+
className
|
|
102
|
+
}) {
|
|
103
|
+
// cumulative positions let the reel move across digit wraparound without jumps
|
|
104
|
+
const spinInDistance = Math.max(digit, 1);
|
|
105
|
+
const initialDirection = direction || 1;
|
|
106
|
+
const initialValue = animateIn ? digit - spinInDistance * initialDirection : digit;
|
|
107
|
+
const current = useSharedValue(initialValue);
|
|
108
|
+
const cumulativeRef = useRef(digit);
|
|
109
|
+
const previousDigitRef = useRef(digit);
|
|
110
|
+
const initialRef = useRef(true);
|
|
111
|
+
const exitStateRef = useRef({
|
|
112
|
+
digit,
|
|
113
|
+
direction,
|
|
114
|
+
motionRecipe,
|
|
115
|
+
target: digit
|
|
116
|
+
});
|
|
117
|
+
if (digit !== previousDigitRef.current) {
|
|
118
|
+
const previousDigit = previousDigitRef.current;
|
|
119
|
+
let digitDelta;
|
|
120
|
+
if (direction > 0) {
|
|
121
|
+
digitDelta = digit >= previousDigit ? digit - previousDigit : 10 - previousDigit + digit;
|
|
122
|
+
} else if (direction < 0) {
|
|
123
|
+
digitDelta = previousDigit >= digit ? -(previousDigit - digit) : -(10 - digit + previousDigit);
|
|
124
|
+
} else {
|
|
125
|
+
digitDelta = digit - previousDigit;
|
|
126
|
+
}
|
|
127
|
+
cumulativeRef.current += digitDelta;
|
|
128
|
+
previousDigitRef.current = digit;
|
|
129
|
+
}
|
|
130
|
+
exitStateRef.current = {
|
|
131
|
+
digit,
|
|
132
|
+
direction,
|
|
133
|
+
motionRecipe,
|
|
134
|
+
target: cumulativeRef.current
|
|
135
|
+
};
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
// continue the current reel from its last committed target when the column exits
|
|
138
|
+
return () => {
|
|
139
|
+
const exitState = exitStateRef.current;
|
|
140
|
+
const spinOutDistance = Math.max(exitState.digit, 1);
|
|
141
|
+
const exitDirection = exitState.direction || 1;
|
|
142
|
+
current.value = exitState.motionRecipe.driveNumber(exitState.target + spinOutDistance * exitDirection);
|
|
143
|
+
};
|
|
144
|
+
}, [current]);
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
// keep the reel bounded by recentring after enough cumulative turns
|
|
147
|
+
if (initialRef.current) {
|
|
148
|
+
initialRef.current = false;
|
|
149
|
+
if (!animateIn) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
let target = cumulativeRef.current;
|
|
154
|
+
if (target < REEL_MIN + 4 || target > REEL_MAX - 4) {
|
|
155
|
+
const shift = Math.trunc(target / 10) * 10;
|
|
156
|
+
if (shift !== 0) {
|
|
157
|
+
target -= shift;
|
|
158
|
+
cumulativeRef.current = target;
|
|
159
|
+
current.value -= shift;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exitStateRef.current = {
|
|
163
|
+
digit,
|
|
164
|
+
direction,
|
|
165
|
+
motionRecipe,
|
|
166
|
+
target
|
|
167
|
+
};
|
|
168
|
+
current.value = motionRecipe.driveNumber(target, delayMs);
|
|
169
|
+
}, [animateIn, current, delayMs, digit, direction, motionRecipe]);
|
|
170
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
171
|
+
style: slotFrameStyle,
|
|
172
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
173
|
+
style: [textStyle, slotProbeStyle, {
|
|
174
|
+
lineHeight: slotHeight
|
|
175
|
+
}],
|
|
176
|
+
className: className,
|
|
177
|
+
children: "0"
|
|
178
|
+
}), /*#__PURE__*/_jsx(SlotReel, {
|
|
179
|
+
current: current,
|
|
180
|
+
slotHeight: slotHeight,
|
|
181
|
+
textStyle: textStyle,
|
|
182
|
+
className: className
|
|
183
|
+
})]
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
// render text prefixes beside reusable digit reels
|
|
187
|
+
export const SlotsRun = /*#__PURE__*/React.memo(({
|
|
188
|
+
value,
|
|
189
|
+
motionRecipe,
|
|
190
|
+
align,
|
|
191
|
+
fontSize,
|
|
192
|
+
textStyle,
|
|
193
|
+
staggerMs,
|
|
194
|
+
className
|
|
195
|
+
}) => {
|
|
196
|
+
// numeric lane identity decides which columns stay mounted as values change
|
|
197
|
+
const {
|
|
198
|
+
units,
|
|
199
|
+
direction,
|
|
200
|
+
leadLength
|
|
201
|
+
} = useNumericLanes(value);
|
|
202
|
+
const lastValueRef = useRef(value);
|
|
203
|
+
const hasAnimatedRef = useRef(false);
|
|
204
|
+
// derive one stable row height so every reel position shares the same baseline
|
|
205
|
+
const slotHeight = useMemo(() => {
|
|
206
|
+
const flattenedStyle = StyleSheet.flatten(textStyle);
|
|
207
|
+
const resolvedLineHeight = typeof flattenedStyle?.lineHeight === "number" ? flattenedStyle.lineHeight : undefined;
|
|
208
|
+
const resolvedFontSize = typeof flattenedStyle?.fontSize === "number" ? flattenedStyle.fontSize : fontSize;
|
|
209
|
+
return Math.max(12, Math.ceil(resolvedLineHeight ?? (resolvedFontSize ?? 16) * 1.18));
|
|
210
|
+
}, [fontSize, textStyle]);
|
|
211
|
+
if (value !== lastValueRef.current) {
|
|
212
|
+
hasAnimatedRef.current = true;
|
|
213
|
+
lastValueRef.current = value;
|
|
214
|
+
}
|
|
215
|
+
const digitCount = units.filter(isAsciiDigit).length;
|
|
216
|
+
let digitIndex = 0;
|
|
217
|
+
const hasAnimated = hasAnimatedRef.current;
|
|
218
|
+
return /*#__PURE__*/_jsx(View, {
|
|
219
|
+
style: [rowStyle, rowAlignStyles[align]],
|
|
220
|
+
children: units.map((unit, index) => {
|
|
221
|
+
const inLead = index < leadLength;
|
|
222
|
+
const laneKey = inLead ? `lead:${index}` : `slot:${units.length - 1 - index}`;
|
|
223
|
+
if (inLead || !isAsciiDigit(unit)) {
|
|
224
|
+
return /*#__PURE__*/_jsx(Animated.Text, {
|
|
225
|
+
layout: hasAnimated ? motionRecipe.layoutTransition : undefined,
|
|
226
|
+
exiting: !inLead ? motionRecipe.exitTransition : undefined,
|
|
227
|
+
style: textStyle,
|
|
228
|
+
className: className,
|
|
229
|
+
children: unit
|
|
230
|
+
}, laneKey);
|
|
231
|
+
}
|
|
232
|
+
const delayMs = (digitCount - 1 - digitIndex) * staggerMs;
|
|
233
|
+
digitIndex += 1;
|
|
234
|
+
return /*#__PURE__*/_jsx(Animated.View, {
|
|
235
|
+
layout: hasAnimated ? motionRecipe.layoutTransition : undefined,
|
|
236
|
+
entering: hasAnimated ? motionRecipe.enterTransition : undefined,
|
|
237
|
+
exiting: motionRecipe.exitTransition,
|
|
238
|
+
children: /*#__PURE__*/_jsx(SlotColumn, {
|
|
239
|
+
digit: Number(unit),
|
|
240
|
+
direction: direction,
|
|
241
|
+
delayMs: delayMs,
|
|
242
|
+
animateIn: hasAnimated,
|
|
243
|
+
motionRecipe: motionRecipe,
|
|
244
|
+
slotHeight: slotHeight,
|
|
245
|
+
textStyle: textStyle,
|
|
246
|
+
className: className
|
|
247
|
+
})
|
|
248
|
+
}, laneKey);
|
|
249
|
+
})
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
SlotsRun.displayName = "SlotsRun";
|
|
253
|
+
//# sourceMappingURL=slots-run.js.map
|