Skip to content

Commit

Permalink
fix: the issue of stroke overflowing when trailStrokeWidth is differe…
Browse files Browse the repository at this point in the history
…nt from strokeWidth
  • Loading branch information
MathewtheCoder committed Feb 11, 2021
1 parent ce12b54 commit b3d3aab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 3 additions & 1 deletion packages/mobile/src/components/CountdownCircleTimer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const CountdownCircleTimer = (props) => {
isPlaying,
duration,
size,
strokeWidth,
// https://github.com/vydimitrov/react-countdown-circle-timer/pull/82#issuecomment-774961578
// Find the larger strokeWidth and calculate the path.
strokeWidth: Math.max(strokeWidth, trailStrokeWidth ?? 0),
colors,
initialRemainingTime,
onComplete,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ exports[`snapshot tests renders with different trail stroke width 1`] = `
xmlns="http://www.w3.org/2000/svg"
>
<path
d="m 90,6
a 84,84 0 1,0 0,168
a 84,84 0 1,0 0,-168"
d="m 90,8
a 82,82 0 1,0 0,164
a 82,82 0 1,0 0,-164"
fill="none"
stroke="#d9d9d9"
strokeWidth={16}
/>
<path
d="m 90,6
a 84,84 0 1,0 0,168
a 84,84 0 1,0 0,-168"
d="m 90,8
a 82,82 0 1,0 0,164
a 82,82 0 1,0 0,-164"
fill="none"
stroke="rgba(0, 71, 119, 1)"
strokeDasharray={527.7875658030853}
strokeDasharray={515.221195188726}
strokeDashoffset={0}
strokeLinecap="round"
strokeWidth={12}
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/components/CountdownCircleTimer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const CountdownCircleTimer = ({
} = useCountdown({
isPlaying,
size,
strokeWidth,
// https://github.com/vydimitrov/react-countdown-circle-timer/pull/82#issuecomment-774961578
// Find the larger strokeWidth and calculate the path.
strokeWidth: Math.max(strokeWidth, trailStrokeWidth ?? 0),
duration,
initialRemainingTime,
colors,
Expand Down

0 comments on commit b3d3aab

Please sign in to comment.