UNPKG

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