MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / FadeAnimationView

Function FadeAnimationView

app/components/UI/FadeAnimationView/index.js:7–100  ·  view source on GitHub ↗
({
  children,
  style,
  animationTime = TIME,
  valueToWatch,
  onAnimationStart,
  onAnimationEnd,
  animateOnChange,
})

Source from the content-addressed store, hash-verified

5const TIME = 3900; // 3900/6 = 650 for each
6
7const FadeAnimationView = ({
8 children,
9 style,
10 animationTime = TIME,
11 valueToWatch,
12 onAnimationStart,
13 onAnimationEnd,
14 animateOnChange,
15}) => {
16 const fadeAnim = useRef(new Animated.Value(1)).current; // Initial value for opacity: 1
17 const [value, setValue] = useState(valueToWatch);
18 const [lastChildren, setLastChildren] = useState(children);
19 const [isAnimating, setIsAnimating] = useState(false);
20
21 const animationEnded = useCallback(() => {
22 onAnimationEnd?.();
23 setValue(valueToWatch);
24 setLastChildren(children);
25 setIsAnimating(false);
26 }, [children, onAnimationEnd, valueToWatch]);
27
28 const animationStarted = useCallback(() => {
29 onAnimationStart?.();
30 }, [onAnimationStart]);
31
32 const animate = useCallback(() => {
33 animationStarted();
34
35 const animationParams = {
36 time: animationTime / 6,
37 useNativeDriver: true,
38 };
39 const animationValueZero = 0;
40 const animationValueAlmost = 0.8;
41 const animationValueFinal = 1;
42
43 Animated.sequence([
44 Animated.timing(fadeAnim, {
45 toValue: animationValueZero,
46 ...animationParams,
47 }),
48 Animated.timing(fadeAnim, {
49 toValue: animationValueAlmost,
50 ...animationParams,
51 }),
52 Animated.timing(fadeAnim, {
53 toValue: animationValueZero,
54 ...animationParams,
55 }),
56 Animated.timing(fadeAnim, {
57 toValue: animationValueAlmost,
58 ...animationParams,
59 }),
60 Animated.timing(fadeAnim, {
61 toValue: animationValueZero,
62 ...animationParams,
63 }),
64 Animated.timing(fadeAnim, {

Callers

nothing calls this directly

Calls 1

startMethod · 0.45

Tested by

no test coverage detected