⚛️ 一个 3kb 的 CSS 动画组件,适用于 React。
A css powered (graphics accelerated) animation component for React.
height: auto; and width: auto;Need Help? Click here to sign up for the React-Tools Spectrum community. We are constantly discussing implementation details and answering questions. :)
$ yarn add react-show
# or
$ npm install --save react-showYou can create a simple expander component with the Animate component!
import { Animate } from "react-show";
const SimpleExample = () => (
Hello world!
);You can create a simple expander component with the Animate component!
…You can configure duration, easing, and transition by:
duration, easing, and transitionProperty props.transitionDuration, transitionTimingFunction, transitionProperty or even transitionDelay.ReactShow comes with a wide variety of easings built-in! See Easing Options for a full list.
import { Animate } from "react-show";
const DurationAndEasingExample = () => (
Hello world!
);React-Show uses the following lifecycle to determine which styles to show:
When show === true
transitionOnMount === truestart styles are set as the initial styletransitionOnMount === falseenter styles are set as the initial styleenter styles are set as the initial stylewidth or height style is/was set to autodisplay: block and overflow: hidden styles are temporarily applieddisplay: block and overflow: hidden styles are removedenter styles are applied and component waits until all transitions completeonFinish prop function is firedWhen show === false
width or height style is/was set to autodisplay: block and overflow: hidden styles are temporarily applieddisplay: block and overflow: hidden styles are removedleave or start styles are applied and component waits until all transitions completestayMounted === falseReact-Show comes packaged with some awesome easings that are accessible via Animate.easings. They are extremely simple to use too:
import { Animate } from "react-show";
const SimpleExample = () => (
Hello world!
);Below is a full list of the available easings exported at Animate.easings
…| Prop | Required | Default Value | Description |
|---|---|---|---|
show |
true |
false |
Determines whether to "show" the content or not. |
duration |
300 |
The transition-duration of the transition used to show the content |
|
easing |
easeOutQuint |
The transition-timing-function used to show the content |
|
transitionProperty |
all |
The transition-property used to show the content |
|
preMount |
false |
If true, element will mount on first render if show === false |
|
stayMounted |
false |
If true, element will stay mounted when show === false |
|
transitionOnMount |
false |
If true, element will animate from the start style on mount |
|
style |
undefined |
React style object (See lifecycle for more details) | |
start |
undefined |
React style object (See lifecycle for more details) | |
enter |
undefined |
React style object (See lifecycle for more details) | |
leave |
undefined |
React style object (See lifecycle for more details) | |
component |
div |
Use a (or custom) component as the wrapper instead of a | |
onFinish |
noop |
Function called when the component finishes transitioning. | |
onMount |
noop |
Function called when the children passed to Animate are mounted. | |
onWillUnmount |
noop |
Function called right before the children passed to Animate are unmounted. |
We are always looking for people to help us grow react-show's capabilities and examples. If you have an issue, feature request, or pull request, let us know!
React Show uses the MIT license. For more information on this license, click here.
暂无开放 Issues,或尚未同步最近议题。