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-leanimate

v0.16.0

Published

a lightweight library to animate react components

Downloads

24

Readme

react-leanimate npm version

Animate your react application with lightweight components.

Checkout the demo page which is worth more than a thousand words.

Aminate component

The problem with animating a react component is simple, you cannot animate a component that has been removed from the DOM.

The solution is to wrap a component, intercept the unmount lifecycle, clone the underlying DOM node and then apply the desired CSS animation.

Here is a basic example of how to use the Animate component:

import React, { Component } from "react";
import Animate from "react-leanimate/Animate";

class Toggler extends Component {
  state = {
    show: true
  };

  render() {
    const { state } = this;
    return (
      <div>
        <button onClick={() => this.setState({ show: !state.show })}>
          Toggle
        </button>
        <div
        >
          {state.show && (
            <Animate
              component={<span>Hello World</span>}
              animationHide={"hide-right 1s"}
              animationShow={"show-left 1s"}
            />
          )}
        </div>
      </div>
    );
  }
}

Edit react-leanimate example

Smooth component

When a child component is added or removed, the parent node will have its width or height changed. Use the Smooth component to animate this transition.

Example:

import React, { Component } from "react";
import Smooth from "react-leanimate/Smooth";

class ShowDetails extends Component {
  state = {
    show: false
  };

  render() {
    const { state } = this;
    return (
      <Smooth className="box-border">
        <button onClick={() => this.setState({ show: !state.show })}>
          Show Details
        </button>
        <div>
          {state.show && <div>Details here</div>}
        </div>
      </Smooth>
    );
  }
}

Edit react-leanimate <Smooth/>

Installing this library

The library is published under the react-leanimate name

$ npm i react-leanimate

Building this library

microbundle is the underlying tool to produce size efficient bundles.

$ npm run build:lib
> microbundle -i src/Animate.js -i src/Smooth.js --external all --jsx React.createElement

Build output to dist:
        609 B: Animate.js
        575 B: Animate.m.js
        673 B: Animate.umd.js
        718 B: Smooth.js
        684 B: Smooth.m.js
        782 B: Smooth.umd.js

Modifying this library

Start a development server using:

$ npm run build

You can also develop with storybook

$ npm run storybook