mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-12 01:10:49 +00:00
[AS(Table|Collection)View] make scrollDirection transform aware
This commit is contained in:
parent
8d9d5a0cc3
commit
39cd3afa0d
@ -524,7 +524,9 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
||||
} else {
|
||||
scrollVelocity = _deceleratingVelocity;
|
||||
}
|
||||
return [self _scrollDirectionForVelocity:scrollVelocity];
|
||||
|
||||
ASScrollDirection scrollDirection = [self _scrollDirectionForVelocity:scrollVelocity];
|
||||
return ASScrollDirectionApplyTransform(scrollDirection, self.transform);
|
||||
}
|
||||
|
||||
- (ASScrollDirection)_scrollDirectionForVelocity:(CGPoint)scrollVelocity
|
||||
|
||||
@ -571,7 +571,8 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
||||
} else {
|
||||
scrollVelocity = _deceleratingVelocity;
|
||||
}
|
||||
return [self _scrollDirectionForVelocity:scrollVelocity];
|
||||
ASScrollDirection scrollDirection = [self _scrollDirectionForVelocity:scrollVelocity];
|
||||
return ASScrollDirectionApplyTransform(scrollDirection, self.transform);
|
||||
}
|
||||
|
||||
- (ASScrollDirection)_scrollDirectionForVelocity:(CGPoint)velocity
|
||||
|
||||
@ -10,6 +10,8 @@
|
||||
|
||||
#import "ASBaseDefines.h"
|
||||
|
||||
#include <CoreGraphics/CGAffineTransform.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
typedef NS_OPTIONS(NSInteger, ASScrollDirection) {
|
||||
@ -32,6 +34,7 @@ BOOL ASScrollDirectionContainsRight(ASScrollDirection scrollDirection);
|
||||
BOOL ASScrollDirectionContainsLeft(ASScrollDirection scrollDirection);
|
||||
BOOL ASScrollDirectionContainsUp(ASScrollDirection scrollDirection);
|
||||
BOOL ASScrollDirectionContainsDown(ASScrollDirection scrollDirection);
|
||||
ASScrollDirection ASScrollDirectionApplyTransform(ASScrollDirection scrollDirection, CGAffineTransform transform);
|
||||
|
||||
ASDISPLAYNODE_EXTERN_C_END
|
||||
|
||||
|
||||
@ -34,3 +34,30 @@ BOOL ASScrollDirectionContainsUp(ASScrollDirection scrollDirection) {
|
||||
BOOL ASScrollDirectionContainsDown(ASScrollDirection scrollDirection) {
|
||||
return (scrollDirection & ASScrollDirectionDown) != 0;
|
||||
}
|
||||
|
||||
ASScrollDirection ASScrollDirectionInvertHorizontally(ASScrollDirection scrollDirection) {
|
||||
if (scrollDirection == ASScrollDirectionRight) {
|
||||
return ASScrollDirectionLeft;
|
||||
} else if (scrollDirection == ASScrollDirectionLeft) {
|
||||
return ASScrollDirectionRight;
|
||||
}
|
||||
return scrollDirection;
|
||||
}
|
||||
|
||||
ASScrollDirection ASScrollDirectionInvertVertically(ASScrollDirection scrollDirection) {
|
||||
if (scrollDirection == ASScrollDirectionUp) {
|
||||
return ASScrollDirectionDown;
|
||||
} else if (scrollDirection == ASScrollDirectionDown) {
|
||||
return ASScrollDirectionUp;
|
||||
}
|
||||
return scrollDirection;
|
||||
}
|
||||
|
||||
ASScrollDirection ASScrollDirectionApplyTransform(ASScrollDirection scrollDirection, CGAffineTransform transform) {
|
||||
if ((transform.a < 0) && ASScrollDirectionContainsHorizontalDirection(scrollDirection)) {
|
||||
return ASScrollDirectionInvertHorizontally(scrollDirection);
|
||||
} else if ((transform.d < 0) && ASScrollDirectionContainsVerticalDirection(scrollDirection)) {
|
||||
return ASScrollDirectionInvertVertically(scrollDirection);
|
||||
}
|
||||
return scrollDirection;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user