Skip to content

Commit

Permalink
Merge pull request #33 from Hitta/perform-without-animation
Browse files Browse the repository at this point in the history
Added the ability to perform certain actions without implicit animations
  • Loading branch information
sammcewan committed Dec 2, 2014
2 parents 44c671b + 95d1e5d commit d2a9d52
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions WYPopoverController/WYPopoverController.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) {
@property (nonatomic, strong, readonly) UIViewController *contentViewController;
@property (nonatomic, assign) CGSize popoverContentSize;
@property (nonatomic, assign) float animationDuration;
@property (nonatomic, assign) BOOL implicitAnimationsDisabled;

@property (nonatomic, strong) WYPopoverTheme *theme;

Expand Down Expand Up @@ -202,6 +203,11 @@ typedef NS_OPTIONS(NSUInteger, WYPopoverAnimationOptions) {
options:(WYPopoverAnimationOptions)aOptions
completion:(void (^)(void))completion;

// Misc

- (void)setPopoverContentSize:(CGSize)size animated:(BOOL)animated;
- (void)performWithoutAnimation:(void (^)(void))aBlock;

@end

////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
19 changes: 17 additions & 2 deletions WYPopoverController/WYPopoverController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,21 @@ - (void)setPopoverContentSize:(CGSize)size
[self positionPopover:YES];
}

- (void)setPopoverContentSize:(CGSize)size animated:(BOOL)animated
{
popoverContentSize_ = size;
[self positionPopover:animated];
}

- (void)performWithoutAnimation:(void (^)(void))aBlock
{
if (aBlock) {
self.implicitAnimationsDisabled = YES;
aBlock();
self.implicitAnimationsDisabled = NO;
}
}

- (void)presentPopoverFromRect:(CGRect)aRect
inView:(UIView *)aView
permittedArrowDirections:(WYPopoverArrowDirection)aArrowDirections
Expand Down Expand Up @@ -2663,7 +2678,7 @@ - (void)positionPopover:(BOOL)aAnimated

containerFrame.origin = WYPointRelativeToOrientation(containerOrigin, containerFrame.size, orientation);

if (aAnimated == YES) {
if (aAnimated == YES && !self.implicitAnimationsDisabled) {
backgroundView.frame = savedContainerFrame;
__weak __typeof__(self) weakSelf = self;
[UIView animateWithDuration:0.10f animations:^{
Expand Down Expand Up @@ -2799,7 +2814,7 @@ - (void)dismissPopoverAnimated:(BOOL)aAnimated
}
@catch (NSException * __unused exception) {}

if (aAnimated)
if (aAnimated && !self.implicitAnimationsDisabled)
{
[UIView animateWithDuration:duration animations:^{
__typeof__(self) strongSelf = weakSelf;
Expand Down

0 comments on commit d2a9d52

Please sign in to comment.