Swiftpack.co -  olejnjak/InfiniteScroller as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
olejnjak/InfiniteScroller
Microlibrary which simplifies implementation of infinite scroll in UIScrollView
.package(url: "https://github.com/olejnjak/InfiniteScroller.git", from: "0.2.1")

Infinite Scroller

Travis CI build status InfiniteScroller Carthage Twitter

Microlibrary which simplifies implementation of infinite scroll in UIScrollView.

Motivation

Well in my apps I always deal with the same things again. Every scrolling screen which displays paged data needs to load next page some time. To save some time I created this microlibrary which should deal with everything that is necessary. Every time when user reaches a treshold, the caller is notified and can perform e.g. a network request which fetches new page of data.

Usage

Usage is very simple. Just create an instance of InfiniteScroller with the scrollView you want paged.

let infiniteScroller = InfiniteScroll(scrollView: scrollView)

Add the next page callback.

infiniteScroller.nextPageAction = { [weak self] completion in
    loadNextPage { completion() }
}

If you've done all of that then just start the scroller.

infiniteScroller.start()

Then later if your reach last items of your stream, you can stop the scroller by calling stop() method.

Remember to call the completion callback when loading next page finishes

And that's all. Remember that if you loose any reference to the InfiniteScroller instance, it will get deallocated and you will not receive any callbacks so you have to keep strong reference somewhere (e.g. in the view controller).

For more details you can check included example. ๐Ÿ™‚

Installation

InfiniteScroller is available through Carthage. Just add it to your Cartfile:

github "olejnjak/InfiniteScroller"

Or add it to your Podfile if you're using Cocoapods ๐Ÿ˜Ž

pod "InfiniteScroller"

If you're familiar with integrating manually it's your turn ๐Ÿ™‚. Or if you'd love to use a different way of integration, PRs are welcome ๐Ÿ™‚

GitHub

link
Stars: 5
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jackโ€™d and SCRUFF. We are two of the worldโ€™s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

SPM support
2 weeks ago

Add support for SPM

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API