pronebird / UIScrollView-InfiniteScroll

UIScrollView ∞ scroll category
MIT License
1.06k stars 148 forks source link

infiniteScrollTriggerOffset does not trigger unless you stop scrolling #58

Open nothingimportant55 opened 7 years ago

nothingimportant55 commented 7 years ago

It seems that infiniteScrollTriggerOffset does not kick in and check to see if a new load should occur unless you pass the offset AND stop scrolling. For example, if you very slowly and steadily just scroll from the top of your UITableView until you reach the bottom, a load will not trigger when you cross the offset point, you must stop first. Is something perhaps running on the UI thread that shouldn't be?

Thanks!

pronebird commented 7 years ago

Hi,

If you do not pass an offset to infiniteScrollTriggerOffset then it's zero which is the same as the very bottom of your scroll view.

What you see happens because we schedule handler's execution using performSelector on default run loop. That has something to do with UITrackingRunLoopMode which delays default run loop approximately until table deceleration. At least visually deceleration coincides with when default run loop executes the selector. That's been pretty consistent across iOS versions.

The reason why it's done this way is to avoid interfering with user. Usually animations look smoother and interaction feels more natural when user does not play with table view. There are still glitches though, user may scroll the table after handler block fired causing undesired animations on reused cells.

We can try to replace performSelector with regular call and see if that causes any problems, but last time I checked that was still the case.

Reference: https://github.com/pronebird/UIScrollView-InfiniteScroll/blob/master/Classes/UIScrollView%2BInfiniteScroll.m#L459

eclair4151 commented 5 years ago

i'm having the same issue. is there a way around this?