Skip to content

Commit c2e207c

Browse files
author
Junius Gunaratne
committed
[MDCInk] Update background opacity timing to match web implementation of ink
Reviewers: mtlin, ajsecord, #material_components_ios_owners Reviewed By: ajsecord, #material_components_ios_owners Projects: #material_components_ios Differential Revision: http://codereview.cc/D133
1 parent 1bb420a commit c2e207c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

components/Ink/src/private/MDCInkLayer.m

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,14 +243,20 @@ - (void)endBackgroundRipple {
243243
if (!opacityVal) {
244244
opacityVal = [NSNumber numberWithFloat:0];
245245
}
246-
247-
// The end (tap release) animation should continue at the opacity level of the start animation.
248-
CGFloat enterDuration = (1 - opacityVal.floatValue / _maxOpacityLevel) *
249-
kMDCInkLayerFastEnterDuration;
250-
CGFloat duration = kMDCInkLayerBaseOpacityExitDuration + enterDuration;
251-
_backgroundOpacityAnim =
252-
[self opacityAnimWithValues:@[ opacityVal, @(_maxOpacityLevel), @0 ]
253-
times:@[ @0, @(enterDuration / duration), @1.f ]];
246+
CGFloat duration = kMDCInkLayerBaseOpacityExitDuration;
247+
if ([self isBounded]) {
248+
// The end (tap release) animation should continue at the opacity level of the start animation.
249+
CGFloat enterDuration = (1 - opacityVal.floatValue / _maxOpacityLevel) *
250+
kMDCInkLayerFastEnterDuration;
251+
duration += enterDuration;
252+
_backgroundOpacityAnim =
253+
[self opacityAnimWithValues:@[ opacityVal, @(_maxOpacityLevel), @0 ]
254+
times:@[ @0, @(enterDuration / duration), @1.f ]];
255+
} else {
256+
_backgroundOpacityAnim =
257+
[self opacityAnimWithValues:@[ opacityVal, @0 ]
258+
times:@[ @0, @1.f ]];
259+
}
254260
_backgroundOpacityAnim.duration = duration;
255261
[_backgroundRippleLayer addAnimation:_backgroundOpacityAnim
256262
forKey:kMDCInkLayerBackgroundOpacityAnim];

0 commit comments

Comments
 (0)