Swiftpack.co - olejnjak/InfiniteScroller as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by olejnjak.
olejnjak/InfiniteScroller 0.3.2
Microlibrary which simplifies implementation of infinite scroll in UIScrollView
⭐️ 9
🕓 46 weeks ago
iOS
.package(url: "https://github.com/olejnjak/InfiniteScroller.git", from: "0.3.2")

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 = Scroller(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: 9
Last commit: 46 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

0.3.2
46 weeks ago

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