@bounceapp/lottie
Version:
Lottie wrapper for React Native Web
52 lines (51 loc) • 1.16 kB
JavaScript
;
import Lottie from "lottie-react";
import React, { forwardRef, useImperativeHandle, useRef } from "react";
import { jsx as _jsx } from "react/jsx-runtime";
/**
* ```tsx
* import React from "react"
*
* import { LottieView } from "@bounceapp/lottie"
*
* import lottieAnimation from "./lottieAnimation.json"
*
* const App = () => (
* <LottieView
* style={{ width: 100, height: 100 }}
* autoPlay
* loop
* source={lottieAnimation}
* />
* )
*
* export default App
* ```
*
* @category Component
*/
const LottieView = /*#__PURE__*/forwardRef(({
source,
style,
loop,
autoPlay,
onAnimationFinish
}, ref) => {
const lottieRef = useRef(null);
useImperativeHandle(ref, () => ({
pause: () => lottieRef.current?.pause(),
play: () => lottieRef.current?.play(),
reset: () => lottieRef.current?.goToAndPlay(0)
}));
return /*#__PURE__*/_jsx(Lottie, {
"data-chromatic": "ignore",
lottieRef: lottieRef,
animationData: source,
loop: loop,
autoplay: autoPlay,
style: style,
onComplete: onAnimationFinish
});
});
export { LottieView };
//# sourceMappingURL=Lottie.js.map