Skip to content

Commit

Permalink
[ProgressView] Reverse the start point and end point of indeterminate…
Browse files Browse the repository at this point in the history
… progress stroke to make it aligning with the animation direction.

PiperOrigin-RevId: 318494534
  • Loading branch information
wenyuzhang666 authored and material-automation committed Jun 26, 2020
1 parent 7e25289 commit a411506
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
27 changes: 14 additions & 13 deletions components/ProgressView/src/MDCProgressView.m
Original file line number Diff line number Diff line change
Expand Up @@ -425,18 +425,18 @@ - (void)startAnimatingBar {
[self.indeterminateProgressView.shapeLayer removeAllAnimations];

// The numeric values used here conform to https://material.io/components/progress-indicators.
CABasicAnimation *progressViewHead = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
progressViewHead.fromValue = @1;
progressViewHead.toValue = @0;
CABasicAnimation *progressViewHead = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
progressViewHead.fromValue = @0;
progressViewHead.toValue = @1;
progressViewHead.duration = 0.75;
progressViewHead.timingFunction =
[[CAMediaTimingFunction alloc] initWithControlPoints:0.20f:0.00f:0.80f:1.00f];
progressViewHead.fillMode = kCAFillModeForwards;
progressViewHead.fillMode = kCAFillModeBackwards;

CABasicAnimation *progressViewTail = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
CABasicAnimation *progressViewTail = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
progressViewTail.beginTime = 0.333;
progressViewTail.fromValue = @1;
progressViewTail.toValue = @0;
progressViewTail.fromValue = @0;
progressViewTail.toValue = @1;
progressViewTail.duration = 0.85;
progressViewTail.timingFunction =
[[CAMediaTimingFunction alloc] initWithControlPoints:0.40f:0.00f:1.00f:1.00f];
Expand All @@ -451,20 +451,20 @@ - (void)startAnimatingBar {
forKey:@"kProgressViewAnimation"];

CABasicAnimation *indeterminateProgressViewHead =
[CABasicAnimation animationWithKeyPath:@"strokeStart"];
indeterminateProgressViewHead.fromValue = @1;
indeterminateProgressViewHead.toValue = @0;
[CABasicAnimation animationWithKeyPath:@"strokeEnd"];
indeterminateProgressViewHead.fromValue = @0;
indeterminateProgressViewHead.toValue = @1;
indeterminateProgressViewHead.duration = 0.567;
indeterminateProgressViewHead.beginTime = 1;
indeterminateProgressViewHead.timingFunction =
[[CAMediaTimingFunction alloc] initWithControlPoints:0.00f:0.00f:0.65f:1.00f];
indeterminateProgressViewHead.fillMode = kCAFillModeBackwards;

CABasicAnimation *indeterminateProgressViewTail =
[CABasicAnimation animationWithKeyPath:@"strokeEnd"];
[CABasicAnimation animationWithKeyPath:@"strokeStart"];
indeterminateProgressViewTail.beginTime = 1.267;
indeterminateProgressViewTail.fromValue = @1;
indeterminateProgressViewTail.toValue = @0;
indeterminateProgressViewTail.fromValue = @0;
indeterminateProgressViewTail.toValue = @1;
indeterminateProgressViewTail.duration = 0.533;
indeterminateProgressViewTail.timingFunction =
[[CAMediaTimingFunction alloc] initWithControlPoints:0.10f:0.00f:0.45f:1.00f];
Expand All @@ -475,6 +475,7 @@ - (void)startAnimatingBar {
@[ indeterminateProgressViewHead, indeterminateProgressViewTail ];
indeterminateProgressViewAnimationGroup.duration = 1.8;
indeterminateProgressViewAnimationGroup.repeatCount = HUGE_VALF;

[self.indeterminateProgressView.shapeLayer addAnimation:indeterminateProgressViewAnimationGroup
forKey:@"kIndeterminateProgressViewAnimation"];
}
Expand Down
6 changes: 3 additions & 3 deletions components/ProgressView/src/private/MDCProgressGradientView.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ - (void)layoutSubviews {
CGPoint rightPoint = CGPointMake(CGRectGetWidth(self.gradientLayer.bounds),
CGRectGetMidY(self.gradientLayer.bounds));
if (self.mdf_effectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
[path moveToPoint:leftPoint];
[path addLineToPoint:rightPoint];
} else {
[path moveToPoint:rightPoint];
[path addLineToPoint:leftPoint];
} else {
[path moveToPoint:leftPoint];
[path addLineToPoint:rightPoint];
}
self.shapeLayer.frame = self.gradientLayer.bounds;
self.shapeLayer.strokeColor = UIColor.blackColor.CGColor;
Expand Down

0 comments on commit a411506

Please sign in to comment.