Gathering detailed insights and metrics for react-lottie-hook
Gathering detailed insights and metrics for react-lottie-hook
Gathering detailed insights and metrics for react-lottie-hook
Gathering detailed insights and metrics for react-lottie-hook
npm install react-lottie-hook
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
5 Stars
62 Commits
1 Forks
1 Watching
3 Branches
4 Contributors
Updated on 23 Jun 2022
TypeScript (92.52%)
JavaScript (5.55%)
CSS (1.93%)
Cumulative downloads
Total Downloads
Last day
-10.3%
148
Compared to previous day
Last week
-1%
812
Compared to previous week
Last month
67.1%
3,637
Compared to previous month
Last year
-30.4%
50,412
Compared to previous year
2
40
Lottie react hook with runtime animation controls.
Lottie is a library for the Web, Android and iOS that parses Adobe After Effects animations through a plugin called bodymovin and exported as JSON; rendering natively on each platform.
Add it with your prefered package manager:
yarn add react-lottie-hook
npm i react-lottie-hook
This library main exports a useLottie
hook and supplies also a standard Lottie
component but you are not required to use the latter.
The useLottie
hook requires a configuration object of type LottieConfig
to be supplied to it and in return you will get an array with a ref to the animation container, state of the animation and the control actions, respectively.
1import React from "react"; 2import { useLottie, Lottie } from "react-lottie-hook"; 3import animationData from "./animation.json"; 4 5const App = () => { 6 const [lottieRef, { isPaused, isStopped }, controls] = useLottie({ 7 renderer: "svg", 8 rendererSettings: { 9 preserveAspectRatio: "xMidYMid slice", 10 progressiveLoad: false, 11 }, 12 JSON.parse(JSON.stringify(animationData)), 13 }); 14 15 return <Lottie lottieRef={ref} width={400} height={400} />; 16};
Due to likely memory leaks it is highly advised to deeply clone the animation object using methods such as lodash.cloneDeep
.
The exported Lottie
component has a type of LottieProps
and the minimum props it requires is a lottieRef
from the useLottie
hook.
Lottie Component props:
props | type | default |
---|---|---|
lottieRef: | React.MutableRefObject<HTMLElement | null> | |
width? | number | 200px |
height? | number | 200px |
style? | object | |
title? | string | |
className? | string | |
ariaRole? | string | |
ariaLabel? | string | |
onKeyDown? | (e: React.KeyboardEvent) => void | |
onClick? | (e: React.MouseEvent<HTMLElement, MouseEvent>) |
Among the options you can pass useLottie
is an eventListeners
object as follows:
1const eventListeners: EventLisener = { 2 /** triggered only if loop is set to true */ 3 loopCompleted: (data) => { console.log('Animation Loop Completed'); }, 4 /** triggered when animation is destroyed */ 5 destroy: : (data) => { console.log('Animation Destroyed'); }, 6 /** triggered when loop is set to false */ 7 complete: (data) => { console.log('Animation Complete'); }, 8}; 9 10const [lottieRef, { isPaused, isStopped }, controls] = useLottie({ 11 renderer: "svg", 12 loop: false, // default true 13 rendererSettings: { 14 preserveAspectRatio: "xMidYMid slice", 15 progressiveLoad: false, 16 }, 17 animationData, 18 eventListeners, 19}); 20
hanorine |
Alex Billingsley |
Arno (H) Welgemoed |
benito |
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
48 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More