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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-lotties

v0.3.2

Published

lottie animation view for React

Downloads

18

Readme

Lottie Animation View for React

npm version

Demo

https://jysa65.github.io/react-lottie/

Wapper of bodymovin.js

bodymovin is Adobe After Effects plugin for exporting animations as JSON, also it provide bodymovin.js for render them as svg/canvas/html.

Why Lottie?

Flexible After Effects features

We currently support solids, shape layers, masks, alpha mattes, trim paths, and dash patterns. And we’ll be adding new features on a regular basis.

Manipulate your animation any way you like

You can go forward, backward, and most importantly you can program your animation to respond to any interaction.

Small file sizes

Bundle vector animations within your app without having to worry about multiple dimensions or large file sizes. Alternatively, you can decouple animation files from your app’s code entirely by loading them from a JSON API.

Learn more › http://airbnb.design/lottie/

Looking for lottie files › https://www.lottiefiles.com/

Installation

Install through npm:

npm install --save react-lotties

Usage

import * as React from "react";
import Lottie from "../index";
import animationDataA from "./pinjump.json";
import animationDataB from "./TwitterHeart.json";

const { useState } = React;

export default function LottieControl() {
  const [state, setState] = useState({
    isStopped: false,
    isPaused: false,
    speed: 1,
    direction: 1,
    isDataA: true,
  });
  const centerStyle = {
    display: "block",
    margin: "10px auto",
    textAlign: "center",
  };
  const { isStopped, isPaused, direction, speed, isDataA } = state;
  const defaultOptions = {
    rendererSettings: {
      preserveAspectRatio: 'xMidYMid slice'
    },
    animationData: isDataA ? animationDataA : animationDataB,
  };
  return (
    <div>
      <Lottie
        options={defaultOptions}
        height={400}
        width={400}
        isStopped={isStopped}
        isPaused={isPaused}
        speed={speed}
        direction={direction}
      />

      <p style={centerStyle}>Speed: x{speed}</p>
      <input
        style={centerStyle}
        type="range"
        value={speed}
        min="0"
        max="3"
        step="0.5"
        onChange={(e) => setState({ ...state, speed: e.currentTarget.value })}
      />
      <button
        style={centerStyle}
        onClick={() => setState({ ...state, isStopped: true })}
      >
        stop
      </button>
      <button
        style={centerStyle}
        onClick={() => setState({ ...state, isStopped: false })}
      >
        play
      </button>
      <button
        style={centerStyle}
        onClick={() => setState({ ...state, isPaused: !isPaused })}
      >
        pause
      </button>
      <button
        style={centerStyle}
        onClick={() => setState({ ...state, direction: direction * -1 })}
      >
        change direction
      </button>
      <button
        style={centerStyle}
        onClick={() => setState({ ...state, isDataA: !isDataA })}
      >
        toggle animation
      </button>
    </div>
  );
}

props

The <Lottie /> Component supports the following components:

options required

the object representing the animation settings that will be instantiated by bodymovin. Currently a subset of the bodymovin options are supported:

loop options [default: false]

autoplay options [default: false]

animationData required

rendererSettings required

width optional [default: 100%]

pixel value for containers width.

height optional [default: 100%]

pixel value for containers height.

eventListeners optional [default: []]

This is an array of objects containing a eventName and callback function that will be registered as eventlisteners on the animation object. refer to bodymovin#events where the mention using addEventListener, for a list of available custom events.

example:

eventListeners=[
  {
    eventName: 'complete',
    callback: () => console.log('the animation completed:'),
  },
]

Contribution

Your contributions and suggestions are heartily welcome.

License

MIT