1 | # rc-queue-anim
|
2 | ---
|
3 |
|
4 | Animate React Component in queue, thanks to [rc-animate](https://github.com/react-component/animate) and [enter-animation](https://github.com/jljsj33/enter-animation).
|
5 |
|
6 | [![NPM version][npm-image]][npm-url]
|
7 | [![build status][github-actions-image]][github-actions-url]
|
8 | [![Codecov][codecov-image]][codecov-url]
|
9 | [![Total alerts][lgtm-alerts-image]][lgtm-alerts-url]
|
10 | [![Language grade: JavaScript][lgtm-grade-image]][lgtm-grade-url]
|
11 | [![node version][node-image]][node-url]
|
12 | [![npm download][download-image]][download-url]
|
13 |
|
14 | [npm-image]: http://img.shields.io/npm/v/rc-queue-anim.svg?style=flat-square
|
15 | [npm-url]: http://npmjs.org/package/rc-queue-anim
|
16 | [github-actions-image]: https://github.com/react-component/queue-anim/workflows/CI/badge.svg
|
17 | [github-actions-url]: https://github.com/react-component/queue-anim/actions
|
18 | [codecov-image]: https://img.shields.io/codecov/c/github/react-component/queue-anim/master.svg?style=flat-square
|
19 | [codecov-url]: https://codecov.io/gh/react-component/queue-anim/branch/master
|
20 | [lgtm-alerts-image]: https://img.shields.io/lgtm/alerts/g/react-component/queue-anim.svg?logo=lgtm&logoWidth=18&style=flat-square
|
21 | [lgtm-alerts-url]: https://lgtm.com/projects/g/react-component/queue-anim/alerts/
|
22 | [lgtm-grade-image]: https://img.shields.io/lgtm/grade/javascript/g/react-component/queue-anim.svg?logo=lgtm&logoWidth=18&style=flat-square
|
23 | [lgtm-grade-url]: https://lgtm.com/projects/g/react-component/queue-anim/context:javascript
|
24 | [node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square
|
25 | [node-url]: http://nodejs.org/download/
|
26 | [download-image]: https://img.shields.io/npm/dm/rc-queue-anim.svg?style=flat-square
|
27 | [download-url]: https://npmjs.org/package/rc-queue-anim
|
28 |
|
29 | ## Example
|
30 | 2.x: https://queue-anim.vercel.app/
|
31 |
|
32 | 1.x: http://react-component.github.io/queue-anim/examples/
|
33 |
|
34 | ![](https://t.alipayobjects.com/images/rmsweb/T12PliXjXgXXXXXXXX.gif)
|
35 |
|
36 | ## Usage
|
37 |
|
38 | ```js
|
39 | import QueueAnim from 'rc-queue-anim';
|
40 | import React from 'react';
|
41 | import ReactDom from 'react-dom';
|
42 |
|
43 | ReactDom.render(
|
44 | <QueueAnim>
|
45 | <div key="1">enter in queue</div>
|
46 | <div key="2">enter in queue</div>
|
47 | <div key="3">enter in queue</div>
|
48 | </QueueAnim>
|
49 | , mountNode);
|
50 | ```
|
51 |
|
52 | ## Install
|
53 |
|
54 | [![rc-queue-anim](https://nodei.co/npm/rc-queue-anim.png)](https://npmjs.org/package/rc-queue-anim)
|
55 |
|
56 | ## Browser Support
|
57 |
|
58 | |![IE](https://github.com/alrra/browser-logos/blob/master/src/edge/edge_48x48.png?raw=true) | ![Chrome](https://github.com/alrra/browser-logos/blob/master/src/chrome/chrome_48x48.png?raw=true) | ![Firefox](https://github.com/alrra/browser-logos/blob/master/src/firefox/firefox_48x48.png?raw=true) | ![Opera](https://github.com/alrra/browser-logos/blob/master/src/opera/opera_48x48.png?raw=true) | ![Safari](https://github.com/alrra/browser-logos/blob/master/src/safari/safari_48x48.png?raw=true)|
|
59 | | --- | --- | --- | --- | --- |
|
60 | | IE 10+ ✔ | Chrome 31.0+ ✔ | Firefox 31.0+ ✔ | Opera 30.0+ ✔ | Safari 7.0+ ✔ |
|
61 |
|
62 | ### 1.7.x add childRefs and currentRef;
|
63 |
|
64 | ```js
|
65 | <QueueAnim
|
66 | component={Row}
|
67 | ref={(c) => {
|
68 | this.ref = c;
|
69 | }}
|
70 | onEnd={() => {
|
71 | // this..currentRef = <Row />
|
72 | // this..childRefs.a = <Col key="a">1212</Col>
|
73 | }}
|
74 | >
|
75 | <Col key="a">1212</Col>
|
76 | </QueueAnim>
|
77 | ```
|
78 |
|
79 | ## API
|
80 |
|
81 | > You must provide the key attribute for all children of QueueAnim, children would not peform any animation without key.
|
82 |
|
83 | | props | type | default | description |
|
84 | |------------|----------------|---------|----------------|
|
85 | | type | string / array | `right` | Animation Styles <br/>`alpha` `left` `right` `top` `bottom` `scale` `scaleBig` `scaleX` `scaleY`|
|
86 | | animConfig | object / array | null | Custom config, See below for more details [animConfig](#animConfig) |
|
87 | | delay | number / array | 0 | delay of animation |
|
88 | | duration | number / array | 450 | duration of animation |
|
89 | | interval | number / array | 100 | interval of duration |
|
90 | | leaveReverse | boolean | false | reverse animation order at leave |
|
91 | | ease | string / array | `easeOutQuart` | animation easing config like `'ease'`, `['easeIn', 'easeOut']`, `[[.42,0,.58,1]`, [.42,0,.58,1]]: [more](http://easings.net/en) |
|
92 | | appear | boolean | true | whether support appear anim |
|
93 | | component | string / React.Element | `div` | component tag |
|
94 | | componentProps | Object | null | component is React.Element, component tag props |
|
95 | | animatingClassName | array | `['queue-anim-entering', 'queue-anim-leaving']` | className to every element of animating |
|
96 | | forcedReplay | boolean | false | `leave` animation moment trigger `enter`, forced replay. |
|
97 | | onEnd | function | null | animation end callback({ key, type }), type: `enter` or `leave` |
|
98 |
|
99 | > Above props support array format, like `['left', 'top']`, the secord item is leave config. [Demo](http://react-component.github.io/queue-anim/examples/enter-leave.html)
|
100 |
|
101 | ### animConfig
|
102 |
|
103 | **Data fall into three categories:**
|
104 |
|
105 | - Custom set start: `{ opacity:[1, 0] }` ;
|
106 | <br/> default;
|
107 | <br/>type: `{ opacity: Array<end, start> }`;
|
108 | <br/>leave automatic reverse: `{ opacity: Array<start, end> }`;
|
109 |
|
110 | - Custom: `{ opacity: 0 }`;
|
111 | <br/> Start position is not set。
|
112 |
|
113 | - Array: `[{ opacity:[1, 0] }, { opacity:[1, 0] }]`;
|
114 | <br/> type: `[{ opacity: Array<end, start> }, { opacity: Array<start, end>}]`
|
115 |
|
116 | ## Development
|
117 |
|
118 | ```
|
119 | npm install
|
120 | npm start
|
121 | ```
|