UNPKG

@bounceapp/lottie

Version:

Lottie wrapper for React Native Web

44 lines (42 loc) 1.14 kB
"use strict"; import LottieViewRN from "lottie-react-native"; import React, { forwardRef, useEffect, useImperativeHandle, useRef } from "react"; import { Platform } from "react-native"; import { jsx as _jsx } from "react/jsx-runtime"; const LottieView = /*#__PURE__*/forwardRef(({ source, style, loop, autoPlay, onAnimationFinish }, ref) => { const lottieRef = useRef(null); /** * Fix IOS autoPlay * https://github.com/lottie-react-native/lottie-react-native/issues/832 */ useEffect(() => { if (autoPlay && Platform.OS === "ios") { setTimeout(() => { lottieRef.current?.reset(); lottieRef.current?.play(); }, 100); } }, [autoPlay]); useImperativeHandle(ref, () => ({ pause: () => lottieRef.current?.pause(), play: () => lottieRef.current?.play(), reset: () => lottieRef.current?.reset() })); return /*#__PURE__*/_jsx(LottieViewRN, { ref: lottieRef, source: source, loop: loop, autoPlay: autoPlay, style: style, speed: 1, onAnimationFinish: onAnimationFinish }); }); export { LottieView }; //# sourceMappingURL=Lottie.native.js.map