Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Nicer scroll indicator animations during open/close.

  • Loading branch information...
commit 0f700f80bbcd8f55d59c3cd2a071a023f156295a 1 parent 8ab56be
@matej authored
Showing with 18 additions and 5 deletions.
  1. +18 −5 MBPullDownController/MBPullDownController.m
View
23 MBPullDownController/MBPullDownController.m
@@ -158,22 +158,35 @@ - (void)setOpen:(BOOL)open animated:(BOOL)animated {
CGFloat offset = open ? self.view.bounds.size.height - self.openBottomOffset : self.closedTopOffset;
- void (^updateInserts)(void) = ^{
+ void (^updateContentInset)(void) = ^{
UIEdgeInsets contentInset = scrollView.contentInset;
contentInset.top = offset;
scrollView.contentInset = contentInset;
+ };
+
+ void (^updateScrollInsets)(void) = ^{
UIEdgeInsets scrollIndicatorInsets = scrollView.scrollIndicatorInsets;
scrollIndicatorInsets.top = offset;
scrollView.scrollIndicatorInsets = scrollIndicatorInsets;
};
+ void (^updateBothInsets)(void) = ^{
+ updateContentInset();
+ updateScrollInsets();
+ };
+
if (open) {
- updateInserts();
+ updateContentInset();
+ if (animated) {
+ [UIView animateWithDuration:.3f animations:updateScrollInsets];
+ } else {
+ updateScrollInsets();
+ }
} else {
if (animated) {
- [UIView animateWithDuration:.3f animations:updateInserts];
+ [UIView animateWithDuration:.3f animations:updateBothInsets];
} else {
- updateInserts();
+ updateBothInsets();
}
}
@@ -330,7 +343,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
CGPoint oldValue = [[change valueForKey:NSKeyValueChangeOldKey] CGPointValue];
CGPoint newValue = [[change valueForKey:NSKeyValueChangeNewKey] CGPointValue];
CGPoint adjusted = newValue;
- // Simulate the scroll view elasticity effect while dragging in the open state
+ // Simulate the scroll view elasticity effect while dragging in the open state
if (self.open && [self scrollView].dragging) {
CGFloat delta = roundf((oldValue.y - newValue.y) / 3);
adjusted = CGPointMake(newValue.x, oldValue.y - delta);
Please sign in to comment.
Something went wrong with that request. Please try again.