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

@wbe/react-transition

v2.7.1

Published

![](https://img.shields.io/npm/v/@wbe/react-transition/latest.svg) ![](https://img.shields.io/bundlephobia/minzip/@wbe/react-transition.svg) ![](https://img.shields.io/npm/dt/@wbe/react-transition.svg) ![](https://img.shields.io/npm/l/@wbe/react-transi

Downloads

39

Readme

@wbe/react-transition

A zero dependency React transition component who allows to manage play-in & play-out transitions of any DOM element.

About

React-transition responds to the simple request to have control over the play-in and play-out transition of any component or DOM element.

React does not by default provide the ability to execute an exit transition function before a DOM element is destroyed. Alexey Taktarov explains this "limitation" with example in this publication.

React-transition a "Vuejs like" transition API. It's intended to partially meet the same needs of Vue transition component.

Install

$ npm i @wbe/react-transition

Usage

import React, {useState} from "react"
import {Transition} from "@wbe/react-transition"
import {gsap} from "gsap/all"

const App = () => {
  const [isToggle, setIsToggle] = useState(true)

  // Example with GSAP
  const playInTransition = (el, done) => {
    gsap.fromTo(el, {autoAlpha: 0}, {autoAlpha: 1, onComplete: done})
  }

  const playOutTransition = (el, done) => {
    gsap.fromTo(el, {autoAlpha: 1}, {autoAlpha: 0, onComplete: done})
  }

  return (
    <div className={"app"}>
      <button onClick={() => setIsToggle(!isToggle)}>Toggle</button>
      <Transition
        if={isToggle}
        playIn={playInTransition}
        playOut={playOutTransition}
      >
        <div className={"element"} />
      </Transition>
    </div>
  )
}

Props

if

boolean optional - default: true
Toggle start play-in / play-out children with transition

children

ReactElement
React children element to transit

playIn

(el: HTMLElement, done: () => any) => void optional
Play-in transition function

onPlayInComplete

() => void optional
Function calls when play-in transition function is completed

playOut

(el: HTMLElement, done: () => any) => void optional
Play-out transition function

onPlayOutComplete

() => void optional
Function calls when play-out transition function is completed

appear

boolean optional - default: false
Start transition on first mount. If false, children is visible but transition start only when "if" props change

unmountAfterPlayOut

boolean optional - default: true
Unmount children React element after playOut transition

dispatchPlayState

(play: TPlay) => void optional
Dispatch current TPlay string type

type TPlay = "hidden" | "play-out" | "play-in" | "visible";
import React, {useEffect, useState} from "react"
import {Transition} from "@wbe/react-transition"

const App = () => {
  // ...
  const [elementPlayState, setElementPlayState] = useState(null);
  useEffect(()=> {
    if (elementPlayState === "play-in") {
      // ...  
    }
  }, [elementPlayState])

  return (
    <>
      <Transition
        // ...
        // Everytime transition playState change, elementPlayState will be updated
        dispatchPlayState={(playState) => setElementPlayState(playState)}
      >
        <div className={"element"} />
      </Transition>
    </>
  )
}

Example

A use case example is available on this repos.

Install dependencies

$ npm i

Start dev server

$ npm run dev