
Security News
PEP 810 Proposes Explicit Lazy Imports for Python 3.15
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
@cher-ami/react-transition
Advanced tools
A zero dependency React transition component who allows to manage play-in & play-out transitions of any DOM element.
A zero dependency React transition component who allows to manage play-in & play-out transitions of any DOM element.
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.
$ npm i @cher-ami/react-transition
import React, {useState} from "react"
import {Transition} from "@cher-ami/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>
)
}
boolean
optional - default: true
Toggle start play-in / play-out children with transition
ReactElement
React children element to transit
(el: HTMLElement, done: () => any) => void
optional
Play-in transition function
() => void
optional
Function calls when play-in transition function is completed
(el: HTMLElement, done: () => any) => void
optional
Play-out transition function
() => void
optional
Function calls when play-out transition function is completed
boolean
optional - default: false
Start transition on first mount. If false, children is visible but transition
start only when "if" props change
boolean
optional - default: true
Unmount children React element after playOut transition
(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 "@cher-ami/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>
</>
)
}
A use case example is available on this repos.
Install dependencies
$ npm i
Start dev server
$ npm run dev
FAQs
A zero dependency React transition component who allows to manage play-in & play-out transitions of any DOM element.
We found that @cher-ami/react-transition demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
An opt-in lazy import keyword aims to speed up Python startups, especially CLIs, without the ecosystem-wide risks that sank PEP 690.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.