-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Majorly Improve automaticallyAdjustsContentOffset #3033
Conversation
_delegateDidInsertNodes = [_delegate respondsToSelector:@selector(dataController:didInsertNodes:atIndexPaths:withAnimationOptions:)]; | ||
_delegateDidDeleteNodes = [_delegate respondsToSelector:@selector(dataController:didDeleteNodes:atIndexPaths:withAnimationOptions:)]; | ||
_delegateDidInsertSections = [_delegate respondsToSelector:@selector(dataController:didInsertSections:atIndexSet:withAnimationOptions:)]; | ||
_delegateDidDeleteSections = [_delegate respondsToSelector:@selector(dataController:didDeleteSectionsAtIndexSet:withAnimationOptions:)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All this can be removed because these methods are required i.e. enforced by compiler. Sorry @nguyenhuy if this requires a rebase but it should be simple if so!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also deleted this in #3017. I will rebase with joy if necessary!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Adlai-Holler Love it! 1 less thing to handle in #3017. Thanks a ton!
} | ||
} | ||
|
||
// We can't do this if we didn't have a top visible row before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's great that this edge case is handled.
Non-blocking feedback: I'm wondering if we should store 1 or maybe even 2 more nodes? That way we would rarely give up because all of the anchor nodes were gone. The last visible node and the one in the middle are good candidates for this purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call! For the time being, let's leave it as-is to reduce complexity since cases where they delete the anchor row will be somewhat rare, and I have a suspicion that not many people are using this flag.
|
||
if (_automaticallyAdjustsContentOffset) { | ||
[self adjustContentOffsetWithNodes:nodes atIndexPaths:indexPaths inserting:YES]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these lines are deleted based on the assumption that edits are always done in batches and so offset adjustment can be solely done in -rangeController: didEndUpdatesAnimated:completion:
?
I honestly think we should embrace this "always in batches" strategy to the point that there should be only one delegate method -rangeController:didUpdateWithChangeSet:
. It will allow us to greatly simplify ASCollectionView and ASTableView. Currently those classes need many internal states to deal with the possibility that updates can be done separately.
_delegateDidInsertNodes = [_delegate respondsToSelector:@selector(dataController:didInsertNodes:atIndexPaths:withAnimationOptions:)]; | ||
_delegateDidDeleteNodes = [_delegate respondsToSelector:@selector(dataController:didDeleteNodes:atIndexPaths:withAnimationOptions:)]; | ||
_delegateDidInsertSections = [_delegate respondsToSelector:@selector(dataController:didInsertSections:atIndexSet:withAnimationOptions:)]; | ||
_delegateDidDeleteSections = [_delegate respondsToSelector:@selector(dataController:didDeleteSectionsAtIndexSet:withAnimationOptions:)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also deleted this in #3017. I will rebase with joy if necessary!
Old system:
New system:
This removes a ton of logic where we sum up
cellNode.calculatedSize
and makes sure we handle things like section headers/footers etc.I also removed some now-unused arguments from
ASDataControllerDelegate
andASRangeControllerDelegate
.Resolves #2908