common.js 909 B

12345678910111213141516171819202122232425262728293031323334
  1. import { useRef, useEffect } from 'react';
  2. export var defaultProps = {
  3. percent: 0,
  4. prefixCls: 'rc-progress',
  5. strokeColor: '#2db7f5',
  6. strokeLinecap: 'round',
  7. strokeWidth: 1,
  8. trailColor: '#D9D9D9',
  9. trailWidth: 1,
  10. gapPosition: 'bottom'
  11. };
  12. export var useTransitionDuration = function useTransitionDuration() {
  13. var pathsRef = useRef([]);
  14. var prevTimeStamp = useRef(null);
  15. useEffect(function () {
  16. var now = Date.now();
  17. var updated = false;
  18. pathsRef.current.forEach(function (path) {
  19. if (!path) {
  20. return;
  21. }
  22. updated = true;
  23. var pathStyle = path.style;
  24. pathStyle.transitionDuration = '.3s, .3s, .3s, .06s';
  25. if (prevTimeStamp.current && now - prevTimeStamp.current < 100) {
  26. pathStyle.transitionDuration = '0s, 0s';
  27. }
  28. });
  29. if (updated) {
  30. prevTimeStamp.current = Date.now();
  31. }
  32. });
  33. return pathsRef.current;
  34. };