1 | import { useRef, useEffect } from 'react';
|
2 | export var defaultProps = {
|
3 | className: '',
|
4 | percent: 0,
|
5 | prefixCls: 'rc-progress',
|
6 | strokeColor: '#2db7f5',
|
7 | strokeLinecap: 'round',
|
8 | strokeWidth: 1,
|
9 | style: {},
|
10 | trailColor: '#D9D9D9',
|
11 | trailWidth: 1,
|
12 | gapPosition: 'bottom'
|
13 | };
|
14 | export var useTransitionDuration = function useTransitionDuration(percentList) {
|
15 |
|
16 | var paths = percentList.map(function () {
|
17 | return useRef();
|
18 | });
|
19 | var prevTimeStamp = useRef(null);
|
20 | useEffect(function () {
|
21 | var now = Date.now();
|
22 | var updated = false;
|
23 | Object.keys(paths).forEach(function (key) {
|
24 | var path = paths[key].current;
|
25 |
|
26 | if (!path) {
|
27 | return;
|
28 | }
|
29 |
|
30 | updated = true;
|
31 | var pathStyle = path.style;
|
32 | pathStyle.transitionDuration = '.3s, .3s, .3s, .06s';
|
33 |
|
34 | if (prevTimeStamp.current && now - prevTimeStamp.current < 100) {
|
35 | pathStyle.transitionDuration = '0s, 0s';
|
36 | }
|
37 | });
|
38 |
|
39 | if (updated) {
|
40 | prevTimeStamp.current = Date.now();
|
41 | }
|
42 | });
|
43 | return [paths];
|
44 | }; |
\ | No newline at end of file |