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