All files / hooks usePetAnim.ts

88.88% Statements 8/9
75% Branches 3/4
100% Functions 3/3
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      2x 3x   3x 3x         3x 2x 1x       3x          
import { useEffect, useRef } from 'react';
import LottieView from 'lottie-react-native';
 
export const usePetAnim = () => {
  const lottieRef = useRef<LottieView>(null);
 
  useEffect(() => {
    Iif (lottieRef.current) {
      lottieRef.current.play();
    }
  }, []);
 
  const playInteractAnim = () => {
    if (lottieRef.current) {
      lottieRef.current.play(0, 120); // 假设动画帧范围,可根据实际json调整
    }
  };
 
  return {
    lottieRef,
    playInteractAnim,
  };
};