react-native-bootsplash 5.5.2 → 6.0.0-beta.0

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/src/index.ts CHANGED
@@ -29,6 +29,7 @@ export type Manifest = {
29
29
 
30
30
  export type UseHideAnimationConfig = {
31
31
  manifest: Manifest;
32
+ ready?: boolean;
32
33
 
33
34
  logo?: ImageRequireSource;
34
35
  darkLogo?: ImageRequireSource;
@@ -59,6 +60,7 @@ export function isVisible(): Promise<boolean> {
59
60
  export function useHideAnimation(config: UseHideAnimationConfig) {
60
61
  const {
61
62
  manifest,
63
+ ready = true,
62
64
 
63
65
  logo: logoSrc,
64
66
  darkLogo: darkLogoSrc,
@@ -106,31 +108,39 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
106
108
  ? darkBrandSrc
107
109
  : brandSrc;
108
110
 
109
- const animateFn = useRef(animate);
110
- const layoutReady = useRef(false);
111
- const logoReady = useRef(skipLogo);
112
- const brandReady = useRef(skipBrand);
113
- const animateHasBeenCalled = useRef(false);
111
+ const ref = useRef({
112
+ layoutReady: false,
113
+ logoReady: skipLogo,
114
+ brandReady: skipBrand,
115
+ userReady: ready,
114
116
 
115
- useEffect(() => {
116
- animateFn.current = animate;
117
+ animate,
118
+ animateHasBeenCalled: false,
117
119
  });
118
120
 
119
121
  const maybeRunAnimate = useCallback(() => {
120
122
  if (
121
- layoutReady.current &&
122
- logoReady.current &&
123
- brandReady.current &&
124
- !animateHasBeenCalled.current
123
+ ref.current.layoutReady &&
124
+ ref.current.logoReady &&
125
+ ref.current.brandReady &&
126
+ ref.current.userReady &&
127
+ !ref.current.animateHasBeenCalled
125
128
  ) {
126
- animateHasBeenCalled.current = true;
129
+ ref.current.animateHasBeenCalled = true;
127
130
 
128
131
  hide({ fade: false })
129
- .then(() => animateFn.current())
132
+ .then(() => ref.current.animate())
130
133
  .catch(() => {});
131
134
  }
132
135
  }, []);
133
136
 
137
+ useEffect(() => {
138
+ ref.current.animate = animate;
139
+ ref.current.userReady = ready;
140
+
141
+ maybeRunAnimate();
142
+ });
143
+
134
144
  return useMemo<UseHideAnimation>(() => {
135
145
  const containerStyle: ViewStyle = {
136
146
  ...StyleSheet.absoluteFillObject,
@@ -142,7 +152,7 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
142
152
  const container: ViewProps = {
143
153
  style: containerStyle,
144
154
  onLayout: () => {
145
- layoutReady.current = true;
155
+ ref.current.layoutReady = true;
146
156
  maybeRunAnimate();
147
157
  },
148
158
  };
@@ -159,7 +169,7 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
159
169
  height: logoHeight,
160
170
  },
161
171
  onLoadEnd: () => {
162
- logoReady.current = true;
172
+ ref.current.logoReady = true;
163
173
  maybeRunAnimate();
164
174
  },
165
175
  };
@@ -178,7 +188,7 @@ export function useHideAnimation(config: UseHideAnimationConfig) {
178
188
  height: brandHeight,
179
189
  },
180
190
  onLoadEnd: () => {
181
- brandReady.current = true;
191
+ ref.current.brandReady = true;
182
192
  maybeRunAnimate();
183
193
  },
184
194
  };