Skip to content

Commit

Permalink
Fix dimming for low maximum to minimum height differences
Browse files Browse the repository at this point in the history
  • Loading branch information
felixLam committed Jul 8, 2016
1 parent 080620c commit 92c1a2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ISHPullUp/ISHPullUpViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ typedef NS_ENUM(NSUInteger, ISHPullUpBottomLayoutMode) {
/// Set to nil to disable dimming. Default is black with 40% alpha.
@property (nonatomic, nullable) UIColor *dimmingColor;

/// The threshold at which the content should be dimmed relative to the maximum height. Default is 0.5.
/// The threshold at which the content should be dimmed relative to the
/// difference between minimum and maximum height. Default is 0.5 meaning
/// that dimming will start half way between min and max height.
@property (nonatomic) CGFloat dimmingThreshold;

/// Returns the current model value for the height of the bottomViewController.
Expand Down
5 changes: 3 additions & 2 deletions ISHPullUp/ISHPullUpViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ - (void)setBottomHeight:(CGFloat)bottomHeight animated:(BOOL)animated {
}
CGFloat oldHeight = self.bottomHeight;
self.bottomHeight = bottomHeight;

BOOL dimmingViewHidden = (self.bottomHeight < self.dimmingThreshold * self.maximumBottomHeightCached);
CGFloat heightOverMinimum = self.bottomHeight - self.minimumBottomHeightCached;
CGFloat maximumHeightOverMinimum = self.maximumBottomHeightCached - self.minimumBottomHeightCached;
BOOL dimmingViewHidden = (heightOverMinimum < (self.dimmingThreshold * maximumHeightOverMinimum));
void (^updateBlock)();
updateBlock = ^{
// setup (hide) dimming view with oldheight
Expand Down

0 comments on commit 92c1a2b

Please sign in to comment.