I am trying to get the velocity of a scrolling UIScrollView after the user has lifted his/her finger so that I can trigger an event when the scrollview's velocity drops below a threshold velocity.
The Apple documentation states that the units for a scrollview's velocity are in points and I would guess that would be per second (pts/s), e.g., for UIScrollView Delegate method - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
.
I would therefore assume that the units for a scrollview's deceleration would be points per second per second (pts/s^2) but this does not seem to be the case.
Here are some example parameters pulled from a scrolling scroll view as soon as the pan gesture event ends (i.e., as soon as you lift your finger) pulled from methods - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
and - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
:
(Initial offset, Target offset, Initial Velocity, Final Velocity, Deceleration, Elapsed Time) =
- (364.0, 2664.5, 4.619940, 0, 0.998, 3.068916)
- (2595.5, 3288.5, 1.398724, 0, 0.998, 2.485449)
- (3094.5, 1907.0, -2.389578, 0, 0.998, 2.752163)
- (143.0, 1275.5, 2.279252, 0, 0.998, 2.718653)
where:
- Initial offset = scrollView.contentOffset.y as soon as finger is lifted
- Target offset = targetContentOffset->y as soon as finger is lifted or scrollView.contentOffset.y when scrollview is done decelerating
- Initial velocity = velocity.y as soon as finger is lifted
- Final velocity = 0 because letting scrollview scroll until it stops naturally
- Deceleration = scrollView.decelerationRate as soon as finger is lifted
- Elapsed time = time between when finger is lifted and when scrollview comes to rest