UNPKG

4.21 kBMarkdownView Raw
1# rc-motion
2
3[![NPM version][npm-image]][npm-url]
4[![npm download][download-image]][download-url]
5[![build status][github-actions-image]][github-actions-url]
6[![Codecov][codecov-image]][codecov-url]
7[![Dependencies][david-image]](david-url)
8[![DevDependencies][david-dev-image]][david-dev-url]
9[![bundle size][bundlephobia-image]][bundlephobia-url]
10
11[npm-image]: http://img.shields.io/npm/v/rc-motion.svg?style=flat-square
12[npm-url]: http://npmjs.org/package/rc-motion
13[github-actions-image]: https://github.com/react-component/motion/workflows/CI/badge.svg
14[github-actions-url]: https://github.com/react-component/motion/actions
15[codecov-image]: https://img.shields.io/codecov/c/github/react-component/motion/master.svg?style=flat-square
16[codecov-url]: https://codecov.io/gh/react-component/motion/branch/master
17[david-url]: https://david-dm.org/react-component/motion
18[david-image]: https://david-dm.org/react-component/motion/status.svg?style=flat-square
19[david-dev-url]: https://david-dm.org/react-component/motion?type=dev
20[david-dev-image]: https://david-dm.org/react-component/motion/dev-status.svg?style=flat-square
21[download-image]: https://img.shields.io/npm/dm/rc-motion.svg?style=flat-square
22[download-url]: https://npmjs.org/package/rc-motion
23[bundlephobia-url]: https://bundlephobia.com/result?p=rc-motion
24[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-motion
25
26React lifecycle controlled motion library.
27
28## Live Demo
29
30https://react-component.github.io/motion/
31
32## Install
33
34[![rc-motion](https://nodei.co/npm/rc-motion.png)](https://npmjs.org/package/rc-motion)
35
36## Example
37
38```tsx
39import CSSMotion from 'rc-motion';
40
41export default ({ visible }) => (
42 <CSSMotion visible={visible} motionName="my-motion">
43 {({ className, style }) => <div className={className} style={style} />}
44 </CSSMotion>
45);
46```
47
48## API
49
50### CSSMotion
51
52| Property | Type | Default | Description |
53| --- | --- | --- | --- |
54| motionName | string | - | Config motion name, will dynamic update when status changed |
55| visible | boolean | true | Trigger motion events |
56| motionAppear | boolean | true | Use motion when appear |
57| motionEnter | boolean | true | Use motion when enter |
58| motionLeave | boolean | true | Use motion when leave |
59| motionLeaveImmediately | boolean | - | Will trigger leave even on mount |
60| motionDeadline | number | - | Trigger motion status change even when motion event not fire |
61| removeOnLeave | boolean | true | Remove element when motion leave end |
62| leavedClassName | string | - | Set leaved element className |
63| onAppearStart | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when appear start, return style will patch to element |
64| onEnterStart | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when enter start, return style will patch to element |
65| onLeaveStart | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when leave start, return style will patch to element |
66| onAppearActive | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when appear active, return style will patch to element |
67| onEnterActive | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when enter active, return style will patch to element |
68| onLeaveActive | (HTMLElement, Event) => CSSProperties \| void; | - | Trigger when leave active, return style will patch to element |
69| onAppearEnd | (HTMLElement, Event) => boolean \| void; | - | Trigger when appear end, will not finish when return false |
70| onEnterEnd | (HTMLElement, Event) => boolean \| void; | - | Trigger when enter end, will not finish when return false |
71| onLeaveEnd | (HTMLElement, Event) => boolean \| void; | - | Trigger when leave end, will not finish when return false |
72
73### CSSMotionList
74
75extends all the props from [CSSMotion](#CSSMotion)
76
77| Property | Type | Default | Description |
78| --------- | ----------------------------- | ------- | ----------------- |
79| keys | React.Key[] | - | Motion list keys |
80| component | string \| React.ComponentType | div | wrapper component |
81
82## Development
83
84```
85npm install
86npm start
87```
88
89## License
90
91rc-motion is released under the MIT license.