I am trying to get the scroll speed of a UIScrollView after the user has raised his finger so that I can trigger an event when the scroll speed drops below the threshold speed.
Apple's documentation states that scrollview speed units are in points , and I would assume that it would be per second (pts / s), for example, for the UIScrollView Delegate method - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset .
Therefore, I assumed that the units to slow down the scrolling would be dots per second per second (pts / s ^ 2) , but this does not seem to be the case.
Here are some sample parameters pulled out of the scrollable scroll view as soon as the panning gesture event ends (i.e. as soon as you lift your finger), pull from the methods - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset and - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView :
(initial displacement, target displacement, initial speed, final speed, braking, 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:
- Start offset = scrollView.contentOffset.y as soon as the finger is raised
- Target offset = targetContentOffset-> y as soon as the finger is raised, or scrollView.contentOffset.y when the scrollview is canceled.
- Initial speed = speed. And as soon as the finger rises
- Final speed = 0, because the scroll scroll scrolls until it stops naturally
- Slow = scrollView.decelerationRate as soon as the finger is raised
- Elapsed time = time between when finger is raised and when scrollview is suitable for resting
source share