@william-callao/antonella-animations 1.0.0 → 1.0.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/dist/index.d.ts +42 -7
- package/dist/index.js +54 -23
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import React from 'react';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
4
3
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import { FadeIn as FadeIn$1, FadeInDown, FadeInUp, SlideInRight, ZoomIn, FadeOut, SlideOutRight } from 'react-native-reanimated';
|
|
5
|
+
import * as react_native_reanimated_lib_typescript_hook_commonTypes from 'react-native-reanimated/lib/typescript/hook/commonTypes';
|
|
6
|
+
|
|
7
|
+
type FadeInProps = {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
/** Cambia para remontar y re-lanzar el fade (p. ej. el id de la selección actual). */
|
|
10
|
+
contentKey?: string | number;
|
|
11
|
+
/** Duración (ms) del fade. Default 280. */
|
|
12
|
+
duration?: number;
|
|
13
|
+
/** Opacidad inicial. Default 0. Usar 1 para desactivar el fade. */
|
|
14
|
+
initialOpacity?: number;
|
|
15
|
+
style?: StyleProp<ViewStyle>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Wrapper de fade de entrada 0->1 (hook-driven, ver `useFadeIn`). Al cambiar
|
|
19
|
+
* `contentKey` el contenido se remonta y la animación vuelve a correr.
|
|
20
|
+
*/
|
|
21
|
+
declare function FadeIn({ children, contentKey, duration, initialOpacity, style, }: FadeInProps): React.JSX.Element;
|
|
5
22
|
|
|
6
23
|
declare const entering: {
|
|
7
|
-
readonly fade: FadeIn;
|
|
24
|
+
readonly fade: FadeIn$1;
|
|
8
25
|
readonly fadeInDown: FadeInDown;
|
|
9
26
|
readonly fadeInUp: FadeInUp;
|
|
10
27
|
readonly slideRight: SlideInRight;
|
|
@@ -17,7 +34,7 @@ declare const exiting: {
|
|
|
17
34
|
declare function staggeredFadeInDown(index: number, step?: number, duration?: number): FadeInDown;
|
|
18
35
|
|
|
19
36
|
type TransitionViewProps = {
|
|
20
|
-
children:
|
|
37
|
+
children: React__default.ReactNode;
|
|
21
38
|
/**
|
|
22
39
|
* Cambia cuando el contenido cambia estructuralmente (p. ej. `contentKey={step}`).
|
|
23
40
|
* Al cambiar, el contenido se remonta y entra con fade in desde opacity 0 (sin parpadeos).
|
|
@@ -37,6 +54,24 @@ type TransitionViewProps = {
|
|
|
37
54
|
* thread; el fade lo maneja Reanimated (layout animations entering/exiting)
|
|
38
55
|
* desde el primer frame.
|
|
39
56
|
*/
|
|
40
|
-
declare function TransitionView({ children, contentKey, duration, fadeDuration, style, }: TransitionViewProps):
|
|
57
|
+
declare function TransitionView({ children, contentKey, duration, fadeDuration, style, }: TransitionViewProps): React__default.JSX.Element;
|
|
58
|
+
|
|
59
|
+
type UseFadeInOptions = {
|
|
60
|
+
/** Duración (ms) del fade. Default 280. */
|
|
61
|
+
duration?: number;
|
|
62
|
+
/** Opacidad inicial. Default 0. Usar 1 para desactivar el fade. */
|
|
63
|
+
initialOpacity?: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Fade de entrada controlado por hook (opacity inicial -> 1 al montar), en el
|
|
67
|
+
* UI thread. Se prefiere sobre las animaciones `entering` de Reanimated para
|
|
68
|
+
* contenidos que viven en slots del layout que se montan/remontan (p. ej. el
|
|
69
|
+
* AppLayout), donde `entering` se degrada o re-arranca en 0 y deja el texto
|
|
70
|
+
* invisible por unos frames. Devuelve un `useAnimatedStyle` para aplicar a un
|
|
71
|
+
* `Animated.View`.
|
|
72
|
+
*/
|
|
73
|
+
declare function useFadeIn({ duration, initialOpacity }?: UseFadeInOptions): react_native_reanimated_lib_typescript_hook_commonTypes.AnimatedStyleHandle<{
|
|
74
|
+
opacity: number;
|
|
75
|
+
}>;
|
|
41
76
|
|
|
42
|
-
export { TransitionView, type TransitionViewProps, entering, exiting, staggeredFadeInDown };
|
|
77
|
+
export { FadeIn, type FadeInProps, TransitionView, type TransitionViewProps, type UseFadeInOptions, entering, exiting, staggeredFadeInDown, useFadeIn };
|
package/dist/index.js
CHANGED
|
@@ -30,37 +30,66 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
FadeIn: () => FadeIn,
|
|
33
34
|
TransitionView: () => TransitionView,
|
|
34
35
|
entering: () => entering,
|
|
35
36
|
exiting: () => exiting,
|
|
36
|
-
staggeredFadeInDown: () => staggeredFadeInDown
|
|
37
|
+
staggeredFadeInDown: () => staggeredFadeInDown,
|
|
38
|
+
useFadeIn: () => useFadeIn
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(index_exports);
|
|
39
41
|
|
|
40
|
-
// src/
|
|
42
|
+
// src/FadeIn.tsx
|
|
43
|
+
var import_react_native_reanimated2 = __toESM(require("react-native-reanimated"));
|
|
44
|
+
|
|
45
|
+
// src/useFadeIn.ts
|
|
46
|
+
var import_react = require("react");
|
|
41
47
|
var import_react_native_reanimated = require("react-native-reanimated");
|
|
48
|
+
function useFadeIn({ duration = 280, initialOpacity = 0 } = {}) {
|
|
49
|
+
const opacity = (0, import_react_native_reanimated.useSharedValue)(initialOpacity);
|
|
50
|
+
(0, import_react.useEffect)(() => {
|
|
51
|
+
opacity.value = (0, import_react_native_reanimated.withTiming)(1, { duration });
|
|
52
|
+
}, [opacity, duration]);
|
|
53
|
+
return (0, import_react_native_reanimated.useAnimatedStyle)(() => ({ opacity: opacity.value }));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/FadeIn.tsx
|
|
57
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
58
|
+
function FadeIn({
|
|
59
|
+
children,
|
|
60
|
+
contentKey,
|
|
61
|
+
duration = 280,
|
|
62
|
+
initialOpacity = 0,
|
|
63
|
+
style
|
|
64
|
+
}) {
|
|
65
|
+
const fadeStyle = useFadeIn({ duration, initialOpacity });
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_reanimated2.default.View, { style: [fadeStyle, style], children }, contentKey);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/presets.ts
|
|
70
|
+
var import_react_native_reanimated3 = require("react-native-reanimated");
|
|
42
71
|
var entering = {
|
|
43
|
-
fade:
|
|
44
|
-
fadeInDown:
|
|
45
|
-
fadeInUp:
|
|
46
|
-
slideRight:
|
|
47
|
-
zoom:
|
|
72
|
+
fade: import_react_native_reanimated3.FadeIn.duration(150),
|
|
73
|
+
fadeInDown: import_react_native_reanimated3.FadeInDown.duration(180),
|
|
74
|
+
fadeInUp: import_react_native_reanimated3.FadeInUp.duration(180),
|
|
75
|
+
slideRight: import_react_native_reanimated3.SlideInRight.duration(180),
|
|
76
|
+
zoom: import_react_native_reanimated3.ZoomIn.duration(150)
|
|
48
77
|
};
|
|
49
78
|
var exiting = {
|
|
50
|
-
fade:
|
|
51
|
-
slideRight:
|
|
79
|
+
fade: import_react_native_reanimated3.FadeOut.duration(150),
|
|
80
|
+
slideRight: import_react_native_reanimated3.SlideOutRight.duration(150)
|
|
52
81
|
};
|
|
53
82
|
function staggeredFadeInDown(index, step = 15, duration = 180) {
|
|
54
83
|
const maxDelay = 120;
|
|
55
84
|
const delay = Math.min(index * step, maxDelay);
|
|
56
|
-
return
|
|
85
|
+
return import_react_native_reanimated3.FadeInDown.duration(duration).delay(delay);
|
|
57
86
|
}
|
|
58
87
|
|
|
59
88
|
// src/TransitionView.tsx
|
|
60
|
-
var
|
|
89
|
+
var import_react2 = require("react");
|
|
61
90
|
var import_react_native = require("react-native");
|
|
62
|
-
var
|
|
63
|
-
var
|
|
91
|
+
var import_react_native_reanimated4 = __toESM(require("react-native-reanimated"));
|
|
92
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
64
93
|
function TransitionView({
|
|
65
94
|
children,
|
|
66
95
|
contentKey,
|
|
@@ -68,26 +97,26 @@ function TransitionView({
|
|
|
68
97
|
fadeDuration = 150,
|
|
69
98
|
style
|
|
70
99
|
}) {
|
|
71
|
-
const animatedHeight = (0,
|
|
72
|
-
const onContentLayout = (0,
|
|
100
|
+
const animatedHeight = (0, import_react_native_reanimated4.useSharedValue)(0);
|
|
101
|
+
const onContentLayout = (0, import_react2.useCallback)(
|
|
73
102
|
(event) => {
|
|
74
103
|
const { height } = event.nativeEvent.layout;
|
|
75
104
|
if (height === animatedHeight.value) return;
|
|
76
|
-
animatedHeight.value = (0,
|
|
105
|
+
animatedHeight.value = (0, import_react_native_reanimated4.withTiming)(height, {
|
|
77
106
|
duration,
|
|
78
|
-
easing:
|
|
107
|
+
easing: import_react_native_reanimated4.Easing.out(import_react_native_reanimated4.Easing.quad)
|
|
79
108
|
});
|
|
80
109
|
},
|
|
81
110
|
[animatedHeight, duration]
|
|
82
111
|
);
|
|
83
|
-
const containerStyle = (0,
|
|
112
|
+
const containerStyle = (0, import_react_native_reanimated4.useAnimatedStyle)(() => ({
|
|
84
113
|
height: animatedHeight.value
|
|
85
114
|
}));
|
|
86
|
-
return /* @__PURE__ */ (0,
|
|
87
|
-
|
|
115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native_reanimated4.default.View, { style: [styles.container, containerStyle, style], children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native.View, { style: styles.content, onLayout: onContentLayout, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
116
|
+
import_react_native_reanimated4.default.View,
|
|
88
117
|
{
|
|
89
|
-
entering:
|
|
90
|
-
exiting:
|
|
118
|
+
entering: import_react_native_reanimated4.FadeIn.duration(fadeDuration),
|
|
119
|
+
exiting: import_react_native_reanimated4.FadeOut.duration(fadeDuration),
|
|
91
120
|
children
|
|
92
121
|
},
|
|
93
122
|
contentKey
|
|
@@ -106,8 +135,10 @@ var styles = import_react_native.StyleSheet.create({
|
|
|
106
135
|
});
|
|
107
136
|
// Annotate the CommonJS export names for ESM import in node:
|
|
108
137
|
0 && (module.exports = {
|
|
138
|
+
FadeIn,
|
|
109
139
|
TransitionView,
|
|
110
140
|
entering,
|
|
111
141
|
exiting,
|
|
112
|
-
staggeredFadeInDown
|
|
142
|
+
staggeredFadeInDown,
|
|
143
|
+
useFadeIn
|
|
113
144
|
});
|