Skip to content

Commit 5ddf405

Browse files
author
Junius Gunaratne
committed
[FlexibleHeader] When the tracking scroll view is cleared update shadow.
Reviewers: #material_components_ios_owners, featherless Reviewed By: #material_components_ios_owners, featherless Projects: #material_components_ios Differential Revision: http://codereview.cc/D137
1 parent 258fd9e commit 5ddf405

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

components/FlexibleHeader/src/MDCFlexibleHeaderView.m

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ - (void)fhv_shiftDisplayLinkDidFire:(CADisplayLink *)displayLink {
464464

465465
- (void)fhv_accumulatorDidChange {
466466
if (!_trackingScrollView) {
467+
// Set the shadow opacity directly.
468+
self.layer.shadowOpacity = _visibleShadowOpacity;
469+
467470
return;
468471
}
469472

@@ -698,7 +701,7 @@ - (void)statusBarShifterNeedsStatusBarAppearanceUpdate:(MDCStatusBarShifter *)st
698701
}
699702

700703
- (void)statusBarShifter:(MDCStatusBarShifter *)statusBarShifter
701-
wantsSnapshotViewAdded:(UIView *)view {
704+
wantsSnapshotViewAdded:(UIView *)view {
702705
[self addSubview:view];
703706
}
704707

@@ -735,10 +738,23 @@ - (void)setTrackingScrollView:(UIScrollView *)trackingScrollView {
735738
void (^animate)() = ^{
736739
[self fhv_updateLayout];
737740
};
741+
void (^completion)(BOOL) = ^(BOOL finished) {
742+
if (!finished) {
743+
return;
744+
}
745+
746+
// When the tracking scroll view is cleared we need a shadow update.
747+
if (!_trackingScrollView) {
748+
[self fhv_accumulatorDidChange];
749+
}
750+
};
738751
if (wasTrackingScrollView) {
739-
[UIView animateWithDuration:kTrackingScrollViewDidChangeAnimationDuration animations:animate];
752+
[UIView animateWithDuration:kTrackingScrollViewDidChangeAnimationDuration
753+
animations:animate
754+
completion:completion];
740755
} else {
741756
animate();
757+
completion(YES);
742758
}
743759
}
744760

@@ -776,7 +792,8 @@ - (void)setBehavior:(MDCFlexibleHeaderShiftBehavior)behavior {
776792
if (_behavior == behavior) {
777793
return;
778794
}
779-
BOOL needsShiftOnScreen = (_behavior != MDCFlexibleHeaderShiftBehaviorDisabled && behavior == MDCFlexibleHeaderShiftBehaviorDisabled);
795+
BOOL needsShiftOnScreen = (_behavior != MDCFlexibleHeaderShiftBehaviorDisabled &&
796+
behavior == MDCFlexibleHeaderShiftBehaviorDisabled);
780797
_behavior = behavior;
781798

782799
_statusBarShifter.enabled = self.hidesStatusBarWhenCollapsed;

0 commit comments

Comments
 (0)