mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Go into full range mode if a scroll happens
This commit is contained in:
@@ -690,6 +690,8 @@ static NSString * const kCellReuseIdentifier = @"_ASCollectionViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||||
{
|
{
|
||||||
|
[_rangeController scrollViewDidScroll:scrollView];
|
||||||
|
|
||||||
for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) {
|
for (_ASCollectionViewCell *collectionCell in _cellsForVisibilityUpdates) {
|
||||||
// Only nodes that respond to the selector are added to _cellsForVisibilityUpdates
|
// Only nodes that respond to the selector are added to _cellsForVisibilityUpdates
|
||||||
[[collectionCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged
|
[[collectionCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged
|
||||||
|
|||||||
@@ -602,6 +602,8 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||||
{
|
{
|
||||||
|
[_rangeController scrollViewDidScroll:scrollView];
|
||||||
|
|
||||||
for (_ASTableViewCell *tableCell in _cellsForVisibilityUpdates) {
|
for (_ASTableViewCell *tableCell in _cellsForVisibilityUpdates) {
|
||||||
[[tableCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged
|
[[tableCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventVisibleRectChanged
|
||||||
inScrollView:scrollView
|
inScrollView:scrollView
|
||||||
|
|||||||
@@ -45,6 +45,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
- (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection;
|
- (void)visibleNodeIndexPathsDidChangeWithScrollDirection:(ASScrollDirection)scrollDirection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify the range controller that a scroll view did scroll.
|
||||||
|
*/
|
||||||
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the sized node for `indexPath` as a subview of `contentView`.
|
* Add the sized node for `indexPath` as a subview of `contentView`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -61,11 +61,16 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
|
|
||||||
#pragma mark - Core visible node range managment API
|
#pragma mark - Core visible node range managment API
|
||||||
|
|
||||||
|
+ (BOOL)isFirstRangeUpdateForRangeMode:(ASLayoutRangeMode)rangeMode
|
||||||
|
{
|
||||||
|
return (rangeMode == ASLayoutRangeModeInvalid);
|
||||||
|
}
|
||||||
|
|
||||||
+ (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState
|
+ (ASLayoutRangeMode)rangeModeForInterfaceState:(ASInterfaceState)interfaceState
|
||||||
currentRangeMode:(ASLayoutRangeMode)currentRangeMode
|
currentRangeMode:(ASLayoutRangeMode)currentRangeMode
|
||||||
{
|
{
|
||||||
BOOL isVisible = (ASInterfaceStateIncludesVisible(interfaceState));
|
BOOL isVisible = (ASInterfaceStateIncludesVisible(interfaceState));
|
||||||
BOOL isFirstRangeUpdate = (currentRangeMode == ASLayoutRangeModeInvalid);
|
BOOL isFirstRangeUpdate = [self isFirstRangeUpdateForRangeMode:currentRangeMode];
|
||||||
if (!isVisible || isFirstRangeUpdate) {
|
if (!isVisible || isFirstRangeUpdate) {
|
||||||
return ASLayoutRangeModeMinimum;
|
return ASLayoutRangeModeMinimum;
|
||||||
}
|
}
|
||||||
@@ -94,6 +99,15 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
|
|||||||
[self scheduleRangeUpdate];
|
[self scheduleRangeUpdate];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
||||||
|
{
|
||||||
|
// If a scroll happenes the current range mode needs to go to full
|
||||||
|
BOOL isFirstRangeUpdate = [[self class] isFirstRangeUpdateForRangeMode:_currentRangeMode];
|
||||||
|
if (!isFirstRangeUpdate && _currentRangeMode != ASLayoutRangeModeFull) {
|
||||||
|
[self scheduleRangeUpdate];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode
|
- (void)updateCurrentRangeWithMode:(ASLayoutRangeMode)rangeMode
|
||||||
{
|
{
|
||||||
if (_currentRangeMode != rangeMode) {
|
if (_currentRangeMode != rangeMode) {
|
||||||
|
|||||||
Reference in New Issue
Block a user