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

pranimate

v0.2.0

Published

Lightweight library for basic animations

Downloads

26

Readme

pranimate

npm version Bundle size

Installation

npm i --save pranimate
## OR
yarn add pranimate

Usage

useSpring

This hook accepts an object as argument, this object can contain seven properties:

  • to, the ending value where we are animating towards
  • property, the name of the property we are animating
  • from, the starting value where we are animating from
  • getValue, this function will be invoked to get special values as seen in the example for rotate/translate
  • infinite, whether or not the animation should keep animating back and forth
  • lazy, whether or not the hook should start with the animation started
  • preset, this can be either 'wobbly' | 'noWobble' | 'stiff' which are three spring mechanics
  • velocity, by default 1 you can tweak this number to have your proper speed

The hook returns you a tuple with the first being a ref which you should attach to the element you are animating, the second being a function that activates the animation, this can be handy when you started in the lazy mode and the thirth being a function called play to imperatively play your animation once.

Example:

const SpringAnimation = () => {
  const [ref] = useSpring({
    from: 0,
    to: 75,
    getValue: x => `translateX(${x}vw)`,
    property: 'transform',
    infinite: true,
  });

  return (
    <div
      ref={ref}
      style={{ backgroundColor: 'red', width: 300, height: 300 }}
    />
  );
};

useMountUnmount

This hook accepts an object as argument, this object can contain four properties:

  • mountedClass, the className to return when the element is mounting
  • unmountedClass, the className to return when the element is unmounting
  • duration, the duration of your css-animation from the above two properties.
  • lazy (optional), whether or not the hook should start with a mounted false state

This hooks returns you an array with four values:

  • The current className (mounting/unmounting)
  • The mounted state
  • A function to indicate to our hook that we are mounting
  • A function to indicate to our hook that we are unmounting

Example:

const CssAnimation = () => {
  const [className, mounted, mount, unmount] = useMountUnmount({
    mountingClass: 'mounting',
    unmountingClass: 'unmounting',
    duration: 1000,
  });

  useEffect(() => {
    setTimeout(() => {
      if (mounted) {
        unmount();
      } else {
        mount();
      }
    }, 2500);
  }, [mounted, mount, unmount]);

  return (
    mounted !== false && (
      <div
        className={className}
        style={{
          backgroundColor: 'red',
          width: 300,
          height: 300,
          marginBottom: 64,
        }}
      />
    )
  );
};