Skip to content

Commit

Permalink
Merge pull request github#122 from jagreenwood/tuiscrollview-delegate…
Browse files Browse the repository at this point in the history
…-scrollViewDidEndDecelerating

Added TUIScrollView delegate method scrollViewDidEndDecelerating:
  • Loading branch information
jwilling committed Oct 19, 2012
2 parents f5ade96 + e35f7e5 commit 5f9b5e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/UIKit/TUIScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ typedef enum {
unsigned int delegateScrollViewDidScroll:1;
unsigned int delegateScrollViewWillBeginDragging:1;
unsigned int delegateScrollViewDidEndDragging:1;
unsigned int delegateScrollViewDidEndDecelerating:1;
unsigned int delegateScrollViewWillShowScrollIndicator:1;
unsigned int delegateScrollViewDidShowScrollIndicator:1;
unsigned int delegateScrollViewWillHideScrollIndicator:1;
Expand Down Expand Up @@ -194,6 +195,7 @@ typedef enum {
- (void)scrollViewDidScroll:(TUIScrollView *)scrollView;
- (void)scrollViewWillBeginDragging:(TUIScrollView *)scrollView;
- (void)scrollViewDidEndDragging:(TUIScrollView *)scrollView;
- (void)scrollViewDidEndDecelerating:(TUIScrollView *)scrollView;

- (void)scrollView:(TUIScrollView *)scrollView willShowScrollIndicator:(TUIScrollViewIndicator)indicator;
- (void)scrollView:(TUIScrollView *)scrollView didShowScrollIndicator:(TUIScrollViewIndicator)indicator;
Expand Down
7 changes: 7 additions & 0 deletions lib/UIKit/TUIScrollView.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ - (void)setDelegate:(id<TUIScrollViewDelegate>)d
_scrollViewFlags.delegateScrollViewDidScroll = [_delegate respondsToSelector:@selector(scrollViewDidScroll:)];
_scrollViewFlags.delegateScrollViewWillBeginDragging = [_delegate respondsToSelector:@selector(scrollViewWillBeginDragging:)];
_scrollViewFlags.delegateScrollViewDidEndDragging = [_delegate respondsToSelector:@selector(scrollViewDidEndDragging:)];
_scrollViewFlags.delegateScrollViewDidEndDecelerating = [_delegate respondsToSelector:@selector(scrollViewDidEndDecelerating:)];
_scrollViewFlags.delegateScrollViewWillShowScrollIndicator = [_delegate respondsToSelector:@selector(scrollView:willShowScrollIndicator:)];
_scrollViewFlags.delegateScrollViewDidShowScrollIndicator = [_delegate respondsToSelector:@selector(scrollView:didShowScrollIndicator:)];
_scrollViewFlags.delegateScrollViewWillHideScrollIndicator = [_delegate respondsToSelector:@selector(scrollView:willHideScrollIndicator:)];
Expand Down Expand Up @@ -772,6 +773,9 @@ - (void)_updateBounce

if(fabsf(_bounce.vy) < 1.0 && fabsf(_bounce.y) < 1.0 && fabsf(_bounce.vx) < 1.0 && fabsf(_bounce.x) < 1.0) {
[self _stopTimer];
if (_scrollViewFlags.delegateScrollViewDidEndDecelerating) {
[_delegate scrollViewDidEndDecelerating:self];
}
}

[self _updateScrollKnobs];
Expand Down Expand Up @@ -1170,6 +1174,9 @@ - (void)scrollWheel:(NSEvent *)event
// ignore - let the bounce finish (_updateBounce will kill the timer when it's ready)
} else {
[self _stopTimer];
if (_scrollViewFlags.delegateScrollViewDidEndDecelerating) {
[_delegate scrollViewDidEndDecelerating:self];
}
}
}
break;
Expand Down

0 comments on commit 5f9b5e6

Please sign in to comment.