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

v1.0.2

Published

Simple alternative for applying an array of style transitions in React

Downloads

8

Readme

React Transition Array

This component is a simple alternative for applying an array of style transitions in React.

Philosophy

ReactCSSTransitionGroup (https://facebook.github.io/react/docs/animation.html) and ReactInlineTransitionGroup (https://github.com/felipethome/react-inline-transition-group) seemed like the only options to render transitions using React. Now, both these appear to be limited in terms of how many transitions you can squeeze into appear/enter and leave. It isn't intuitive how one would go about supplying an array of more than two transitions to be applied to a component sequentially. That's where React Transition Array comes to the rescue.

There's no appear/enter/leave constraint. This component works off an array of styles that are applied sequentially. The first is equivalent to appear/enter and the last is leave. If there's just one style element in the array, apear/enter/leave are rolled into one. Optionally, we can unmount all child components after the last transition style is applied.

Demo

How to install

    npm install react-transition-array

How it works

Dynamically build styles object as an array of transitions, and pass it as a property using the key of the corresponding React element passed as a child element to link the style:


import Transition from 'react-transition-array'

let styles = {
  base: {
    position: 'absolute',
    top: '100px',
    left: '100px',
    borderRadius: '50%',
    border: '2px solid #B2FF59',
    height: '100px',
    width: '100px',
    opacity: '0.5',
  },
  transitionArray: [
    {
      transition: 'all 600ms ease-in',
      opacity: '0.75',
    },
    {
      transition: 'all 600ms ease-in',
      opacity: '1',
      top: '75px',
      left: '75px',
      border: '2px solid #80CBC4',
      height: '150px',
      width: '150px',
    },
    {
      transition: 'all 600ms ease-in',
      opacity: '1',
      top: '50px',
      left: '50px',
      border: '2px solid #26A69A',
      height: '200px',
      width: '200px',
    },
    {
      border: '2px solid #004D40',
      transition: 'all 600ms ease-in',
      opacity: '0',
    }
  ]
}

...

render() {
  let keyTmp = 'xmplky'
  let transitionStyles = {}
  transitionStyles[keyTmp] =  styles

  return (
    <Transition transitionStyles={transitionStyles} keepAllAlive={false}>
      <div key={keyTmp} />
    </Transition>
  )
}

Properties

Property name | Description ------------ | ------------- component | String. Wrapper component. Default: div. transitionStyles | Object. This object has a nested structure containing a first level of properties matching those of child React element keys. Each of the above top level objects contain objects with base and transitionArray properties. base is an object containing styles that are common to each transition contained in transitionArray, which is an array of objects, each containing styles including transition specs to be applied sequentially. keepAllAlive | Boolean. Flag to be used to determine whether child elements should be unmounted after completion of the transition rendering sequence. Default: false children | Node. React element on which above transition styles are to be merged with corresponding child's given inline style.

LICENSE

MIT © [Thomas Varghese] (https://github.com/numbervine)