From 5fe2811996516c4c6d41b5b154a300b6ba30a563 Mon Sep 17 00:00:00 2001 From: preper Date: Tue, 29 Dec 2020 19:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20line=20progress=20percenta?= =?UTF-8?q?ge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Line.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Line.tsx b/src/Line.tsx index 8aa48c9..9c0706b 100644 --- a/src/Line.tsx +++ b/src/Line.tsx @@ -46,8 +46,20 @@ const Line: React.FC = ({ fillOpacity="0" /> {percentList.map((ptg, index) => { + let dashPercent = 1; + switch (strokeLinecap) { + case 'round': + dashPercent = 1 - strokeWidth / 100; + break; + case 'square': + dashPercent = 1 - strokeWidth / 2 / 100; + break; + default: + dashPercent = 1; + break; + } const pathStyle = { - strokeDasharray: `${ptg}px, 100px`, + strokeDasharray: `${ptg * dashPercent}px, 100px`, strokeDashoffset: `-${stackPtg}px`, transition: transition ||