Merge pull request #47 from baz/master

Ability to customise fade duration
This commit is contained in:
Danny Greg 2012-11-06 14:52:41 -08:00
Родитель 2763201ad1 c58b60fc3b
Коммит 1816ef692e
2 изменённых файлов: 7 добавлений и 18 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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 {