Skip to content

Commit

Permalink
[ProgressIndicator] Improved the smoothness of the animation when ina…
Browse files Browse the repository at this point in the history
…ctive track's ends are close.

Resolves #4124

PiperOrigin-RevId: 621620538
  • Loading branch information
pekingme authored and paulfthomas committed Apr 3, 2024
1 parent e8452fb commit 2a80e16
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,20 @@ private void drawArc(
}

float displayedCornerRadiusInDegree = (float) toDegrees(displayedCornerRadius / adjustedRadius);

if (startFraction == 0 && arcFraction >= 1 - ROUND_CAP_RAMP_DOWN_THRESHHOLD) {
float arcFractionOverRoundCapThreshold = arcFraction - (1 - ROUND_CAP_RAMP_DOWN_THRESHHOLD);
if (arcFractionOverRoundCapThreshold >= 0) {
// Increases the arc length to hide the round cap at the ends when the active indicator is
// forming a full circle.
arcFraction +=
(arcFraction - (1 - ROUND_CAP_RAMP_DOWN_THRESHHOLD))
* (2 * displayedCornerRadiusInDegree / 360)
float increasedArcFraction =
arcFractionOverRoundCapThreshold
* displayedCornerRadiusInDegree
/ 180
/ ROUND_CAP_RAMP_DOWN_THRESHHOLD;
arcFraction += increasedArcFraction;
// Offsets the start fraction to make the inactive track's ends connect at 0%.
if (!shouldDrawActiveIndicator) {
startFraction -= increasedArcFraction / 2;
}
}

// Scale start and arc fraction for ESCAPE animation.
Expand Down

0 comments on commit 2a80e16

Please sign in to comment.