Skip to content

Commit

Permalink
update code
Browse files Browse the repository at this point in the history
  • Loading branch information
SaidMarar committed Jan 4, 2024
1 parent 4202892 commit 502b57b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/Circle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const Circle: React.FC<ProgressProps> = (props) => {
>;
const isConicGradient = gradient && typeof gradient === 'object';
const mergedStrokeLinecap = isConicGradient ? 'butt' : strokeLinecap;
const { indeterminateStylePops, indeterminateStyleTag } = getIndeterminateCircle({ loading });
const { indeterminateStyleProps, indeterminateStyleAnimation } = getIndeterminateCircle({
loading,
});

const circleStyle = getCircleStyle(
perimeter,
Expand Down Expand Up @@ -97,7 +99,7 @@ const Circle: React.FC<ProgressProps> = (props) => {
radius={radius}
prefixCls={prefixCls}
gradientId={gradientId}
style={{ ...circleStyleForStack, ...indeterminateStylePops }}
style={{ ...circleStyleForStack, ...indeterminateStyleProps }}
strokeLinecap={mergedStrokeLinecap}
strokeWidth={strokeWidth}
gapDegree={gapDegree}
Expand Down Expand Up @@ -183,7 +185,7 @@ const Circle: React.FC<ProgressProps> = (props) => {
/>
)}
{stepCount ? getStepStokeList() : getStokeList()}
{indeterminateStyleTag}
{indeterminateStyleAnimation}
</svg>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/Line.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import classNames from 'classnames';
import { useTransitionDuration, defaultProps, toArray } from './common';
import { useTransitionDuration, defaultProps } from './common';
import type { ProgressProps } from './interface';
import getIndeterminateLine from './utils/getIndeterminateLine';

Expand Down Expand Up @@ -36,7 +36,7 @@ const Line: React.FC<ProgressProps> = (props) => {
L ${strokeLinecap === 'round' ? right : 100},${center}`;
const viewBoxString = `0 0 100 ${strokeWidth}`;
let stackPtg = 0;
const { indeterminateStylePops, indeterminateStyleTag } = getIndeterminateLine({
const { indeterminateStyleProps, indeterminateStyleAnimation } = getIndeterminateLine({
loading,
percent: percentList[0],
strokeLinecap,
Expand Down Expand Up @@ -78,7 +78,7 @@ const Line: React.FC<ProgressProps> = (props) => {
transition:
transition ||
'stroke-dashoffset 0.3s ease 0s, stroke-dasharray .3s ease 0s, stroke 0.3s linear',
...indeterminateStylePops,
...indeterminateStyleProps,
};
const color = strokeColorList[index] || strokeColorList[strokeColorList.length - 1];
stackPtg += ptg;
Expand All @@ -103,7 +103,7 @@ const Line: React.FC<ProgressProps> = (props) => {
/>
);
})}
{indeterminateStyleTag}
{indeterminateStyleAnimation}
</svg>
);
};
Expand Down
8 changes: 4 additions & 4 deletions src/utils/getIndeterminateCircle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ interface IndeterminateOption {
export default (options: IndeterminateOption) => {
if (!options.loading) {
return {
indeterminateStylePops: {},
indeterminateStyleTag: null,
indeterminateStyleProps: {},
indeterminateStyleAnimation: null,
};
}

const animationName = 'circle-indeterminate-animate';

return {
indeterminateStylePops: {
indeterminateStyleProps: {
transform: 'rotate(0deg)',
animation: `${animationName} 1s linear infinite`,
},
indeterminateStyleTag: (
indeterminateStyleAnimation: (
<style>
{`@keyframes ${animationName} {
0 % { transform: rotate(0deg);}
Expand Down
8 changes: 4 additions & 4 deletions src/utils/getIndeterminateLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ export default (options: IndeterminateOption) => {
const { percent, strokeLinecap, strokeWidth, loading } = options;
if (!loading) {
return {
indeterminateStylePops: {},
indeterminateStyleTag: null,
indeterminateStyleProps: {},
indeterminateStyleAnimation: null,
};
}
const animationName = 'line-indeterminate-animate';
const strokeDashOffset = 100 - (percent + (strokeLinecap === 'round' ? strokeWidth : 0));

return {
indeterminateStylePops: {
indeterminateStyleProps: {
strokeDasharray: `${percent} 100`,
animation: `${animationName} .6s linear alternate infinite`,
strokeDashoffset: 0,
},
indeterminateStyleTag: (
indeterminateStyleAnimation: (
<style>
{`@keyframes ${animationName} {
0% { stroke-dashoffset: 0; }
Expand Down

0 comments on commit 502b57b

Please sign in to comment.