SwiftUI and infinite scroll

I searched but I can not find anywhere how to setup infinite scroll with SwiftUI
Does SwiftUI support this feature?

I cannot comment on the new SwiftUI libraries, I havent used them yet, but I have implemented this functionality using the old Cocoa classes. My solution used NSScrollView which only supports finite scrolling but I extended it in a way that results in a user perceived infinite scroll.

The solution arrived at was to always set the sketch view bounds to have a 600 pts margin around visible portion. When the sketch view is scrolled the backing buffer of pixels is translated relative to its viewport, but if the displacement vector ever exceeds 500 pts in either the x or y direction then it triggers the sketch view to be re-centered around the visible portion but with the sketch views content shifted by the displacement vector to perfectly counteract the re-centering. The margin and recenter threshold values were arrived at through experimentation and gives smooth performance tailored to the inertia and velocity of a fast two finger swipe gesture.

Hi Robert,
Thank you for your answer but I know how to manage the infinite scroll without SwiftUI.
My question was really in the context of SwiftUI what is the best way to set up an infinite scroll

Hi Tof,

You can check out this article. I think it covers precisely what you want.

Hi @EphraimNetWorks
It's an interesting article :slightly_smiling_face:
... but none offense I will not use RxSwift specially with SwiftUI while Apple provides us with their own reactive framework with Combine

No problem @Tof as long as it helped you with what you were looking for.

I created a lib. It might help :slight_smile:

Terms of Service

Privacy Policy

Cookie Policy