Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGListAdapter support for scrollViewDidEndDecelerating #899

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The changelog for `IGListKit`. Also see the [releases](https://github.com/instag
- Added `-[IGListCollectionContext selectItemAtIndex:]` Select an item through IGListCollectionContext like `-[IGListCollectionContext deselectItemAtIndex:]`. [Marvin Nazari](https://github.com/MarvinNazari) (tbd)

- Added horizontal scrolling support to `IGListCollectionViewLayout`. [Peter Edmonston](https://github.com/edmonston) [(#857)](https://github.com/Instagram/IGListKit/pull/857)
- Added support for scrollViewDidEndDecelerating to `IGListAdapter`. [Phil Larson](https://github.com/plarson) [(#899)](https://github.com/Instagram/IGListKit/pull/899)

3.0.0
-----
Expand Down
11 changes: 11 additions & 0 deletions Source/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,17 @@ - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL
}
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
// forward this method to the delegate b/c this implementation will steal the message from the proxy
id<UIScrollViewDelegate> scrollViewDelegate = self.scrollViewDelegate;
if ([scrollViewDelegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)]) {
[scrollViewDelegate scrollViewDidEndDecelerating:scrollView];
}
NSArray<IGListSectionController *> *visibleSectionControllers = [self visibleSectionControllers];
for (IGListSectionController *sectionController in visibleSectionControllers) {
[[sectionController scrollDelegate] listAdapter:self didEndDeceleratingSectionController:sectionController];
}
}

#pragma mark - IGListCollectionContext

Expand Down
8 changes: 8 additions & 0 deletions Source/IGListScrollDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ NS_SWIFT_NAME(ListScrollDelegate)
*/
- (void)listAdapter:(IGListAdapter *)listAdapter didEndDraggingSectionController:(IGListSectionController *)sectionController willDecelerate:(BOOL)decelerate;

/**
Tells the delegate that the section controller did end decelerating on screen.

@param listAdapter The list adapter whose collection view ended decelerating.
@param sectionController The visible section controller that ended decelerating.
*/
- (void)listAdapter:(IGListAdapter *)listAdapter didEndDeceleratingSectionController:(IGListSectionController *)sectionController;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking change here.


@end

NS_ASSUME_NONNULL_END
6 changes: 6 additions & 0 deletions Source/IGListStackedSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ - (void)listAdapter:(IGListAdapter *)listAdapter didEndDraggingSectionController
}
}

- (void)listAdapter:(IGListAdapter *)listAdapter didEndDeceleratingSectionController:(IGListSectionController *)sectionController {
for (IGListSectionController *childSectionController in self.sectionControllers) {
[[childSectionController scrollDelegate] listAdapter:listAdapter didEndDeceleratingSectionController:childSectionController];
}
}

#pragma mark - IGListWorkingRangeDelegate

- (void)listAdapter:(IGListAdapter *)listAdapter sectionControllerWillEnterWorkingRange:(IGListSectionController *)sectionController {
Expand Down
3 changes: 2 additions & 1 deletion Source/Internal/IGListAdapterProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ static BOOL isInterceptedSelector(SEL sel) {
// UIScrollViewDelegate
sel == @selector(scrollViewDidScroll:) ||
sel == @selector(scrollViewWillBeginDragging:) ||
sel == @selector(scrollViewDidEndDragging:willDecelerate:)
sel == @selector(scrollViewDidEndDragging:willDecelerate:) ||
sel == @selector(scrollViewDidEndDecelerating:)
);
}

Expand Down