diff --git a/Rebel/RBLPopover.h b/Rebel/RBLPopover.h index 3a62d91..2992d66 100644 --- a/Rebel/RBLPopover.h +++ b/Rebel/RBLPopover.h @@ -95,6 +95,9 @@ typedef void (^RBLPopoverDelegateBlock)(RBLPopover *popover); // animation has successfully completed. @property (nonatomic, copy) RBLPopoverDelegateBlock didShowBlock; +// Use for animation when showing and closing the popover. +@property (nonatomic, assign) NSTimeInterval fadeDuration; + // Designated initialiser. // // Returns a newly initialised `RBLPopover`. @@ -116,16 +119,9 @@ typedef void (^RBLPopoverDelegateBlock)(RBLPopover *popover); // popover to fit on the screen, preferredEdge is used. - (void)showRelativeToRect:(CGRect)positioningRect ofView:(NSView *)positioningView preferredEdge:(CGRectEdge)preferredEdge; -// Closes the popover with the default fadeout duration (if the popover -// animates). +// Closes the popover with the `fadeDuration` (if the popover animates). - (void)close; -// Closes the popover with the given duration. If animates is set to NO the -// popover closes immediately. -// -// duration - The duration of the fade animation. -- (void)closeWithFadeoutDuration:(NSTimeInterval)duration; - // Convenience method exposed for nib files. - (IBAction)performClose:(id)sender; diff --git a/Rebel/RBLPopover.m b/Rebel/RBLPopover.m index a14596b..5735ddd 100644 --- a/Rebel/RBLPopover.m +++ b/Rebel/RBLPopover.m @@ -33,10 +33,6 @@ //*************************************************************************** -static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3; - -//*************************************************************************** - @interface RBLPopover () // The window we are using to display the popover. @@ -116,6 +112,7 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3; _backgroundViewClass = RBLPopoverBackgroundView.class; _behavior = RBLPopoverViewControllerBehaviorApplicationDefined; _animates = YES; + _fadeDuration = 0.3; return self; } @@ -289,7 +286,7 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3; }; if (self.animates) { - [NSView rbl_animateWithDuration:RBLPopoverDefaultFadeDuration animations:^{ + [NSView rbl_animateWithDuration:self.fadeDuration animations:^{ [self.popoverWindow.animator setAlphaValue:1.0]; } completion:postDisplayBlock]; } else { @@ -301,10 +298,6 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3; #pragma mark Closing - (void)close { - [self closeWithFadeoutDuration:RBLPopoverDefaultFadeDuration]; -} - -- (void)closeWithFadeoutDuration:(NSTimeInterval)duration { if (!self.shown) return; [self removeEventMonitor]; @@ -321,7 +314,7 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3; }; if (self.animates) { - [NSView rbl_animateWithDuration:duration animations:^{ + [NSView rbl_animateWithDuration:self.fadeDuration animations:^{ [self.popoverWindow.animator setAlphaValue:0.0]; } completion:windowTeardown]; } else {