mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-19 21:00:10 +00:00
Merge pull request #789 from Adlai-Holler/FixAnimationEnabledness
Avoid overwriting areAnimationsEnabled if app changes it again during animation
This commit is contained in:
commit
ed63577370
@ -790,25 +790,13 @@ static BOOL _isInterceptedSelector(SEL sel)
|
|||||||
return; // if the asyncDataSource has become invalid while we are processing, ignore this request to avoid crashes
|
return; // if the asyncDataSource has become invalid while we are processing, ignore this request to avoid crashes
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL animationsEnabled = NO;
|
ASPerformBlockWithoutAnimation(!animated, ^{
|
||||||
|
[super performBatchUpdates:^{
|
||||||
if (!animated) {
|
for (dispatch_block_t block in _batchUpdateBlocks) {
|
||||||
animationsEnabled = [UIView areAnimationsEnabled];
|
block();
|
||||||
[UIView setAnimationsEnabled:NO];
|
}
|
||||||
}
|
} completion:completion];
|
||||||
|
});
|
||||||
[super performBatchUpdates:^{
|
|
||||||
[_batchUpdateBlocks enumerateObjectsUsingBlock:^(dispatch_block_t block, NSUInteger idx, BOOL *stop) {
|
|
||||||
block();
|
|
||||||
}];
|
|
||||||
} completion:^(BOOL finished) {
|
|
||||||
if (!animated) {
|
|
||||||
[UIView setAnimationsEnabled:animationsEnabled];
|
|
||||||
}
|
|
||||||
if (completion) {
|
|
||||||
completion(finished);
|
|
||||||
}
|
|
||||||
}];
|
|
||||||
|
|
||||||
[_batchUpdateBlocks removeAllObjects];
|
[_batchUpdateBlocks removeAllObjects];
|
||||||
_performingBatchUpdates = NO;
|
_performingBatchUpdates = NO;
|
||||||
|
|||||||
@ -180,26 +180,6 @@ 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (Class)dataControllerClass
|
+ (Class)dataControllerClass
|
||||||
{
|
{
|
||||||
return [ASChangeSetDataController class];
|
return [ASChangeSetDataController class];
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <CoreGraphics/CGBase.h>
|
#include <CoreGraphics/CGBase.h>
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
#import "ASBaseDefines.h"
|
#import "ASBaseDefines.h"
|
||||||
|
|
||||||
ASDISPLAYNODE_EXTERN_C_BEGIN
|
ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||||
@ -27,6 +28,23 @@ CGFloat ASRoundPixelValue(CGFloat f);
|
|||||||
|
|
||||||
ASDISPLAYNODE_EXTERN_C_END
|
ASDISPLAYNODE_EXTERN_C_END
|
||||||
|
|
||||||
|
/**
|
||||||
|
@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
|
||||||
|
*/
|
||||||
|
ASDISPLAYNODE_INLINE void ASPerformBlockWithoutAnimation(BOOL withoutAnimation, void (^block)()) {
|
||||||
|
if (withoutAnimation) {
|
||||||
|
[UIView performWithoutAnimation:block];
|
||||||
|
} else {
|
||||||
|
block();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@interface NSIndexPath (ASInverseComparison)
|
@interface NSIndexPath (ASInverseComparison)
|
||||||
- (NSComparisonResult)asdk_inverseCompare:(NSIndexPath *)otherIndexPath;
|
- (NSComparisonResult)asdk_inverseCompare:(NSIndexPath *)otherIndexPath;
|
||||||
@end
|
@end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user