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

Fix issue with swipe to delete cell gesture. #trivial #46

Merged
merged 1 commit into from
Apr 29, 2017
Merged
Changes from all 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
40 changes: 40 additions & 0 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@
return __val; \
}

#define UITABLEVIEW_RESPONDS_TO_SELECTOR() \
({ \
static BOOL superResponds; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
superResponds = [UITableView instancesRespondToSelector:_cmd]; \
}); \
superResponds; \
})

@interface UITableView (ScrollViewDelegate)

- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset;
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

@end

#pragma mark -
#pragma mark ASCellNode<->UITableViewCell bridging.

Expand Down Expand Up @@ -1173,6 +1193,10 @@ - (void)tableView:(UITableView *)tableView performAction:(nonnull SEL)action for

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewDidScroll:scrollView];
return;
}
// If a scroll happenes the current range mode needs to go to full
ASInterfaceState interfaceState = [self interfaceStateForRangeController:_rangeController];
if (ASInterfaceStateIncludesVisible(interfaceState)) {
Expand All @@ -1192,6 +1216,10 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewWillEndDragging:scrollView withVelocity:velocity targetContentOffset:targetContentOffset];
return;
}
CGPoint contentOffset = scrollView.contentOffset;
_deceleratingVelocity = CGPointMake(
contentOffset.x - ((targetContentOffset != NULL) ? targetContentOffset->x : 0),
Expand All @@ -1210,6 +1238,10 @@ - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoi

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewDidEndDecelerating:scrollView];
return;
}
_deceleratingVelocity = CGPointZero;

if (_asyncDelegateFlags.scrollViewDidEndDecelerating) {
Expand All @@ -1219,6 +1251,10 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewWillBeginDragging:scrollView];
return;
}
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventWillBeginDragging
inScrollView:scrollView
Expand All @@ -1231,6 +1267,10 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
return;
}
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventDidEndDragging
inScrollView:scrollView
Expand Down