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-page-animation

v1.0.3

Published

Customisable Page Animations with react-router

Downloads

10

Readme

PageAnimation

Index

It is a very basic animation wrapper that has a very specific use case.

It allows you to have different routes within react-router places as if in a grid and provide customized transitions based on the direction.

There is only one export default which is the PageAnimation Componant

PageAnimation Props

| Name | Type | Default | Purpose | | ---------------- | -------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | animate | boolean | true | Whether to animate the between screens or directly jump to next screen. (note: this is added for an easy toggle) | | bias | "vertical" | "horizontal" | "vertical" | Since currently only the 4 cardinal directions are supported, if the relative direction is at non 90 degree angle, the bias resolves which one to use | | children | any | Required | The regular React children which gets rendered on each page | | classExtension | string | Required | The base className from which all the directions extend | | className | string | null | The className to be applied on the wrapper div which holds all the rendered screens | | grid | RegExp[][] | Required | This is the grid of pages which is matched against location path from which realtive direcctions are found | | timeout | number | Required | The time delay after which previous screen will be unmounted |

bias:

As noted before, currently diagnol directions arent supported, bias controls whether to check for up/down first or left/right. eg: If the page is to the top-left, if bias is "vertical", the direction top will be given. If the bias was "horizontal", left would be given

Example

Taking this example setup

<PageTransition classExtension="direction" timeout={500} grid={[[/\/$/, /\/about$/], [/\/products$/]]}>
  <Switch>
    <Route path="/about" component={About} />
    <Route path="/products" component={Product} />
    <Route path="/" component={Home} />
  </Switch>
</PageTransition>

The basic page layout then is -

If a user is at / and then clicks to go to /product, then the css class which is added is

  • for / screen: direction-down-leave
  • for /products screen: direction-down-enter

    After 500 milliseconds, / screen will be unmounted and /products will have the class direction-done

Similarily, if a user is at /products and clicks to go to /about, then the css class which is added is

  • for /products screen: direction-top-leave
  • for /abourt screen: direction-top-enter

    After 500 milliseconds, /products screen will be unmounted and /about will have the class direction-done

CSS Classes

In general the classes are generated in the following format:
"classExtension-direction-timePosition" where classExtension is supplied as a prop, direction is the relative direction between 2 screens, and the timePostion is position of the animation in the lifecycle of the component

eg. pages-left-done pages The name supplied to the Transition component left The current component was to the left of the previous component done The previous component has been unmounted and backward means behind in the url tree

classExension

The prop supplied by you.

direction

There are six directions - top, bottom, left and right which are the relative postions in the grid. If the same grid location is detected, depending on the relative depth of the url, same-backward, same-forward and same are set as the direction.

eg: Both the urls are matched to the same position on the grid path. If the previous url is /users and the next url is /users/232, then the same-forward animation will be triggered

timePosition

There are three 'timePositions' - enter, done, leave.

  • enter - When the component, as well as the previous component, are mounted.
  • done - When the previous component is unmounted.
  • leave- When this component is going to be unmounted. [Note: this correlated to the next components enter timePosition]