@tamagui/animations-react-native 2.0.0-rc.4 → 2.0.0-rc.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/createAnimations.cjs +385 -220
- package/dist/cjs/createAnimations.native.js +451 -273
- package/dist/cjs/createAnimations.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/polyfill.cjs +3 -1
- package/dist/cjs/polyfill.native.js +3 -1
- package/dist/cjs/polyfill.native.js.map +1 -1
- package/dist/esm/createAnimations.mjs +355 -193
- package/dist/esm/createAnimations.mjs.map +1 -1
- package/dist/esm/createAnimations.native.js +421 -246
- package/dist/esm/createAnimations.native.js.map +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/polyfill.mjs +3 -1
- package/dist/esm/polyfill.mjs.map +1 -1
- package/dist/esm/polyfill.native.js +3 -1
- package/dist/esm/polyfill.native.js.map +1 -1
- package/package.json +10 -13
- package/src/createAnimations.tsx +187 -25
- package/types/createAnimations.d.ts +5 -1
- package/types/createAnimations.d.ts.map +5 -10
- package/types/index.d.ts.map +2 -2
- package/types/polyfill.d.ts.map +2 -2
- package/dist/cjs/createAnimations.js +0 -297
- package/dist/cjs/createAnimations.js.map +0 -6
- package/dist/cjs/index.js +0 -16
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/polyfill.js +0 -2
- package/dist/cjs/polyfill.js.map +0 -6
- package/dist/esm/createAnimations.js +0 -278
- package/dist/esm/createAnimations.js.map +0 -6
- package/dist/esm/polyfill.js +0 -2
- package/dist/esm/polyfill.js.map +0 -6
package/types/index.d.ts.map
CHANGED
package/types/polyfill.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/polyfill.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"// for SSR\nif (typeof requestAnimationFrame === 'undefined') {\n globalThis['requestAnimationFrame'] =\n typeof setImmediate === 'undefined' ? setTimeout : setImmediate\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var createAnimations_exports = {};
|
|
24
|
-
__export(createAnimations_exports, {
|
|
25
|
-
AnimatedText: () => AnimatedText,
|
|
26
|
-
AnimatedView: () => AnimatedView,
|
|
27
|
-
createAnimations: () => createAnimations,
|
|
28
|
-
useAnimatedNumber: () => useAnimatedNumber,
|
|
29
|
-
useAnimatedNumberReaction: () => useAnimatedNumberReaction,
|
|
30
|
-
useAnimatedNumberStyle: () => useAnimatedNumberStyle
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(createAnimations_exports);
|
|
33
|
-
var import_animation_helpers = require("@tamagui/animation-helpers"), import_constants = require("@tamagui/constants"), import_use_presence = require("@tamagui/use-presence"), import_web = require("@tamagui/web"), import_react = __toESM(require("react"), 1), import_react_native = require("react-native-web");
|
|
34
|
-
const resolveDynamicValue = (value, isDark) => value && typeof value == "object" && "dynamic" in value ? isDark ? value.dynamic.dark : value.dynamic.light : value, animatedStyleKey = {
|
|
35
|
-
transform: !0,
|
|
36
|
-
opacity: !0
|
|
37
|
-
}, colorStyleKey = {
|
|
38
|
-
backgroundColor: !0,
|
|
39
|
-
color: !0,
|
|
40
|
-
borderColor: !0,
|
|
41
|
-
borderLeftColor: !0,
|
|
42
|
-
borderRightColor: !0,
|
|
43
|
-
borderTopColor: !0,
|
|
44
|
-
borderBottomColor: !0
|
|
45
|
-
}, costlyToAnimateStyleKey = {
|
|
46
|
-
borderRadius: !0,
|
|
47
|
-
borderTopLeftRadius: !0,
|
|
48
|
-
borderTopRightRadius: !0,
|
|
49
|
-
borderBottomLeftRadius: !0,
|
|
50
|
-
borderBottomRightRadius: !0,
|
|
51
|
-
borderWidth: !0,
|
|
52
|
-
borderLeftWidth: !0,
|
|
53
|
-
borderRightWidth: !0,
|
|
54
|
-
borderTopWidth: !0,
|
|
55
|
-
borderBottomWidth: !0,
|
|
56
|
-
...colorStyleKey
|
|
57
|
-
// TODO for other keys like height or width, it's better to not add them here till layout animations are ready
|
|
58
|
-
}, AnimatedView = import_react_native.Animated.View, AnimatedText = import_react_native.Animated.Text;
|
|
59
|
-
function useAnimatedNumber(initial) {
|
|
60
|
-
const state = import_react.default.useRef(
|
|
61
|
-
null
|
|
62
|
-
);
|
|
63
|
-
return state.current || (state.current = {
|
|
64
|
-
composite: null,
|
|
65
|
-
val: new import_react_native.Animated.Value(initial),
|
|
66
|
-
strategy: { type: "spring" }
|
|
67
|
-
}), {
|
|
68
|
-
getInstance() {
|
|
69
|
-
return state.current.val;
|
|
70
|
-
},
|
|
71
|
-
getValue() {
|
|
72
|
-
return state.current.val._value;
|
|
73
|
-
},
|
|
74
|
-
stop() {
|
|
75
|
-
state.current.composite?.stop(), state.current.composite = null;
|
|
76
|
-
},
|
|
77
|
-
setValue(next, { type, ...config } = { type: "spring" }, onFinish) {
|
|
78
|
-
const val = state.current.val, handleFinish = onFinish ? ({ finished }) => finished ? onFinish() : null : void 0;
|
|
79
|
-
if (type === "direct")
|
|
80
|
-
val.setValue(next);
|
|
81
|
-
else if (type === "spring") {
|
|
82
|
-
state.current.composite?.stop();
|
|
83
|
-
const composite = import_react_native.Animated.spring(val, {
|
|
84
|
-
...config,
|
|
85
|
-
toValue: next,
|
|
86
|
-
useNativeDriver: !import_constants.isWeb
|
|
87
|
-
});
|
|
88
|
-
composite.start(handleFinish), state.current.composite = composite;
|
|
89
|
-
} else {
|
|
90
|
-
state.current.composite?.stop();
|
|
91
|
-
const composite = import_react_native.Animated.timing(val, {
|
|
92
|
-
...config,
|
|
93
|
-
toValue: next,
|
|
94
|
-
useNativeDriver: !import_constants.isWeb
|
|
95
|
-
});
|
|
96
|
-
composite.start(handleFinish), state.current.composite = composite;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
const useAnimatedNumberReaction = ({ value }, onValue) => {
|
|
102
|
-
const onChange = (0, import_web.useEvent)((current) => {
|
|
103
|
-
onValue(current.value);
|
|
104
|
-
});
|
|
105
|
-
import_react.default.useEffect(() => {
|
|
106
|
-
const id = value.getInstance().addListener(onChange);
|
|
107
|
-
return () => {
|
|
108
|
-
value.getInstance().removeListener(id);
|
|
109
|
-
};
|
|
110
|
-
}, [value, onChange]);
|
|
111
|
-
}, useAnimatedNumberStyle = (value, getStyle) => getStyle(value.getInstance());
|
|
112
|
-
function createAnimations(animations) {
|
|
113
|
-
return {
|
|
114
|
-
isReactNative: !0,
|
|
115
|
-
inputStyle: "value",
|
|
116
|
-
outputStyle: "inline",
|
|
117
|
-
animations,
|
|
118
|
-
View: AnimatedView,
|
|
119
|
-
Text: AnimatedText,
|
|
120
|
-
useAnimatedNumber,
|
|
121
|
-
useAnimatedNumberReaction,
|
|
122
|
-
useAnimatedNumberStyle,
|
|
123
|
-
usePresence: import_use_presence.usePresence,
|
|
124
|
-
ResetPresence: import_use_presence.ResetPresence,
|
|
125
|
-
useAnimations: ({ props, onDidAnimate, style, componentState, presence }) => {
|
|
126
|
-
const isDisabled = import_constants.isWeb && componentState.unmounted === !0, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], [, themeState] = (0, import_web.useThemeWithState)({}), isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark"), animateStyles = import_react.default.useRef({}), animatedTranforms = import_react.default.useRef([]), animationsState = import_react.default.useRef(
|
|
127
|
-
/* @__PURE__ */ new WeakMap()
|
|
128
|
-
), animateOnly = props.animateOnly || [], hasTransitionOnly = !!props.animateOnly, isEntering = !!componentState.unmounted, wasEnteringRef = import_react.default.useRef(isEntering), justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
129
|
-
import_react.default.useEffect(() => {
|
|
130
|
-
wasEnteringRef.current = isEntering;
|
|
131
|
-
});
|
|
132
|
-
const args = [
|
|
133
|
-
JSON.stringify(style),
|
|
134
|
-
componentState,
|
|
135
|
-
isExiting,
|
|
136
|
-
!!onDidAnimate,
|
|
137
|
-
isDark,
|
|
138
|
-
justFinishedEntering
|
|
139
|
-
], isThereNoNativeStyleKeys = import_react.default.useMemo(() => import_constants.isWeb ? !0 : Object.keys(style).some((key) => animateOnly ? !animatedStyleKey[key] && animateOnly.indexOf(key) === -1 : !animatedStyleKey[key]), args), res = import_react.default.useMemo(() => {
|
|
140
|
-
const runners = [], completions = [], animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default", nonAnimatedStyle = {};
|
|
141
|
-
for (const key in style) {
|
|
142
|
-
const rawVal = style[key], val = resolveDynamicValue(rawVal, isDark);
|
|
143
|
-
if (val !== void 0 && !isDisabled) {
|
|
144
|
-
if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key]) {
|
|
145
|
-
nonAnimatedStyle[key] = val;
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (hasTransitionOnly && !animateOnly.includes(key)) {
|
|
149
|
-
nonAnimatedStyle[key] = val;
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (key !== "transform") {
|
|
153
|
-
animateStyles.current[key] = update(key, animateStyles.current[key], val);
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (val) {
|
|
157
|
-
if (typeof val == "string") {
|
|
158
|
-
console.warn("Warning: Tamagui can't animate string transforms yet!");
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
for (const [index, transform] of val.entries()) {
|
|
162
|
-
if (!transform) continue;
|
|
163
|
-
const tkey = Object.keys(transform)[0], currentTransform = animatedTranforms.current[index]?.[tkey];
|
|
164
|
-
animatedTranforms.current[index] = {
|
|
165
|
-
[tkey]: update(tkey, currentTransform, transform[tkey])
|
|
166
|
-
}, animatedTranforms.current = [...animatedTranforms.current];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
const animatedStyle = {
|
|
172
|
-
...Object.fromEntries(
|
|
173
|
-
Object.entries(animateStyles.current).map(([k, v]) => [
|
|
174
|
-
k,
|
|
175
|
-
animationsState.current.get(v)?.interpolation || v
|
|
176
|
-
])
|
|
177
|
-
),
|
|
178
|
-
transform: animatedTranforms.current.map((r) => {
|
|
179
|
-
const key = Object.keys(r)[0], val = animationsState.current.get(r[key])?.interpolation || r[key];
|
|
180
|
-
return { [key]: val };
|
|
181
|
-
})
|
|
182
|
-
};
|
|
183
|
-
return {
|
|
184
|
-
runners,
|
|
185
|
-
completions,
|
|
186
|
-
style: [nonAnimatedStyle, animatedStyle]
|
|
187
|
-
};
|
|
188
|
-
function update(key, animated, valIn) {
|
|
189
|
-
const isColorStyleKey = colorStyleKey[key], [val, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
|
|
190
|
-
let animateToValue = val;
|
|
191
|
-
const value = animated || new import_react_native.Animated.Value(val), curInterpolation = animationsState.current.get(value);
|
|
192
|
-
let interpolateArgs;
|
|
193
|
-
if (type && (interpolateArgs = getInterpolated(
|
|
194
|
-
curInterpolation?.current ?? value._value,
|
|
195
|
-
val,
|
|
196
|
-
type
|
|
197
|
-
), animationsState.current.set(value, {
|
|
198
|
-
interpolation: value.interpolate(interpolateArgs),
|
|
199
|
-
current: val
|
|
200
|
-
})), isColorStyleKey && (animateToValue = curInterpolation?.animateToValue ? 0 : 1, interpolateArgs = getColorInterpolated(
|
|
201
|
-
curInterpolation?.current,
|
|
202
|
-
// valIn is the next color
|
|
203
|
-
valIn,
|
|
204
|
-
animateToValue
|
|
205
|
-
), animationsState.current.set(value, {
|
|
206
|
-
current: valIn,
|
|
207
|
-
interpolation: value.interpolate(interpolateArgs),
|
|
208
|
-
animateToValue: curInterpolation?.animateToValue ? 0 : 1
|
|
209
|
-
})), value) {
|
|
210
|
-
const animationConfig = getAnimationConfig(
|
|
211
|
-
key,
|
|
212
|
-
animations,
|
|
213
|
-
props.transition,
|
|
214
|
-
animationState
|
|
215
|
-
);
|
|
216
|
-
let resolve;
|
|
217
|
-
const promise = new Promise((res2) => {
|
|
218
|
-
resolve = res2;
|
|
219
|
-
});
|
|
220
|
-
completions.push(promise), runners.push(() => {
|
|
221
|
-
value.stopAnimation();
|
|
222
|
-
function getAnimation() {
|
|
223
|
-
return import_react_native.Animated[animationConfig.type || "spring"](value, {
|
|
224
|
-
toValue: animateToValue,
|
|
225
|
-
useNativeDriver: !import_constants.isWeb && !isThereNoNativeStyleKeys,
|
|
226
|
-
...animationConfig
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
(animationConfig.delay ? import_react_native.Animated.sequence([
|
|
230
|
-
import_react_native.Animated.delay(animationConfig.delay),
|
|
231
|
-
getAnimation()
|
|
232
|
-
]) : getAnimation()).start(({ finished }) => {
|
|
233
|
-
finished && resolve();
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(
|
|
238
|
-
" \u{1F4A0} animate",
|
|
239
|
-
key,
|
|
240
|
-
`from (${value._value}) to`,
|
|
241
|
-
valIn,
|
|
242
|
-
`(${val})`,
|
|
243
|
-
"type",
|
|
244
|
-
type,
|
|
245
|
-
"interpolate",
|
|
246
|
-
interpolateArgs
|
|
247
|
-
), value;
|
|
248
|
-
}
|
|
249
|
-
}, args);
|
|
250
|
-
return (0, import_constants.useIsomorphicLayoutEffect)(() => {
|
|
251
|
-
res.runners.forEach((r) => r());
|
|
252
|
-
let cancel = !1;
|
|
253
|
-
return Promise.all(res.completions).then(() => {
|
|
254
|
-
cancel || (onDidAnimate?.(), isExiting && sendExitComplete?.());
|
|
255
|
-
}), () => {
|
|
256
|
-
cancel = !0;
|
|
257
|
-
};
|
|
258
|
-
}, args), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("Animated", { response: res, inputStyle: style, isExiting }), res;
|
|
259
|
-
}
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
function getColorInterpolated(currentColor, nextColor, animateToValue) {
|
|
263
|
-
const inputRange = [0, 1], outputRange = [currentColor || nextColor, nextColor];
|
|
264
|
-
return animateToValue === 0 && outputRange.reverse(), {
|
|
265
|
-
inputRange,
|
|
266
|
-
outputRange
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
function getInterpolated(current, next, postfix = "deg") {
|
|
270
|
-
next === current && (current = next - 1e-9);
|
|
271
|
-
const inputRange = [current, next], outputRange = [`${current}${postfix}`, `${next}${postfix}`];
|
|
272
|
-
return next < current && (inputRange.reverse(), outputRange.reverse()), {
|
|
273
|
-
inputRange,
|
|
274
|
-
outputRange
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function getAnimationConfig(key, animations, transition, animationState = "default") {
|
|
278
|
-
const normalized = (0, import_animation_helpers.normalizeTransition)(transition), shortKey = transformShorthands[key], propAnimation = normalized.properties[key] ?? normalized.properties[shortKey];
|
|
279
|
-
let animationType = null, extraConf = {};
|
|
280
|
-
return typeof propAnimation == "string" ? animationType = propAnimation : propAnimation && typeof propAnimation == "object" ? (animationType = propAnimation.type || (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState), extraConf = propAnimation) : animationType = (0, import_animation_helpers.getEffectiveAnimation)(normalized, animationState), normalized.delay && !extraConf.delay && (extraConf = { ...extraConf, delay: normalized.delay }), {
|
|
281
|
-
...animationType ? animations[animationType] : {},
|
|
282
|
-
...extraConf
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
const transformShorthands = {
|
|
286
|
-
x: "translateX",
|
|
287
|
-
y: "translateY",
|
|
288
|
-
translateX: "x",
|
|
289
|
-
translateY: "y"
|
|
290
|
-
};
|
|
291
|
-
function getValue(input, isColor = !1) {
|
|
292
|
-
if (typeof input != "string")
|
|
293
|
-
return [input];
|
|
294
|
-
const [_, number, after] = input.match(/([-0-9]+)(deg|%|px)/) ?? [];
|
|
295
|
-
return [+number, after];
|
|
296
|
-
}
|
|
297
|
-
//# sourceMappingURL=createAnimations.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/createAnimations.tsx"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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3B,cAAc,CAAC,GAAG,OAAO,GAAG,OAAO,IAAI,GAAG,IAAI,GAAG,OAAO,EAAE;AAChE,SAAI,OAAO,YACT,WAAW,QAAQ,GACnB,YAAY,QAAQ,IAEf;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEA,SAAS,mBACP,KACA,YACA,YACA,iBAA+C,WAC9B;AACjB,QAAM,iBAAa,8CAAoB,UAAU,GAC3C,WAAW,oBAAoB,GAAG,GAGlC,gBAAgB,WAAW,WAAW,GAAG,KAAK,WAAW,WAAW,QAAQ;AAElF,MAAI,gBAA+B,MAC/B,YAAiB,CAAC;AAEtB,SAAI,OAAO,iBAAkB,WAE3B,gBAAgB,gBACP,iBAAiB,OAAO,iBAAkB,YAGnD,gBACE,cAAc,YAAQ,gDAAsB,YAAY,cAAc,GACxE,YAAY,iBAGZ,oBAAgB,gDAAsB,YAAY,cAAc,GAI9D,WAAW,SAAS,CAAC,UAAU,UACjC,YAAY,EAAE,GAAG,WAAW,OAAO,WAAW,MAAM,IAI/C;AAAA,IACL,GAFY,gBAAgB,WAAW,aAAa,IAAI,CAAC;AAAA,IAGzD,GAAG;AAAA,EACL;AACF;AAGA,MAAM,sBAAsB;AAAA,EAC1B,GAAG;AAAA,EACH,GAAG;AAAA,EACH,YAAY;AAAA,EACZ,YAAY;AACd;AAEA,SAAS,SAAS,OAAwB,UAAU,IAAO;AACzD,MAAI,OAAO,SAAU;AACnB,WAAO,CAAC,KAAK;AAEf,QAAM,CAAC,GAAG,QAAQ,KAAK,IAAI,MAAM,MAAM,qBAAqB,KAAK,CAAC;AAClE,SAAO,CAAC,CAAC,QAAQ,KAAK;AACxB;",
|
|
5
|
-
"names": ["React", "res"]
|
|
6
|
-
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
|
-
return to;
|
|
10
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
11
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
12
|
-
var index_exports = {};
|
|
13
|
-
module.exports = __toCommonJS(index_exports);
|
|
14
|
-
var import_polyfill = require("./polyfill");
|
|
15
|
-
__reExport(index_exports, require("./createAnimations"), module.exports);
|
|
16
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
package/dist/cjs/polyfill.js
DELETED
package/dist/cjs/polyfill.js.map
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { normalizeTransition, getEffectiveAnimation } from "@tamagui/animation-helpers";
|
|
2
|
-
import { isWeb, useIsomorphicLayoutEffect } from "@tamagui/constants";
|
|
3
|
-
import { ResetPresence, usePresence } from "@tamagui/use-presence";
|
|
4
|
-
import { useEvent, useThemeWithState } from "@tamagui/web";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import { Animated } from "react-native-web";
|
|
7
|
-
const resolveDynamicValue = (value, isDark) => value && typeof value == "object" && "dynamic" in value ? isDark ? value.dynamic.dark : value.dynamic.light : value, animatedStyleKey = {
|
|
8
|
-
transform: !0,
|
|
9
|
-
opacity: !0
|
|
10
|
-
}, colorStyleKey = {
|
|
11
|
-
backgroundColor: !0,
|
|
12
|
-
color: !0,
|
|
13
|
-
borderColor: !0,
|
|
14
|
-
borderLeftColor: !0,
|
|
15
|
-
borderRightColor: !0,
|
|
16
|
-
borderTopColor: !0,
|
|
17
|
-
borderBottomColor: !0
|
|
18
|
-
}, costlyToAnimateStyleKey = {
|
|
19
|
-
borderRadius: !0,
|
|
20
|
-
borderTopLeftRadius: !0,
|
|
21
|
-
borderTopRightRadius: !0,
|
|
22
|
-
borderBottomLeftRadius: !0,
|
|
23
|
-
borderBottomRightRadius: !0,
|
|
24
|
-
borderWidth: !0,
|
|
25
|
-
borderLeftWidth: !0,
|
|
26
|
-
borderRightWidth: !0,
|
|
27
|
-
borderTopWidth: !0,
|
|
28
|
-
borderBottomWidth: !0,
|
|
29
|
-
...colorStyleKey
|
|
30
|
-
// TODO for other keys like height or width, it's better to not add them here till layout animations are ready
|
|
31
|
-
}, AnimatedView = Animated.View, AnimatedText = Animated.Text;
|
|
32
|
-
function useAnimatedNumber(initial) {
|
|
33
|
-
const state = React.useRef(
|
|
34
|
-
null
|
|
35
|
-
);
|
|
36
|
-
return state.current || (state.current = {
|
|
37
|
-
composite: null,
|
|
38
|
-
val: new Animated.Value(initial),
|
|
39
|
-
strategy: { type: "spring" }
|
|
40
|
-
}), {
|
|
41
|
-
getInstance() {
|
|
42
|
-
return state.current.val;
|
|
43
|
-
},
|
|
44
|
-
getValue() {
|
|
45
|
-
return state.current.val._value;
|
|
46
|
-
},
|
|
47
|
-
stop() {
|
|
48
|
-
state.current.composite?.stop(), state.current.composite = null;
|
|
49
|
-
},
|
|
50
|
-
setValue(next, { type, ...config } = { type: "spring" }, onFinish) {
|
|
51
|
-
const val = state.current.val, handleFinish = onFinish ? ({ finished }) => finished ? onFinish() : null : void 0;
|
|
52
|
-
if (type === "direct")
|
|
53
|
-
val.setValue(next);
|
|
54
|
-
else if (type === "spring") {
|
|
55
|
-
state.current.composite?.stop();
|
|
56
|
-
const composite = Animated.spring(val, {
|
|
57
|
-
...config,
|
|
58
|
-
toValue: next,
|
|
59
|
-
useNativeDriver: !isWeb
|
|
60
|
-
});
|
|
61
|
-
composite.start(handleFinish), state.current.composite = composite;
|
|
62
|
-
} else {
|
|
63
|
-
state.current.composite?.stop();
|
|
64
|
-
const composite = Animated.timing(val, {
|
|
65
|
-
...config,
|
|
66
|
-
toValue: next,
|
|
67
|
-
useNativeDriver: !isWeb
|
|
68
|
-
});
|
|
69
|
-
composite.start(handleFinish), state.current.composite = composite;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
const useAnimatedNumberReaction = ({ value }, onValue) => {
|
|
75
|
-
const onChange = useEvent((current) => {
|
|
76
|
-
onValue(current.value);
|
|
77
|
-
});
|
|
78
|
-
React.useEffect(() => {
|
|
79
|
-
const id = value.getInstance().addListener(onChange);
|
|
80
|
-
return () => {
|
|
81
|
-
value.getInstance().removeListener(id);
|
|
82
|
-
};
|
|
83
|
-
}, [value, onChange]);
|
|
84
|
-
}, useAnimatedNumberStyle = (value, getStyle) => getStyle(value.getInstance());
|
|
85
|
-
function createAnimations(animations) {
|
|
86
|
-
return {
|
|
87
|
-
isReactNative: !0,
|
|
88
|
-
inputStyle: "value",
|
|
89
|
-
outputStyle: "inline",
|
|
90
|
-
animations,
|
|
91
|
-
View: AnimatedView,
|
|
92
|
-
Text: AnimatedText,
|
|
93
|
-
useAnimatedNumber,
|
|
94
|
-
useAnimatedNumberReaction,
|
|
95
|
-
useAnimatedNumberStyle,
|
|
96
|
-
usePresence,
|
|
97
|
-
ResetPresence,
|
|
98
|
-
useAnimations: ({ props, onDidAnimate, style, componentState, presence }) => {
|
|
99
|
-
const isDisabled = isWeb && componentState.unmounted === !0, isExiting = presence?.[0] === !1, sendExitComplete = presence?.[1], [, themeState] = useThemeWithState({}), isDark = themeState?.scheme === "dark" || themeState?.name?.startsWith("dark"), animateStyles = React.useRef({}), animatedTranforms = React.useRef([]), animationsState = React.useRef(
|
|
100
|
-
/* @__PURE__ */ new WeakMap()
|
|
101
|
-
), animateOnly = props.animateOnly || [], hasTransitionOnly = !!props.animateOnly, isEntering = !!componentState.unmounted, wasEnteringRef = React.useRef(isEntering), justFinishedEntering = wasEnteringRef.current && !isEntering;
|
|
102
|
-
React.useEffect(() => {
|
|
103
|
-
wasEnteringRef.current = isEntering;
|
|
104
|
-
});
|
|
105
|
-
const args = [
|
|
106
|
-
JSON.stringify(style),
|
|
107
|
-
componentState,
|
|
108
|
-
isExiting,
|
|
109
|
-
!!onDidAnimate,
|
|
110
|
-
isDark,
|
|
111
|
-
justFinishedEntering
|
|
112
|
-
], isThereNoNativeStyleKeys = React.useMemo(() => isWeb ? !0 : Object.keys(style).some((key) => animateOnly ? !animatedStyleKey[key] && animateOnly.indexOf(key) === -1 : !animatedStyleKey[key]), args), res = React.useMemo(() => {
|
|
113
|
-
const runners = [], completions = [], animationState = isExiting ? "exit" : isEntering || justFinishedEntering ? "enter" : "default", nonAnimatedStyle = {};
|
|
114
|
-
for (const key in style) {
|
|
115
|
-
const rawVal = style[key], val = resolveDynamicValue(rawVal, isDark);
|
|
116
|
-
if (val !== void 0 && !isDisabled) {
|
|
117
|
-
if (animatedStyleKey[key] == null && !costlyToAnimateStyleKey[key]) {
|
|
118
|
-
nonAnimatedStyle[key] = val;
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if (hasTransitionOnly && !animateOnly.includes(key)) {
|
|
122
|
-
nonAnimatedStyle[key] = val;
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
if (key !== "transform") {
|
|
126
|
-
animateStyles.current[key] = update(key, animateStyles.current[key], val);
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
if (val) {
|
|
130
|
-
if (typeof val == "string") {
|
|
131
|
-
console.warn("Warning: Tamagui can't animate string transforms yet!");
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
for (const [index, transform] of val.entries()) {
|
|
135
|
-
if (!transform) continue;
|
|
136
|
-
const tkey = Object.keys(transform)[0], currentTransform = animatedTranforms.current[index]?.[tkey];
|
|
137
|
-
animatedTranforms.current[index] = {
|
|
138
|
-
[tkey]: update(tkey, currentTransform, transform[tkey])
|
|
139
|
-
}, animatedTranforms.current = [...animatedTranforms.current];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const animatedStyle = {
|
|
145
|
-
...Object.fromEntries(
|
|
146
|
-
Object.entries(animateStyles.current).map(([k, v]) => [
|
|
147
|
-
k,
|
|
148
|
-
animationsState.current.get(v)?.interpolation || v
|
|
149
|
-
])
|
|
150
|
-
),
|
|
151
|
-
transform: animatedTranforms.current.map((r) => {
|
|
152
|
-
const key = Object.keys(r)[0], val = animationsState.current.get(r[key])?.interpolation || r[key];
|
|
153
|
-
return { [key]: val };
|
|
154
|
-
})
|
|
155
|
-
};
|
|
156
|
-
return {
|
|
157
|
-
runners,
|
|
158
|
-
completions,
|
|
159
|
-
style: [nonAnimatedStyle, animatedStyle]
|
|
160
|
-
};
|
|
161
|
-
function update(key, animated, valIn) {
|
|
162
|
-
const isColorStyleKey = colorStyleKey[key], [val, type] = isColorStyleKey ? [0, void 0] : getValue(valIn);
|
|
163
|
-
let animateToValue = val;
|
|
164
|
-
const value = animated || new Animated.Value(val), curInterpolation = animationsState.current.get(value);
|
|
165
|
-
let interpolateArgs;
|
|
166
|
-
if (type && (interpolateArgs = getInterpolated(
|
|
167
|
-
curInterpolation?.current ?? value._value,
|
|
168
|
-
val,
|
|
169
|
-
type
|
|
170
|
-
), animationsState.current.set(value, {
|
|
171
|
-
interpolation: value.interpolate(interpolateArgs),
|
|
172
|
-
current: val
|
|
173
|
-
})), isColorStyleKey && (animateToValue = curInterpolation?.animateToValue ? 0 : 1, interpolateArgs = getColorInterpolated(
|
|
174
|
-
curInterpolation?.current,
|
|
175
|
-
// valIn is the next color
|
|
176
|
-
valIn,
|
|
177
|
-
animateToValue
|
|
178
|
-
), animationsState.current.set(value, {
|
|
179
|
-
current: valIn,
|
|
180
|
-
interpolation: value.interpolate(interpolateArgs),
|
|
181
|
-
animateToValue: curInterpolation?.animateToValue ? 0 : 1
|
|
182
|
-
})), value) {
|
|
183
|
-
const animationConfig = getAnimationConfig(
|
|
184
|
-
key,
|
|
185
|
-
animations,
|
|
186
|
-
props.transition,
|
|
187
|
-
animationState
|
|
188
|
-
);
|
|
189
|
-
let resolve;
|
|
190
|
-
const promise = new Promise((res2) => {
|
|
191
|
-
resolve = res2;
|
|
192
|
-
});
|
|
193
|
-
completions.push(promise), runners.push(() => {
|
|
194
|
-
value.stopAnimation();
|
|
195
|
-
function getAnimation() {
|
|
196
|
-
return Animated[animationConfig.type || "spring"](value, {
|
|
197
|
-
toValue: animateToValue,
|
|
198
|
-
useNativeDriver: !isWeb && !isThereNoNativeStyleKeys,
|
|
199
|
-
...animationConfig
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
(animationConfig.delay ? Animated.sequence([
|
|
203
|
-
Animated.delay(animationConfig.delay),
|
|
204
|
-
getAnimation()
|
|
205
|
-
]) : getAnimation()).start(({ finished }) => {
|
|
206
|
-
finished && resolve();
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
return process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info(
|
|
211
|
-
" \u{1F4A0} animate",
|
|
212
|
-
key,
|
|
213
|
-
`from (${value._value}) to`,
|
|
214
|
-
valIn,
|
|
215
|
-
`(${val})`,
|
|
216
|
-
"type",
|
|
217
|
-
type,
|
|
218
|
-
"interpolate",
|
|
219
|
-
interpolateArgs
|
|
220
|
-
), value;
|
|
221
|
-
}
|
|
222
|
-
}, args);
|
|
223
|
-
return useIsomorphicLayoutEffect(() => {
|
|
224
|
-
res.runners.forEach((r) => r());
|
|
225
|
-
let cancel = !1;
|
|
226
|
-
return Promise.all(res.completions).then(() => {
|
|
227
|
-
cancel || (onDidAnimate?.(), isExiting && sendExitComplete?.());
|
|
228
|
-
}), () => {
|
|
229
|
-
cancel = !0;
|
|
230
|
-
};
|
|
231
|
-
}, args), process.env.NODE_ENV === "development" && props.debug === "verbose" && console.info("Animated", { response: res, inputStyle: style, isExiting }), res;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
function getColorInterpolated(currentColor, nextColor, animateToValue) {
|
|
236
|
-
const inputRange = [0, 1], outputRange = [currentColor || nextColor, nextColor];
|
|
237
|
-
return animateToValue === 0 && outputRange.reverse(), {
|
|
238
|
-
inputRange,
|
|
239
|
-
outputRange
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
function getInterpolated(current, next, postfix = "deg") {
|
|
243
|
-
next === current && (current = next - 1e-9);
|
|
244
|
-
const inputRange = [current, next], outputRange = [`${current}${postfix}`, `${next}${postfix}`];
|
|
245
|
-
return next < current && (inputRange.reverse(), outputRange.reverse()), {
|
|
246
|
-
inputRange,
|
|
247
|
-
outputRange
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function getAnimationConfig(key, animations, transition, animationState = "default") {
|
|
251
|
-
const normalized = normalizeTransition(transition), shortKey = transformShorthands[key], propAnimation = normalized.properties[key] ?? normalized.properties[shortKey];
|
|
252
|
-
let animationType = null, extraConf = {};
|
|
253
|
-
return typeof propAnimation == "string" ? animationType = propAnimation : propAnimation && typeof propAnimation == "object" ? (animationType = propAnimation.type || getEffectiveAnimation(normalized, animationState), extraConf = propAnimation) : animationType = getEffectiveAnimation(normalized, animationState), normalized.delay && !extraConf.delay && (extraConf = { ...extraConf, delay: normalized.delay }), {
|
|
254
|
-
...animationType ? animations[animationType] : {},
|
|
255
|
-
...extraConf
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
const transformShorthands = {
|
|
259
|
-
x: "translateX",
|
|
260
|
-
y: "translateY",
|
|
261
|
-
translateX: "x",
|
|
262
|
-
translateY: "y"
|
|
263
|
-
};
|
|
264
|
-
function getValue(input, isColor = !1) {
|
|
265
|
-
if (typeof input != "string")
|
|
266
|
-
return [input];
|
|
267
|
-
const [_, number, after] = input.match(/([-0-9]+)(deg|%|px)/) ?? [];
|
|
268
|
-
return [+number, after];
|
|
269
|
-
}
|
|
270
|
-
export {
|
|
271
|
-
AnimatedText,
|
|
272
|
-
AnimatedView,
|
|
273
|
-
createAnimations,
|
|
274
|
-
useAnimatedNumber,
|
|
275
|
-
useAnimatedNumberReaction,
|
|
276
|
-
useAnimatedNumberStyle
|
|
277
|
-
};
|
|
278
|
-
//# sourceMappingURL=createAnimations.js.map
|