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 | };
|
13 | export var useTransitionDuration = function useTransitionDuration(percentList) {
|
14 |
|
15 | var paths = percentList.map(function () {
|
16 | return useRef();
|
17 | });
|
18 | var prevTimeStamp = useRef(null);
|
19 | useEffect(function () {
|
20 | var now = Date.now();
|
21 | var updated = false;
|
22 | Object.keys(paths).forEach(function (key) {
|
23 | var path = paths[key].current;
|
24 |
|
25 | if (!path) {
|
26 | return;
|
27 | }
|
28 |
|
29 | updated = true;
|
30 | var pathStyle = path.style;
|
31 | pathStyle.transitionDuration = '.3s, .3s, .3s, .06s';
|
32 |
|
33 | if (prevTimeStamp.current && now - prevTimeStamp.current < 100) {
|
34 | pathStyle.transitionDuration = '0s, 0s';
|
35 | }
|
36 | });
|
37 |
|
38 | if (updated) {
|
39 | prevTimeStamp.current = Date.now();
|
40 | }
|
41 | });
|
42 | return [paths];
|
43 | }; |
\ | No newline at end of file |