util.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.getCircleStyle = exports.VIEW_BOX_SIZE = void 0;
  6. var VIEW_BOX_SIZE = exports.VIEW_BOX_SIZE = 100;
  7. var getCircleStyle = exports.getCircleStyle = function getCircleStyle(perimeter, perimeterWithoutGap, offset, percent, rotateDeg, gapDegree, gapPosition, strokeColor, strokeLinecap, strokeWidth) {
  8. var stepSpace = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : 0;
  9. var offsetDeg = offset / 100 * 360 * ((360 - gapDegree) / 360);
  10. var positionDeg = gapDegree === 0 ? 0 : {
  11. bottom: 0,
  12. top: 180,
  13. left: 90,
  14. right: -90
  15. }[gapPosition];
  16. var strokeDashoffset = (100 - percent) / 100 * perimeterWithoutGap;
  17. // Fix percent accuracy when strokeLinecap is round
  18. // https://github.com/ant-design/ant-design/issues/35009
  19. if (strokeLinecap === 'round' && percent !== 100) {
  20. strokeDashoffset += strokeWidth / 2;
  21. // when percent is small enough (<= 1%), keep smallest value to avoid it's disappearance
  22. if (strokeDashoffset >= perimeterWithoutGap) {
  23. strokeDashoffset = perimeterWithoutGap - 0.01;
  24. }
  25. }
  26. var halfSize = VIEW_BOX_SIZE / 2;
  27. return {
  28. stroke: typeof strokeColor === 'string' ? strokeColor : undefined,
  29. strokeDasharray: "".concat(perimeterWithoutGap, "px ").concat(perimeter),
  30. strokeDashoffset: strokeDashoffset + stepSpace,
  31. transform: "rotate(".concat(rotateDeg + offsetDeg + positionDeg, "deg)"),
  32. transformOrigin: "".concat(halfSize, "px ").concat(halfSize, "px"),
  33. transition: 'stroke-dashoffset .3s ease 0s, stroke-dasharray .3s ease 0s, stroke .3s, stroke-width .06s ease .3s, opacity .3s ease 0s',
  34. fillOpacity: 0
  35. };
  36. };