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-hero-transition

v0.4.0

Published

A library to help create beutiful hero transitions for view changes. It tracks mounting and unmounting of components and is therfore not dependant on react-router or any other way of managing different views. It is based on the principle of [FLIP](https:/

Downloads

20

Readme

react-hero-transition

A library to help create beutiful hero transitions for view changes. It tracks mounting and unmounting of components and is therfore not dependant on react-router or any other way of managing different views. It is based on the principle of FLIP animations and uses getBoundingClientRect to calculate the position and size of the old and the new element, the new element is then animated using transforms from the position of the old element.

Transitions can be applied using either react-motion or css transitions. You can also write your own renderer that animates in whatever way you prefer.

Usage

First wrap your app with <TransitionProvider> similarly to the provider of react-redux. Then wrap your "heroes" with the <Hero> component.

A basic example:

<TransitionProvider>
  <Row>
    <Column>
      <Box>
        {position === 0 && <Hero id='position'><Number>0</Number></Hero>}
      </Box>
      {position !== 0 && <button onClick={() => this.setState({position: 0})}>Move here</button>}
    </Column>
    <Column>
      <Box>
        {position === 1 && <Hero id='position'><Number>1</Number></Hero>}
      </Box>
      {position !== 1 && <button onClick={() => this.setState({position: 1})}>Move here</button>}
    </Column>
  </Row>
</TransitionProvider>

API

TransitionProvider

Props

timeout
  • Type: number
  • required: no
  • default value: 100

How much time in ms it may pass between an element beeing removed and added for a hero transition to be run.

renderer
  • Type: Renderer
  • required: no
  • default value: cssTransition

Which renderer to use for performing transitions

Hero

Props

id
  • Type: string
  • required: yes

A hero will transition to another hero with the same id. It should be unique per page but be repeated on the pages it should transition between.

children
  • Type: ReactElement
  • required: no

A hero must either have a render prop or be provided with a single child. The child will be provided a ref and a style prop and must therfore be either a browser element or a class component, not a function component as those can't have refs.

render
  • Type: ({heroIn: boolean}) => ReactElement
  • required: no

If a render function is provided, it will be called with a single argument containing an object with a heroIn property. heroIn will be true if the hero will perform an hero transition and false otherwise. This can be used to for example show a fade in animation instead. The function should return a single rendered ReactElement that corresponds to the same rules as for the children prop.

Example

To start the example run

yarn
yarn start

in the example folder