Skip to content

Commit

Permalink
Remove clipping view (#5897)
Browse files Browse the repository at this point in the history
### Context
In working on navigation drawer I noticed the addition of the clippingScrollView. This additional view just makes the component more complex with no known benefit. This change removes that view in order to simply the component and remove the extra subview in the hierarchy.
### The problem
Adding the clippingScrollView adds extra complexity to the navigation drawer.
### The fix
Remove the clipping scroll view.
  • Loading branch information
codeman7 committed Dec 5, 2018
1 parent f8d595e commit be33ef5
Showing 1 changed file with 1 addition and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ @interface MDCBottomDrawerContainerViewController () <UIScrollViewDelegate>
// The main scroll view.
@property(nonatomic, readonly) UIScrollView *scrollView;

// View that functions as the superview of |scrollView|. Used to clip the top of the scroll view.
@property(nonatomic, readonly) UIView *scrollViewClippingView;

// The top header bottom shadow layer.
@property(nonatomic) MDCShadowLayer *headerShadowLayer;

Expand All @@ -153,7 +150,6 @@ - (CGFloat)calculateInitialDrawerFactor;

@implementation MDCBottomDrawerContainerViewController {
UIScrollView *_scrollView;
UIView *_scrollViewClippingView;
CGFloat _contentHeaderTopInset;
CGFloat _contentHeightSurplus;
CGFloat _addedContentHeight;
Expand Down Expand Up @@ -394,8 +390,7 @@ - (void)viewDidLoad {

self.view.backgroundColor = [UIColor clearColor];

[self.view addSubview:self.scrollViewClippingView];
[self.scrollViewClippingView addSubview:self.scrollView];
[self.view addSubview:self.scrollView];

// Top header shadow layer starts as hidden.
self.headerShadowLayer.hidden = YES;
Expand Down Expand Up @@ -425,12 +420,7 @@ - (void)viewWillLayoutSubviews {

// Layout the clipping view and the scroll view.
if (self.currentlyFullscreen) {
CGRect scrollViewClippingViewFrame = self.presentingViewBounds;
scrollViewClippingViewFrame.origin.y = self.topHeaderHeight;
scrollViewClippingViewFrame.size.height -= self.topHeaderHeight;
self.scrollViewClippingView.frame = scrollViewClippingViewFrame;
CGRect scrollViewFrame = self.presentingViewBounds;
scrollViewFrame.origin.y = -self.topHeaderHeight;
self.scrollView.frame = scrollViewFrame;
} else {
CGRect scrollViewFrame = self.presentingViewBounds;
Expand All @@ -439,7 +429,6 @@ - (void)viewWillLayoutSubviews {
self.presentingViewBounds.size.height / 2;
scrollViewFrame.size.height += heightSurplusForSpringAnimationOvershooting;
}
self.scrollViewClippingView.frame = scrollViewFrame;
self.scrollView.frame = scrollViewFrame;
}

Expand Down Expand Up @@ -595,14 +584,12 @@ - (void)updateContentHeaderWithTransitionToTop:(CGFloat)headerTransitionToTop
// is shown in fullscreen.
[contentHeaderView removeFromSuperview];
[self.view addSubview:contentHeaderView];
self.scrollViewClippingView.clipsToBounds = YES;
[self.view setNeedsLayout];
} else if (!self.currentlyFullscreen && contentHeaderView.superview != self.scrollView) {
// The content header should be scrolled together with the rest of the content when the drawer
// is not in fullscreen.
[contentHeaderView removeFromSuperview];
[self.scrollView addSubview:contentHeaderView];
self.scrollViewClippingView.clipsToBounds = NO;
[self.view setNeedsLayout];
}
CGFloat contentHeaderViewWidth = self.presentingViewBounds.size.width;
Expand Down Expand Up @@ -637,14 +624,6 @@ - (UIScrollView *)scrollView {
return _scrollView;
}

- (UIView *)scrollViewClippingView {
if (!_scrollViewClippingView) {
_scrollViewClippingView = [[UIView alloc] init];
_scrollViewClippingView.backgroundColor = [UIColor clearColor];
}
return _scrollViewClippingView;
}

- (CGFloat)contentHeaderTopInset {
if (_contentHeaderTopInset == NSNotFound) {
[self cacheLayoutCalculations];
Expand Down

0 comments on commit be33ef5

Please sign in to comment.