@hua-labs/motion-core 2.2.3 → 2.4.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/README.md +128 -39
- package/dist/chunk-47QAGQLN.mjs +1057 -0
- package/dist/chunk-47QAGQLN.mjs.map +1 -0
- package/dist/chunk-LSIP7MB5.cjs +1090 -0
- package/dist/chunk-LSIP7MB5.cjs.map +1 -0
- package/dist/index.cjs +7532 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +834 -642
- package/dist/index.d.ts +834 -642
- package/dist/index.mjs +4393 -1744
- package/dist/index.mjs.map +1 -1
- package/dist/native.cjs +692 -0
- package/dist/native.cjs.map +1 -0
- package/dist/native.d.mts +177 -0
- package/dist/native.d.ts +177 -0
- package/dist/native.mjs +555 -0
- package/dist/native.mjs.map +1 -0
- package/dist/springPhysics-DLyZ4nbx.d.mts +687 -0
- package/dist/springPhysics-DLyZ4nbx.d.ts +687 -0
- package/package.json +31 -11
- package/dist/index.js +0 -4756
- package/dist/index.js.map +0 -1
package/dist/native.mjs
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMotionProfile, easeOut, getEasing, easeInOut } from './chunk-47QAGQLN.mjs';
|
|
3
|
+
export { MOTION_PRESETS, MotionEngine, MotionProfileProvider, MotionStateManager, PAGE_MOTIONS, TransitionEffects, applyEasing, calculateSpring, easeIn, easeInOut, easeInOutQuad, easeInQuad, easeOut, easeOutQuad, easingPresets, getAvailableEasings, getEasing, getMotionPreset, getPagePreset, getPresetEasing, hua, isEasingFunction, isValidEasing, linear, mergeProfileOverrides, mergeWithPreset, motionEngine, neutral, resolveProfile, safeApplyEasing, transitionEffects, useMotionProfile } from './chunk-47QAGQLN.mjs';
|
|
4
|
+
import { useRef, useState, useCallback, useEffect, useMemo } from 'react';
|
|
5
|
+
import { Animated } from 'react-native';
|
|
6
|
+
|
|
7
|
+
function useFadeIn(options = {}) {
|
|
8
|
+
const profile = useMotionProfile();
|
|
9
|
+
const {
|
|
10
|
+
duration = profile.base.duration,
|
|
11
|
+
delay = 0,
|
|
12
|
+
easing = getEasing(profile.base.easing) || easeOut,
|
|
13
|
+
autoStart = true,
|
|
14
|
+
useNativeDriver = true,
|
|
15
|
+
initialOpacity = profile.entrance.fade.initialOpacity,
|
|
16
|
+
targetOpacity = 1,
|
|
17
|
+
onComplete,
|
|
18
|
+
onStart
|
|
19
|
+
} = options;
|
|
20
|
+
const opacity = useRef(new Animated.Value(initialOpacity)).current;
|
|
21
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
22
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
23
|
+
const [progress, setProgress] = useState(0);
|
|
24
|
+
const animRef = useRef(null);
|
|
25
|
+
const start = useCallback(() => {
|
|
26
|
+
if (isAnimating) return;
|
|
27
|
+
setIsAnimating(true);
|
|
28
|
+
onStart?.();
|
|
29
|
+
animRef.current = Animated.timing(opacity, {
|
|
30
|
+
toValue: targetOpacity,
|
|
31
|
+
duration,
|
|
32
|
+
delay,
|
|
33
|
+
easing,
|
|
34
|
+
useNativeDriver
|
|
35
|
+
});
|
|
36
|
+
animRef.current.start(({ finished }) => {
|
|
37
|
+
if (finished) {
|
|
38
|
+
setIsVisible(true);
|
|
39
|
+
setIsAnimating(false);
|
|
40
|
+
setProgress(1);
|
|
41
|
+
onComplete?.();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}, [opacity, duration, delay, easing, useNativeDriver, targetOpacity, isAnimating, onStart, onComplete]);
|
|
45
|
+
const stop = useCallback(() => {
|
|
46
|
+
animRef.current?.stop();
|
|
47
|
+
setIsAnimating(false);
|
|
48
|
+
}, []);
|
|
49
|
+
const reset = useCallback(() => {
|
|
50
|
+
animRef.current?.stop();
|
|
51
|
+
opacity.setValue(initialOpacity);
|
|
52
|
+
setIsAnimating(false);
|
|
53
|
+
setIsVisible(false);
|
|
54
|
+
setProgress(0);
|
|
55
|
+
}, [opacity, initialOpacity]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (autoStart) start();
|
|
58
|
+
}, []);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
return () => {
|
|
61
|
+
animRef.current?.stop();
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
return {
|
|
65
|
+
style: { opacity },
|
|
66
|
+
isVisible,
|
|
67
|
+
isAnimating,
|
|
68
|
+
progress,
|
|
69
|
+
start,
|
|
70
|
+
stop,
|
|
71
|
+
reset
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function useSlideBase(direction, options = {}) {
|
|
75
|
+
const profile = useMotionProfile();
|
|
76
|
+
const {
|
|
77
|
+
duration = profile.base.duration,
|
|
78
|
+
delay = 0,
|
|
79
|
+
easing = getEasing(profile.entrance.slide.easing) || easeOut,
|
|
80
|
+
distance = profile.entrance.slide.distance,
|
|
81
|
+
autoStart = true,
|
|
82
|
+
useNativeDriver = true,
|
|
83
|
+
onComplete,
|
|
84
|
+
onStart
|
|
85
|
+
} = options;
|
|
86
|
+
const isVertical = direction === "up" || direction === "down";
|
|
87
|
+
const sign = direction === "up" || direction === "left" ? 1 : -1;
|
|
88
|
+
const initialValue = sign * distance;
|
|
89
|
+
const translate = useRef(new Animated.Value(initialValue)).current;
|
|
90
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
91
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
92
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
93
|
+
const [progress, setProgress] = useState(0);
|
|
94
|
+
const animRef = useRef(null);
|
|
95
|
+
const start = useCallback(() => {
|
|
96
|
+
if (isAnimating) return;
|
|
97
|
+
setIsAnimating(true);
|
|
98
|
+
onStart?.();
|
|
99
|
+
animRef.current = Animated.parallel([
|
|
100
|
+
Animated.timing(translate, {
|
|
101
|
+
toValue: 0,
|
|
102
|
+
duration,
|
|
103
|
+
delay,
|
|
104
|
+
easing,
|
|
105
|
+
useNativeDriver
|
|
106
|
+
}),
|
|
107
|
+
Animated.timing(opacity, {
|
|
108
|
+
toValue: 1,
|
|
109
|
+
duration,
|
|
110
|
+
delay,
|
|
111
|
+
easing,
|
|
112
|
+
useNativeDriver
|
|
113
|
+
})
|
|
114
|
+
]);
|
|
115
|
+
animRef.current.start(({ finished }) => {
|
|
116
|
+
if (finished) {
|
|
117
|
+
setIsVisible(true);
|
|
118
|
+
setIsAnimating(false);
|
|
119
|
+
setProgress(1);
|
|
120
|
+
onComplete?.();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}, [translate, opacity, duration, delay, easing, useNativeDriver, isAnimating, onStart, onComplete]);
|
|
124
|
+
const stop = useCallback(() => {
|
|
125
|
+
animRef.current?.stop();
|
|
126
|
+
setIsAnimating(false);
|
|
127
|
+
}, []);
|
|
128
|
+
const reset = useCallback(() => {
|
|
129
|
+
animRef.current?.stop();
|
|
130
|
+
translate.setValue(initialValue);
|
|
131
|
+
opacity.setValue(0);
|
|
132
|
+
setIsAnimating(false);
|
|
133
|
+
setIsVisible(false);
|
|
134
|
+
setProgress(0);
|
|
135
|
+
}, [translate, opacity, initialValue]);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (autoStart) start();
|
|
138
|
+
}, []);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
return () => {
|
|
141
|
+
animRef.current?.stop();
|
|
142
|
+
};
|
|
143
|
+
}, []);
|
|
144
|
+
const style = isVertical ? { opacity, transform: [{ translateY: translate }] } : { opacity, transform: [{ translateX: translate }] };
|
|
145
|
+
return {
|
|
146
|
+
style,
|
|
147
|
+
isVisible,
|
|
148
|
+
isAnimating,
|
|
149
|
+
progress,
|
|
150
|
+
start,
|
|
151
|
+
stop,
|
|
152
|
+
reset
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function useSlideUp(options = {}) {
|
|
156
|
+
return useSlideBase("up", options);
|
|
157
|
+
}
|
|
158
|
+
function useSlideDown(options = {}) {
|
|
159
|
+
return useSlideBase("down", options);
|
|
160
|
+
}
|
|
161
|
+
function useSlideLeft(options = {}) {
|
|
162
|
+
return useSlideBase("left", options);
|
|
163
|
+
}
|
|
164
|
+
function useSlideRight(options = {}) {
|
|
165
|
+
return useSlideBase("right", options);
|
|
166
|
+
}
|
|
167
|
+
function useScaleIn(options = {}) {
|
|
168
|
+
const profile = useMotionProfile();
|
|
169
|
+
const {
|
|
170
|
+
duration = profile.base.duration,
|
|
171
|
+
delay = 0,
|
|
172
|
+
easing = getEasing(profile.base.easing) || easeOut,
|
|
173
|
+
autoStart = true,
|
|
174
|
+
useNativeDriver = true,
|
|
175
|
+
initialScale = profile.entrance.scale.from,
|
|
176
|
+
targetScale = 1,
|
|
177
|
+
onComplete,
|
|
178
|
+
onStart
|
|
179
|
+
} = options;
|
|
180
|
+
const scale = useRef(new Animated.Value(initialScale)).current;
|
|
181
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
182
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
183
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
184
|
+
const [progress, setProgress] = useState(0);
|
|
185
|
+
const animRef = useRef(null);
|
|
186
|
+
const start = useCallback(() => {
|
|
187
|
+
if (isAnimating) return;
|
|
188
|
+
setIsAnimating(true);
|
|
189
|
+
onStart?.();
|
|
190
|
+
animRef.current = Animated.parallel([
|
|
191
|
+
Animated.timing(scale, {
|
|
192
|
+
toValue: targetScale,
|
|
193
|
+
duration,
|
|
194
|
+
delay,
|
|
195
|
+
easing,
|
|
196
|
+
useNativeDriver
|
|
197
|
+
}),
|
|
198
|
+
Animated.timing(opacity, {
|
|
199
|
+
toValue: 1,
|
|
200
|
+
duration,
|
|
201
|
+
delay,
|
|
202
|
+
easing,
|
|
203
|
+
useNativeDriver
|
|
204
|
+
})
|
|
205
|
+
]);
|
|
206
|
+
animRef.current.start(({ finished }) => {
|
|
207
|
+
if (finished) {
|
|
208
|
+
setIsVisible(true);
|
|
209
|
+
setIsAnimating(false);
|
|
210
|
+
setProgress(1);
|
|
211
|
+
onComplete?.();
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}, [scale, opacity, duration, delay, easing, useNativeDriver, targetScale, isAnimating, onStart, onComplete]);
|
|
215
|
+
const stop = useCallback(() => {
|
|
216
|
+
animRef.current?.stop();
|
|
217
|
+
setIsAnimating(false);
|
|
218
|
+
}, []);
|
|
219
|
+
const reset = useCallback(() => {
|
|
220
|
+
animRef.current?.stop();
|
|
221
|
+
scale.setValue(initialScale);
|
|
222
|
+
opacity.setValue(0);
|
|
223
|
+
setIsAnimating(false);
|
|
224
|
+
setIsVisible(false);
|
|
225
|
+
setProgress(0);
|
|
226
|
+
}, [scale, opacity, initialScale]);
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (autoStart) start();
|
|
229
|
+
}, []);
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
return () => {
|
|
232
|
+
animRef.current?.stop();
|
|
233
|
+
};
|
|
234
|
+
}, []);
|
|
235
|
+
return {
|
|
236
|
+
style: {
|
|
237
|
+
opacity,
|
|
238
|
+
transform: [{ scale }]
|
|
239
|
+
},
|
|
240
|
+
isVisible,
|
|
241
|
+
isAnimating,
|
|
242
|
+
progress,
|
|
243
|
+
start,
|
|
244
|
+
stop,
|
|
245
|
+
reset
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function useBounceIn(options = {}) {
|
|
249
|
+
useMotionProfile();
|
|
250
|
+
const {
|
|
251
|
+
delay = 0,
|
|
252
|
+
autoStart = true,
|
|
253
|
+
useNativeDriver = true,
|
|
254
|
+
initialScale = 0.3,
|
|
255
|
+
friction = 4,
|
|
256
|
+
tension = 80,
|
|
257
|
+
onComplete,
|
|
258
|
+
onStart
|
|
259
|
+
} = options;
|
|
260
|
+
const scale = useRef(new Animated.Value(initialScale)).current;
|
|
261
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
262
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
263
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
264
|
+
const [progress, setProgress] = useState(0);
|
|
265
|
+
const animRef = useRef(null);
|
|
266
|
+
const start = useCallback(() => {
|
|
267
|
+
if (isAnimating) return;
|
|
268
|
+
setIsAnimating(true);
|
|
269
|
+
onStart?.();
|
|
270
|
+
animRef.current = Animated.parallel([
|
|
271
|
+
Animated.spring(scale, {
|
|
272
|
+
toValue: 1,
|
|
273
|
+
friction,
|
|
274
|
+
tension,
|
|
275
|
+
useNativeDriver,
|
|
276
|
+
delay
|
|
277
|
+
}),
|
|
278
|
+
Animated.timing(opacity, {
|
|
279
|
+
toValue: 1,
|
|
280
|
+
duration: 200,
|
|
281
|
+
delay,
|
|
282
|
+
useNativeDriver
|
|
283
|
+
})
|
|
284
|
+
]);
|
|
285
|
+
animRef.current.start(({ finished }) => {
|
|
286
|
+
if (finished) {
|
|
287
|
+
setIsVisible(true);
|
|
288
|
+
setIsAnimating(false);
|
|
289
|
+
setProgress(1);
|
|
290
|
+
onComplete?.();
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}, [scale, opacity, friction, tension, delay, useNativeDriver, isAnimating, onStart, onComplete]);
|
|
294
|
+
const stop = useCallback(() => {
|
|
295
|
+
animRef.current?.stop();
|
|
296
|
+
setIsAnimating(false);
|
|
297
|
+
}, []);
|
|
298
|
+
const reset = useCallback(() => {
|
|
299
|
+
animRef.current?.stop();
|
|
300
|
+
scale.setValue(initialScale);
|
|
301
|
+
opacity.setValue(0);
|
|
302
|
+
setIsAnimating(false);
|
|
303
|
+
setIsVisible(false);
|
|
304
|
+
setProgress(0);
|
|
305
|
+
}, [scale, opacity, initialScale]);
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
if (autoStart) start();
|
|
308
|
+
}, []);
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
return () => {
|
|
311
|
+
animRef.current?.stop();
|
|
312
|
+
};
|
|
313
|
+
}, []);
|
|
314
|
+
return {
|
|
315
|
+
style: {
|
|
316
|
+
opacity,
|
|
317
|
+
transform: [{ scale }]
|
|
318
|
+
},
|
|
319
|
+
isVisible,
|
|
320
|
+
isAnimating,
|
|
321
|
+
progress,
|
|
322
|
+
start,
|
|
323
|
+
stop,
|
|
324
|
+
reset
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function useSpringMotion(options) {
|
|
328
|
+
const profile = useMotionProfile();
|
|
329
|
+
const {
|
|
330
|
+
from,
|
|
331
|
+
to,
|
|
332
|
+
friction = Math.sqrt(4 * profile.spring.mass * profile.spring.stiffness) / (2 * profile.spring.damping) * 10 || 26,
|
|
333
|
+
tension = profile.spring.stiffness / 2 || 170,
|
|
334
|
+
autoStart = true,
|
|
335
|
+
useNativeDriver = true,
|
|
336
|
+
enabled = true,
|
|
337
|
+
onComplete,
|
|
338
|
+
onStart
|
|
339
|
+
} = options;
|
|
340
|
+
const value = useRef(new Animated.Value(from)).current;
|
|
341
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
342
|
+
const animRef = useRef(null);
|
|
343
|
+
const animateTo = useCallback((toValue) => {
|
|
344
|
+
if (!enabled) return;
|
|
345
|
+
setIsAnimating(true);
|
|
346
|
+
onStart?.();
|
|
347
|
+
animRef.current?.stop();
|
|
348
|
+
animRef.current = Animated.spring(value, {
|
|
349
|
+
toValue,
|
|
350
|
+
friction,
|
|
351
|
+
tension,
|
|
352
|
+
useNativeDriver
|
|
353
|
+
});
|
|
354
|
+
animRef.current.start(({ finished }) => {
|
|
355
|
+
if (finished) {
|
|
356
|
+
setIsAnimating(false);
|
|
357
|
+
onComplete?.();
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
}, [value, friction, tension, useNativeDriver, enabled, onStart, onComplete]);
|
|
361
|
+
const start = useCallback(() => {
|
|
362
|
+
animateTo(to);
|
|
363
|
+
}, [animateTo, to]);
|
|
364
|
+
const stop = useCallback(() => {
|
|
365
|
+
animRef.current?.stop();
|
|
366
|
+
setIsAnimating(false);
|
|
367
|
+
}, []);
|
|
368
|
+
const reset = useCallback(() => {
|
|
369
|
+
animRef.current?.stop();
|
|
370
|
+
value.setValue(from);
|
|
371
|
+
setIsAnimating(false);
|
|
372
|
+
}, [value, from]);
|
|
373
|
+
useEffect(() => {
|
|
374
|
+
if (autoStart && enabled) start();
|
|
375
|
+
}, []);
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
return () => {
|
|
378
|
+
animRef.current?.stop();
|
|
379
|
+
};
|
|
380
|
+
}, []);
|
|
381
|
+
return { value, isAnimating, start, stop, reset, animateTo };
|
|
382
|
+
}
|
|
383
|
+
function usePulse(options = {}) {
|
|
384
|
+
const {
|
|
385
|
+
duration = 1500,
|
|
386
|
+
autoStart = true,
|
|
387
|
+
useNativeDriver = true,
|
|
388
|
+
easing = getEasing("easeInOut") || easeInOut,
|
|
389
|
+
minOpacity = 0.3,
|
|
390
|
+
iterations = -1,
|
|
391
|
+
onStart
|
|
392
|
+
} = options;
|
|
393
|
+
const opacity = useRef(new Animated.Value(1)).current;
|
|
394
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
395
|
+
const animRef = useRef(null);
|
|
396
|
+
const start = useCallback(() => {
|
|
397
|
+
if (isAnimating) return;
|
|
398
|
+
setIsAnimating(true);
|
|
399
|
+
onStart?.();
|
|
400
|
+
const pulse = Animated.sequence([
|
|
401
|
+
Animated.timing(opacity, {
|
|
402
|
+
toValue: minOpacity,
|
|
403
|
+
duration: duration / 2,
|
|
404
|
+
easing,
|
|
405
|
+
useNativeDriver
|
|
406
|
+
}),
|
|
407
|
+
Animated.timing(opacity, {
|
|
408
|
+
toValue: 1,
|
|
409
|
+
duration: duration / 2,
|
|
410
|
+
easing,
|
|
411
|
+
useNativeDriver
|
|
412
|
+
})
|
|
413
|
+
]);
|
|
414
|
+
animRef.current = iterations === -1 || iterations === Infinity ? Animated.loop(pulse) : Animated.loop(pulse, { iterations });
|
|
415
|
+
animRef.current.start(({ finished }) => {
|
|
416
|
+
if (finished) setIsAnimating(false);
|
|
417
|
+
});
|
|
418
|
+
}, [opacity, duration, easing, useNativeDriver, minOpacity, iterations, isAnimating, onStart]);
|
|
419
|
+
const stop = useCallback(() => {
|
|
420
|
+
animRef.current?.stop();
|
|
421
|
+
setIsAnimating(false);
|
|
422
|
+
}, []);
|
|
423
|
+
const reset = useCallback(() => {
|
|
424
|
+
animRef.current?.stop();
|
|
425
|
+
opacity.setValue(1);
|
|
426
|
+
setIsAnimating(false);
|
|
427
|
+
}, [opacity]);
|
|
428
|
+
useEffect(() => {
|
|
429
|
+
if (autoStart) start();
|
|
430
|
+
}, []);
|
|
431
|
+
useEffect(() => {
|
|
432
|
+
return () => {
|
|
433
|
+
animRef.current?.stop();
|
|
434
|
+
};
|
|
435
|
+
}, []);
|
|
436
|
+
return {
|
|
437
|
+
style: { opacity },
|
|
438
|
+
isVisible: true,
|
|
439
|
+
isAnimating,
|
|
440
|
+
progress: 0,
|
|
441
|
+
start,
|
|
442
|
+
stop,
|
|
443
|
+
reset
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function useStagger(options) {
|
|
447
|
+
const profile = useMotionProfile();
|
|
448
|
+
const {
|
|
449
|
+
count,
|
|
450
|
+
staggerDelay = profile.stagger.perItem,
|
|
451
|
+
duration = profile.base.duration,
|
|
452
|
+
easing = getEasing(profile.base.easing) || easeOut,
|
|
453
|
+
autoStart = true,
|
|
454
|
+
useNativeDriver = true,
|
|
455
|
+
motionType = "fadeIn",
|
|
456
|
+
distance = profile.entrance.slide.distance,
|
|
457
|
+
onComplete,
|
|
458
|
+
onStart
|
|
459
|
+
} = options;
|
|
460
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
461
|
+
const animRef = useRef(null);
|
|
462
|
+
const animatedValues = useRef(
|
|
463
|
+
Array.from({ length: count }, () => ({
|
|
464
|
+
opacity: new Animated.Value(0),
|
|
465
|
+
translateY: new Animated.Value(distance),
|
|
466
|
+
scale: new Animated.Value(0.8)
|
|
467
|
+
}))
|
|
468
|
+
).current;
|
|
469
|
+
useEffect(() => {
|
|
470
|
+
while (animatedValues.length < count) {
|
|
471
|
+
animatedValues.push({
|
|
472
|
+
opacity: new Animated.Value(0),
|
|
473
|
+
translateY: new Animated.Value(distance),
|
|
474
|
+
scale: new Animated.Value(0.8)
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
}, [count, animatedValues, distance]);
|
|
478
|
+
const start = useCallback(() => {
|
|
479
|
+
setIsVisible(false);
|
|
480
|
+
onStart?.();
|
|
481
|
+
const animations = animatedValues.slice(0, count).map((v) => {
|
|
482
|
+
const itemAnims = [
|
|
483
|
+
Animated.timing(v.opacity, {
|
|
484
|
+
toValue: 1,
|
|
485
|
+
duration,
|
|
486
|
+
easing,
|
|
487
|
+
useNativeDriver
|
|
488
|
+
})
|
|
489
|
+
];
|
|
490
|
+
if (motionType === "slideUp") {
|
|
491
|
+
itemAnims.push(
|
|
492
|
+
Animated.timing(v.translateY, {
|
|
493
|
+
toValue: 0,
|
|
494
|
+
duration,
|
|
495
|
+
easing,
|
|
496
|
+
useNativeDriver
|
|
497
|
+
})
|
|
498
|
+
);
|
|
499
|
+
} else if (motionType === "scaleIn") {
|
|
500
|
+
itemAnims.push(
|
|
501
|
+
Animated.timing(v.scale, {
|
|
502
|
+
toValue: 1,
|
|
503
|
+
duration,
|
|
504
|
+
easing,
|
|
505
|
+
useNativeDriver
|
|
506
|
+
})
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
return Animated.parallel(itemAnims);
|
|
510
|
+
});
|
|
511
|
+
animRef.current = Animated.stagger(staggerDelay, animations);
|
|
512
|
+
animRef.current.start(({ finished }) => {
|
|
513
|
+
if (finished) {
|
|
514
|
+
setIsVisible(true);
|
|
515
|
+
onComplete?.();
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}, [animatedValues, count, staggerDelay, duration, easing, useNativeDriver, motionType, onStart, onComplete]);
|
|
519
|
+
const stop = useCallback(() => {
|
|
520
|
+
animRef.current?.stop();
|
|
521
|
+
}, []);
|
|
522
|
+
const reset = useCallback(() => {
|
|
523
|
+
animRef.current?.stop();
|
|
524
|
+
animatedValues.forEach((v) => {
|
|
525
|
+
v.opacity.setValue(0);
|
|
526
|
+
v.translateY.setValue(distance);
|
|
527
|
+
v.scale.setValue(0.8);
|
|
528
|
+
});
|
|
529
|
+
setIsVisible(false);
|
|
530
|
+
}, [animatedValues, distance]);
|
|
531
|
+
useEffect(() => {
|
|
532
|
+
if (autoStart) start();
|
|
533
|
+
}, []);
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
return () => {
|
|
536
|
+
animRef.current?.stop();
|
|
537
|
+
};
|
|
538
|
+
}, []);
|
|
539
|
+
const items = useMemo(() => {
|
|
540
|
+
return animatedValues.slice(0, count).map((v) => {
|
|
541
|
+
if (motionType === "slideUp") {
|
|
542
|
+
return { style: { opacity: v.opacity, transform: [{ translateY: v.translateY }] } };
|
|
543
|
+
}
|
|
544
|
+
if (motionType === "scaleIn") {
|
|
545
|
+
return { style: { opacity: v.opacity, transform: [{ scale: v.scale }] } };
|
|
546
|
+
}
|
|
547
|
+
return { style: { opacity: v.opacity } };
|
|
548
|
+
});
|
|
549
|
+
}, [animatedValues, count, motionType]);
|
|
550
|
+
return { items, isVisible, start, stop, reset };
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
export { useBounceIn, useFadeIn, usePulse, useScaleIn, useSlideDown, useSlideLeft, useSlideRight, useSlideUp, useSpringMotion, useStagger };
|
|
554
|
+
//# sourceMappingURL=native.mjs.map
|
|
555
|
+
//# sourceMappingURL=native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks-native/useFadeIn.ts","../src/hooks-native/useSlide.ts","../src/hooks-native/useScaleIn.ts","../src/hooks-native/useBounceIn.ts","../src/hooks-native/useSpringMotion.ts","../src/hooks-native/usePulse.ts","../src/hooks-native/useStagger.ts"],"names":["useRef","Animated","useState","useCallback","useEffect"],"mappings":";;;;;AAWO,SAAS,SAAA,CAAU,O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AAA,IAAE,CAAA;AAAA,EACzC,CAAA,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,KAAA,GAAQ,QAA6B,MAAM;AAC/C,IAAA,OAAO,eAAe,KAAA,CAAM,CAAA,EAAG,KAAK,CAAA,CAAE,GAAA,CAAI,CAAC,CAAA,KAAM;AAC/C,MAAA,IAAI,eAAe,SAAA,EAAW;AAC5B,QAAA,OAAO,EAAE,KAAA,EAAO,EAAE,OAAA,EAAS,EAAE,OAAA,EAAS,SAAA,EAAW,CAAC,EAAE,UAAA,EAAY,CAAA,CAAE,UAAA,EAAY,GAAE,EAAE;AAAA,MACpF;AACA,MAAA,IAAI,eAAe,SAAA,EAAW;AAC5B,QAAA,OAAO,EAAE,KAAA,EAAO,EAAE,OAAA,EAAS,EAAE,OAAA,EAAS,SAAA,EAAW,CAAC,EAAE,KAAA,EAAO,CAAA,CAAE,KAAA,EAAO,GAAE,EAAE;AAAA,MAC1E;AACA,MAAA,OAAO,EAAE,KAAA,EAAO,EAAE,OAAA,EAAS,CAAA,CAAE,SAAQ,EAAE;AAAA,IACzC,CAAC,CAAA;AAAA,EACH,CAAA,EAAG,CAAC,cAAA,EAAgB,KAAA,EAAO,UAAU,CAAC,CAAA;AAEtC,EAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,KAAA,EAAO,MAAM,KAAA,EAAM;AAChD","file":"native.mjs","sourcesContent":["import { useRef, useEffect, useState, useCallback } from 'react'\nimport { Animated } from 'react-native'\nimport { useMotionProfile } from '../profiles/MotionProfileContext'\nimport { getEasing, easeOut } from '../utils/easing'\nimport type { NativeMotionReturn, NativeMotionOptions } from './types'\n\nexport interface NativeFadeInOptions extends NativeMotionOptions {\n initialOpacity?: number\n targetOpacity?: number\n}\n\nexport function useFadeIn(options: NativeFadeInOptions = {}): NativeMotionReturn {\n const profile = useMotionProfile()\n const {\n duration = profile.base.duration,\n delay = 0,\n easing = getEasing(profile.base.easing) || easeOut,\n autoStart = true,\n useNativeDriver = true,\n initialOpacity = profile.entrance.fade.initialOpacity,\n targetOpacity = 1,\n onComplete,\n onStart,\n } = options\n\n const opacity = useRef(new Animated.Value(initialOpacity)).current\n const [isAnimating, setIsAnimating] = useState(false)\n const [isVisible, setIsVisible] = useState(false)\n const [progress, setProgress] = useState(0)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n const start = useCallback(() => {\n if (isAnimating) return\n setIsAnimating(true)\n onStart?.()\n\n animRef.current = Animated.timing(opacity, {\n toValue: targetOpacity,\n duration,\n delay,\n easing,\n useNativeDriver,\n })\n animRef.current.start(({ finished }) => {\n if (finished) {\n setIsVisible(true)\n setIsAnimating(false)\n setProgress(1)\n onComplete?.()\n }\n })\n }, [opacity, duration, delay, easing, useNativeDriver, targetOpacity, isAnimating, onStart, onComplete])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n setIsAnimating(false)\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n opacity.setValue(initialOpacity)\n setIsAnimating(false)\n setIsVisible(false)\n setProgress(0)\n }, [opacity, initialOpacity])\n\n useEffect(() => {\n if (autoStart) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n return {\n style: { opacity },\n isVisible,\n isAnimating,\n progress,\n start,\n stop,\n reset,\n }\n}\n","import { useRef, useEffect, useState, useCallback } from 'react'\nimport { Animated } from 'react-native'\nimport { useMotionProfile } from '../profiles/MotionProfileContext'\nimport { getEasing, easeOut } from '../utils/easing'\nimport type { NativeMotionReturn, NativeMotionOptions } from './types'\n\nexport interface NativeSlideOptions extends NativeMotionOptions {\n distance?: number\n}\n\ntype SlideDirection = 'up' | 'down' | 'left' | 'right'\n\nfunction useSlideBase(direction: SlideDirection, options: NativeSlideOptions = {}): NativeMotionReturn {\n const profile = useMotionProfile()\n const {\n duration = profile.base.duration,\n delay = 0,\n easing = getEasing(profile.entrance.slide.easing) || easeOut,\n distance = profile.entrance.slide.distance,\n autoStart = true,\n useNativeDriver = true,\n onComplete,\n onStart,\n } = options\n\n const isVertical = direction === 'up' || direction === 'down'\n const sign = direction === 'up' || direction === 'left' ? 1 : -1\n const initialValue = sign * distance\n\n const translate = useRef(new Animated.Value(initialValue)).current\n const opacity = useRef(new Animated.Value(0)).current\n const [isAnimating, setIsAnimating] = useState(false)\n const [isVisible, setIsVisible] = useState(false)\n const [progress, setProgress] = useState(0)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n const start = useCallback(() => {\n if (isAnimating) return\n setIsAnimating(true)\n onStart?.()\n\n animRef.current = Animated.parallel([\n Animated.timing(translate, {\n toValue: 0,\n duration,\n delay,\n easing,\n useNativeDriver,\n }),\n Animated.timing(opacity, {\n toValue: 1,\n duration,\n delay,\n easing,\n useNativeDriver,\n }),\n ])\n animRef.current.start(({ finished }) => {\n if (finished) {\n setIsVisible(true)\n setIsAnimating(false)\n setProgress(1)\n onComplete?.()\n }\n })\n }, [translate, opacity, duration, delay, easing, useNativeDriver, isAnimating, onStart, onComplete])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n setIsAnimating(false)\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n translate.setValue(initialValue)\n opacity.setValue(0)\n setIsAnimating(false)\n setIsVisible(false)\n setProgress(0)\n }, [translate, opacity, initialValue])\n\n useEffect(() => {\n if (autoStart) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n const style = isVertical\n ? { opacity, transform: [{ translateY: translate }] }\n : { opacity, transform: [{ translateX: translate }] }\n\n return {\n style,\n isVisible,\n isAnimating,\n progress,\n start,\n stop,\n reset,\n }\n}\n\nexport function useSlideUp(options: NativeSlideOptions = {}): NativeMotionReturn {\n return useSlideBase('up', options)\n}\n\nexport function useSlideDown(options: NativeSlideOptions = {}): NativeMotionReturn {\n return useSlideBase('down', options)\n}\n\nexport function useSlideLeft(options: NativeSlideOptions = {}): NativeMotionReturn {\n return useSlideBase('left', options)\n}\n\nexport function useSlideRight(options: NativeSlideOptions = {}): NativeMotionReturn {\n return useSlideBase('right', options)\n}\n","import { useRef, useEffect, useState, useCallback } from 'react'\nimport { Animated } from 'react-native'\nimport { useMotionProfile } from '../profiles/MotionProfileContext'\nimport { getEasing, easeOut } from '../utils/easing'\nimport type { NativeMotionReturn, NativeMotionOptions } from './types'\n\nexport interface NativeScaleInOptions extends NativeMotionOptions {\n initialScale?: number\n targetScale?: number\n}\n\nexport function useScaleIn(options: NativeScaleInOptions = {}): NativeMotionReturn {\n const profile = useMotionProfile()\n const {\n duration = profile.base.duration,\n delay = 0,\n easing = getEasing(profile.base.easing) || easeOut,\n autoStart = true,\n useNativeDriver = true,\n initialScale = profile.entrance.scale.from,\n targetScale = 1,\n onComplete,\n onStart,\n } = options\n\n const scale = useRef(new Animated.Value(initialScale)).current\n const opacity = useRef(new Animated.Value(0)).current\n const [isAnimating, setIsAnimating] = useState(false)\n const [isVisible, setIsVisible] = useState(false)\n const [progress, setProgress] = useState(0)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n const start = useCallback(() => {\n if (isAnimating) return\n setIsAnimating(true)\n onStart?.()\n\n animRef.current = Animated.parallel([\n Animated.timing(scale, {\n toValue: targetScale,\n duration,\n delay,\n easing,\n useNativeDriver,\n }),\n Animated.timing(opacity, {\n toValue: 1,\n duration,\n delay,\n easing,\n useNativeDriver,\n }),\n ])\n animRef.current.start(({ finished }) => {\n if (finished) {\n setIsVisible(true)\n setIsAnimating(false)\n setProgress(1)\n onComplete?.()\n }\n })\n }, [scale, opacity, duration, delay, easing, useNativeDriver, targetScale, isAnimating, onStart, onComplete])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n setIsAnimating(false)\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n scale.setValue(initialScale)\n opacity.setValue(0)\n setIsAnimating(false)\n setIsVisible(false)\n setProgress(0)\n }, [scale, opacity, initialScale])\n\n useEffect(() => {\n if (autoStart) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n return {\n style: {\n opacity,\n transform: [{ scale }],\n },\n isVisible,\n isAnimating,\n progress,\n start,\n stop,\n reset,\n }\n}\n","import { useRef, useEffect, useState, useCallback } from 'react'\nimport { Animated } from 'react-native'\nimport { useMotionProfile } from '../profiles/MotionProfileContext'\nimport type { NativeMotionReturn, NativeMotionOptions } from './types'\n\nexport interface NativeBounceInOptions extends NativeMotionOptions {\n initialScale?: number\n /** Spring friction (lower = more bouncy) @default 4 */\n friction?: number\n /** Spring tension @default 80 */\n tension?: number\n}\n\nexport function useBounceIn(options: NativeBounceInOptions = {}): NativeMotionReturn {\n const profile = useMotionProfile()\n const {\n delay = 0,\n autoStart = true,\n useNativeDriver = true,\n initialScale = 0.3,\n friction = 4,\n tension = 80,\n onComplete,\n onStart,\n } = options\n\n const scale = useRef(new Animated.Value(initialScale)).current\n const opacity = useRef(new Animated.Value(0)).current\n const [isAnimating, setIsAnimating] = useState(false)\n const [isVisible, setIsVisible] = useState(false)\n const [progress, setProgress] = useState(0)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n const start = useCallback(() => {\n if (isAnimating) return\n setIsAnimating(true)\n onStart?.()\n\n animRef.current = Animated.parallel([\n Animated.spring(scale, {\n toValue: 1,\n friction,\n tension,\n useNativeDriver,\n delay,\n }),\n Animated.timing(opacity, {\n toValue: 1,\n duration: 200,\n delay,\n useNativeDriver,\n }),\n ])\n animRef.current.start(({ finished }) => {\n if (finished) {\n setIsVisible(true)\n setIsAnimating(false)\n setProgress(1)\n onComplete?.()\n }\n })\n }, [scale, opacity, friction, tension, delay, useNativeDriver, isAnimating, onStart, onComplete])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n setIsAnimating(false)\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n scale.setValue(initialScale)\n opacity.setValue(0)\n setIsAnimating(false)\n setIsVisible(false)\n setProgress(0)\n }, [scale, opacity, initialScale])\n\n useEffect(() => {\n if (autoStart) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n return {\n style: {\n opacity,\n transform: [{ scale }],\n },\n isVisible,\n isAnimating,\n progress,\n start,\n stop,\n reset,\n }\n}\n","import { useRef, useEffect, useState, useCallback } from 'react'\nimport { Animated } from 'react-native'\nimport { useMotionProfile } from '../profiles/MotionProfileContext'\nimport type { NativeMotionOptions } from './types'\n\nexport interface NativeSpringMotionOptions extends NativeMotionOptions {\n from: number\n to: number\n friction?: number\n tension?: number\n enabled?: boolean\n}\n\nexport interface NativeSpringMotionReturn {\n value: Animated.Value\n isAnimating: boolean\n start: () => void\n stop: () => void\n reset: () => void\n animateTo: (toValue: number) => void\n}\n\nexport function useSpringMotion(options: NativeSpringMotionOptions): NativeSpringMotionReturn {\n const profile = useMotionProfile()\n const {\n from,\n to,\n friction = Math.sqrt(4 * profile.spring.mass * profile.spring.stiffness) / (2 * profile.spring.damping) * 10 || 26,\n tension = profile.spring.stiffness / 2 || 170,\n autoStart = true,\n useNativeDriver = true,\n enabled = true,\n onComplete,\n onStart,\n } = options\n\n const value = useRef(new Animated.Value(from)).current\n const [isAnimating, setIsAnimating] = useState(false)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n const animateTo = useCallback((toValue: number) => {\n if (!enabled) return\n setIsAnimating(true)\n onStart?.()\n\n animRef.current?.stop()\n animRef.current = Animated.spring(value, {\n toValue,\n friction,\n tension,\n useNativeDriver,\n })\n animRef.current.start(({ finished }) => {\n if (finished) {\n setIsAnimating(false)\n onComplete?.()\n }\n })\n }, [value, friction, tension, useNativeDriver, enabled, onStart, onComplete])\n\n const start = useCallback(() => {\n animateTo(to)\n }, [animateTo, to])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n setIsAnimating(false)\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n value.setValue(from)\n setIsAnimating(false)\n }, [value, from])\n\n useEffect(() => {\n if (autoStart && enabled) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n return { value, isAnimating, start, stop, reset, animateTo }\n}\n","import { useRef, useEffect, useState, useCallback } from 'react'\nimport { Animated } from 'react-native'\nimport { getEasing, easeInOut } from '../utils/easing'\nimport type { NativeMotionReturn, NativeMotionOptions } from './types'\n\nexport interface NativePulseOptions extends NativeMotionOptions {\n /** Min opacity @default 0.3 */\n minOpacity?: number\n /** Number of iterations (Infinity for forever) @default Infinity */\n iterations?: number\n}\n\nexport function usePulse(options: NativePulseOptions = {}): NativeMotionReturn {\n const {\n duration = 1500,\n autoStart = true,\n useNativeDriver = true,\n easing = getEasing('easeInOut') || easeInOut,\n minOpacity = 0.3,\n iterations = -1,\n onStart,\n } = options\n\n const opacity = useRef(new Animated.Value(1)).current\n const [isAnimating, setIsAnimating] = useState(false)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n const start = useCallback(() => {\n if (isAnimating) return\n setIsAnimating(true)\n onStart?.()\n\n const pulse = Animated.sequence([\n Animated.timing(opacity, {\n toValue: minOpacity,\n duration: duration / 2,\n easing,\n useNativeDriver,\n }),\n Animated.timing(opacity, {\n toValue: 1,\n duration: duration / 2,\n easing,\n useNativeDriver,\n }),\n ])\n\n animRef.current = iterations === -1 || iterations === Infinity\n ? Animated.loop(pulse)\n : Animated.loop(pulse, { iterations })\n\n animRef.current.start(({ finished }) => {\n if (finished) setIsAnimating(false)\n })\n }, [opacity, duration, easing, useNativeDriver, minOpacity, iterations, isAnimating, onStart])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n setIsAnimating(false)\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n opacity.setValue(1)\n setIsAnimating(false)\n }, [opacity])\n\n useEffect(() => {\n if (autoStart) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n return {\n style: { opacity },\n isVisible: true,\n isAnimating,\n progress: 0,\n start,\n stop,\n reset,\n }\n}\n","import { useRef, useEffect, useState, useCallback, useMemo } from 'react'\nimport { Animated } from 'react-native'\nimport { useMotionProfile } from '../profiles/MotionProfileContext'\nimport { getEasing, easeOut } from '../utils/easing'\nimport type { NativeMotionOptions } from './types'\n\nexport interface NativeStaggerOptions extends NativeMotionOptions {\n /** Number of items */\n count: number\n /** Delay between each item (ms) @default 100 */\n staggerDelay?: number\n /** Motion type @default 'fadeIn' */\n motionType?: 'fadeIn' | 'slideUp' | 'scaleIn'\n /** Slide distance (px, for slideUp) @default 20 */\n distance?: number\n}\n\nexport interface NativeStaggerItem {\n style: {\n opacity: Animated.Value\n transform?: Array<{ translateY: Animated.Value } | { scale: Animated.Value }>\n }\n}\n\nexport interface NativeStaggerReturn {\n items: NativeStaggerItem[]\n isVisible: boolean\n start: () => void\n stop: () => void\n reset: () => void\n}\n\nexport function useStagger(options: NativeStaggerOptions): NativeStaggerReturn {\n const profile = useMotionProfile()\n const {\n count,\n staggerDelay = profile.stagger.perItem,\n duration = profile.base.duration,\n easing = getEasing(profile.base.easing) || easeOut,\n autoStart = true,\n useNativeDriver = true,\n motionType = 'fadeIn',\n distance = profile.entrance.slide.distance,\n onComplete,\n onStart,\n } = options\n\n const [isVisible, setIsVisible] = useState(false)\n const animRef = useRef<Animated.CompositeAnimation | null>(null)\n\n // Create animated values for each item (stable across renders)\n const animatedValues = useRef(\n Array.from({ length: count }, () => ({\n opacity: new Animated.Value(0),\n translateY: new Animated.Value(distance),\n scale: new Animated.Value(0.8),\n }))\n ).current\n\n // Rebuild if count changes\n useEffect(() => {\n while (animatedValues.length < count) {\n animatedValues.push({\n opacity: new Animated.Value(0),\n translateY: new Animated.Value(distance),\n scale: new Animated.Value(0.8),\n })\n }\n }, [count, animatedValues, distance])\n\n const start = useCallback(() => {\n setIsVisible(false)\n onStart?.()\n\n const animations = animatedValues.slice(0, count).map((v) => {\n const itemAnims: Animated.CompositeAnimation[] = [\n Animated.timing(v.opacity, {\n toValue: 1,\n duration,\n easing,\n useNativeDriver,\n }),\n ]\n\n if (motionType === 'slideUp') {\n itemAnims.push(\n Animated.timing(v.translateY, {\n toValue: 0,\n duration,\n easing,\n useNativeDriver,\n })\n )\n } else if (motionType === 'scaleIn') {\n itemAnims.push(\n Animated.timing(v.scale, {\n toValue: 1,\n duration,\n easing,\n useNativeDriver,\n })\n )\n }\n\n return Animated.parallel(itemAnims)\n })\n\n animRef.current = Animated.stagger(staggerDelay, animations)\n animRef.current.start(({ finished }) => {\n if (finished) {\n setIsVisible(true)\n onComplete?.()\n }\n })\n }, [animatedValues, count, staggerDelay, duration, easing, useNativeDriver, motionType, onStart, onComplete])\n\n const stop = useCallback(() => {\n animRef.current?.stop()\n }, [])\n\n const reset = useCallback(() => {\n animRef.current?.stop()\n animatedValues.forEach((v) => {\n v.opacity.setValue(0)\n v.translateY.setValue(distance)\n v.scale.setValue(0.8)\n })\n setIsVisible(false)\n }, [animatedValues, distance])\n\n useEffect(() => {\n if (autoStart) start()\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n useEffect(() => {\n return () => { animRef.current?.stop() }\n }, [])\n\n const items = useMemo<NativeStaggerItem[]>(() => {\n return animatedValues.slice(0, count).map((v) => {\n if (motionType === 'slideUp') {\n return { style: { opacity: v.opacity, transform: [{ translateY: v.translateY }] } }\n }\n if (motionType === 'scaleIn') {\n return { style: { opacity: v.opacity, transform: [{ scale: v.scale }] } }\n }\n return { style: { opacity: v.opacity } }\n })\n }, [animatedValues, count, motionType])\n\n return { items, isVisible, start, stop, reset }\n}\n"]}
|