common.js 1.1 KB

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