Skip to content

Commit 163bb3c

Browse files
authored
🐛 fix line progress percentage (#94)
1 parent e4a262b commit 163bb3c

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Line.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,20 @@ const Line: React.FC<ProgressProps> = ({
4646
fillOpacity="0"
4747
/>
4848
{percentList.map((ptg, index) => {
49+
let dashPercent = 1;
50+
switch (strokeLinecap) {
51+
case 'round':
52+
dashPercent = 1 - strokeWidth / 100;
53+
break;
54+
case 'square':
55+
dashPercent = 1 - strokeWidth / 2 / 100;
56+
break;
57+
default:
58+
dashPercent = 1;
59+
break;
60+
}
4961
const pathStyle = {
50-
strokeDasharray: `${ptg}px, 100px`,
62+
strokeDasharray: `${ptg * dashPercent}px, 100px`,
5163
strokeDashoffset: `-${stackPtg}px`,
5264
transition:
5365
transition ||

0 commit comments

Comments
 (0)