mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-28 08:30:11 +00:00
Merge pull request #445 from levi/master
Prevent UITableView insertion/deletion animations by default
This commit is contained in:
commit
7e50f05dfd
@ -15,7 +15,7 @@
|
|||||||
#import "ASDisplayNodeInternal.h"
|
#import "ASDisplayNodeInternal.h"
|
||||||
#import "ASBatchFetching.h"
|
#import "ASBatchFetching.h"
|
||||||
|
|
||||||
const static NSUInteger kASCollectionViewAnimationNone = 0;
|
const static NSUInteger kASCollectionViewAnimationNone = UITableViewRowAnimationNone;
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
@ -132,6 +132,26 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
|
|
||||||
@implementation ASTableView
|
@implementation ASTableView
|
||||||
|
|
||||||
|
/**
|
||||||
|
@summary Conditionally performs UIView geometry changes in the given block without animation.
|
||||||
|
|
||||||
|
Used primarily to circumvent UITableView forcing insertion animations when explicitly told not to via
|
||||||
|
`UITableViewRowAnimationNone`. More info: https://github.com/facebook/AsyncDisplayKit/pull/445
|
||||||
|
|
||||||
|
@param withoutAnimation Set to `YES` to perform given block without animation
|
||||||
|
@param block Perform UIView geometry changes within the passed block
|
||||||
|
*/
|
||||||
|
void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
||||||
|
if (withoutAnimation) {
|
||||||
|
BOOL animationsEnabled = [UIView areAnimationsEnabled];
|
||||||
|
[UIView setAnimationsEnabled:NO];
|
||||||
|
block();
|
||||||
|
[UIView setAnimationsEnabled:animationsEnabled];
|
||||||
|
} else {
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Lifecycle
|
#pragma mark Lifecycle
|
||||||
|
|
||||||
@ -498,28 +518,40 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
|
|
||||||
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
BOOL preventAnimation = animationOption == UITableViewRowAnimationNone;
|
||||||
|
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||||
|
[super insertRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
- (void)rangeController:(ASRangeController *)rangeController didDeleteNodesAtIndexPaths:(NSArray *)indexPaths withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
|
|
||||||
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
BOOL preventAnimation = animationOption == UITableViewRowAnimationNone;
|
||||||
|
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||||
|
[super deleteRowsAtIndexPaths:indexPaths withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
- (void)rangeController:(ASRangeController *)rangeController didInsertSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
|
|
||||||
[super insertSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
BOOL preventAnimation = animationOption == UITableViewRowAnimationNone;
|
||||||
|
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||||
|
[super insertSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
- (void)rangeController:(ASRangeController *)rangeController didDeleteSectionsAtIndexSet:(NSIndexSet *)indexSet withAnimationOption:(ASDataControllerAnimationOptions)animationOption
|
||||||
{
|
{
|
||||||
ASDisplayNodeAssertMainThread();
|
ASDisplayNodeAssertMainThread();
|
||||||
|
|
||||||
[super deleteSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
BOOL preventAnimation = animationOption == UITableViewRowAnimationNone;
|
||||||
|
ASPerformBlockWithoutAnimation(preventAnimation, ^{
|
||||||
|
[super deleteSections:indexSet withRowAnimation:(UITableViewRowAnimation)animationOption];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - ASDataControllerDelegate
|
#pragma mark - ASDataControllerDelegate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user