npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

lottie-web-react

v1.0.3

Published

React wrapper for lottie-web

Downloads

609

Readme

Lottie web for React

Blog : https://medium.com/@tanisha_verma/lottie-and-react-hooks-1adb4713446b

Lottie-web-react is a wrapper for lottie-web using React hooks. For more information on lottie-web visit https://github.com/airbnb/lottie-web

Demo : https://tanisha-verma.github.io/lottie-web-react/

Installation

Install through npm:

npm install --save lottie-web-react

Usage

import  React, { useState } from  'react'
import  Lottie  from  'lottie-web-react'
let  watchAnimationData = require('./stopwatch.json')
const  renderer ='svg'
const  rendererSettings = {
preserveAspectRatio:  'xMinYMin slice',
}

function  MyAnimation() {
const [playingState, setPlayingState] = useState('play')
const [autoplay, setAutoplay] = useState(false)
const [loop, setLoop] = useState(true)
const [path, setPath] = useState('https://assets2.lottiefiles.com/datafiles/zc3XRzudyWE36ZBJr7PIkkqq0PFIrIBgp4ojqShI/newAnimation.json')
const [animationData, setAnimationData] = useState(watchAnimationData)
const [speed, setSpeed] = useState(1)
const [direction, setDirection] = useState(1)
return (
<Lottie
options={{
renderer:  renderer,
loop:  loop,
autoplay:  autoplay,
path:  path,
animationData:  animationData,
rendererSettings:  rendererSettings
}}
playingState={playingState}
speed={speed}
direction={direction}
/>
)
}
export  default  MyAnimation

Props

options

Used for loading the animation

  • animationData: an Object with the exported animation data.
  • path: the relative path to the animation object. (animationData and path are mutually exclusive)
  • loop: true / false / number
  • autoplay: true / false it will start playing as soon as it is ready
  • name: animation name for future reference
  • renderer: 'svg' / 'canvas' / 'html' to set the renderer

Note : If path and animationData both are passed then the animation instance is created using path and not animationData.

playingState :

Accepts three values : 'play' , 'pause' or 'stop' . 'play' : Plays lottie animation once the animation is loaded by using lottie-web's play() method. 'pause' : Plays lottie animation once the animation is loaded. Uses lottie-web's pause() method. 'stop' : Stops lottie animation if the animation is loaded by using lottie-web's stop() method.

id

Optional.

className

Pass custom class to modify the container.

direction

Accepts two values : '1' or '-1' . Uses lottie-web's setDirection() method. 1 is forward, -1 is reverse.

speed

Accepts number. Uses lottie-web's setSpeed() method. 1 is normal speed.

goToAndPlay

Type : object. Should contain following parameters :

  • value: numeric value.
  • isFrame: defines if first argument is a time based value or a frame based (default false).

Uses lottie-web's goToAndPlay() method.

playSegments

Type : object. Should contain following parameters :

  • segments: array. Can contain 2 numeric values that will be used as first and last frame of the animation. Or can contain a sequence of arrays each with 2 numeric values.
  • forceFlag: boolean. If set to false, it will wait until the current segment is complete. If true, it will update values immediately.(default false).

Uses lottie-web's playSegments() method.

eventListeners

Type : array. You can pass list of events and its callbacks to dispatch any action once the event is triggered.

Example use case: [{ eventName: 'loopComplete', callback: () => { setLoopCounter(loopCounter + 1) } }]

Once a loop is completed by animation the event 'loopComplete' is triggered and it calls setLoopCounter action to increment the loopCounter.

Following events can be added:

  • complete
  • loopComplete
  • enterFrame
  • segmentStart
  • config_ready (when initial config is done)
  • data_ready (when all parts of the animation have been loaded)
  • data_failed (when part of the animation can not be loaded)
  • loaded_images (when all image loads have either succeeded or errored)
  • DOMLoaded (when elements have been added to the DOM)
  • destroy