Pull to refresh
Last updated
Last updated
The pull-to-refresh pattern lets a user pull down on a list of data using touch in order to retrieve more data. This is usually implemented in apps where even few seconds of idle time can allow more data to pile up in a feed list, like in Instagram or Facebook.
This functionality is similar to hitting a refresh button, while still able to see already fetched data.
While Infinite scroll allows you to fetch more "older" data in your feed, pull-to-refresh allows you to fetch "newer" data in the feed, and add it to the visible feed.
The infinite scroll is located in src/app/pages/addons/refresh
To use this functionality, you put the ion-refresher
at the top of ion-content
in your page
ion-refresher-content
contains the elements which will show when the page is loading new content. You can put text, images or GIFs here as per your app design.
(ionRefresh)="doRefresh($event)"
is basically an ionRefresh
listener implemented, which fires on a pull-down and release event of the page. It then calls a function doRefresh
(or any function you want), and you can implement the proper logic to fetch more data.
In Full App, we fetch more data from an API, with 5000ms delay
event.target.complete();
tells the app that loading new data is completed, and the loader can be hidden. This will require a custom logic on your end. For demo purpose, we stop fetching new data when the list item count exceeds 10.
Name
Description
ionPull
Emitted while the user is pulling down the content and exposing the refresher.
ionRefresh
Emitted when the user lets go of the content and has pulled down further than the `pullMin` or pulls the content down and exceeds the pullMax. Updates the refresher state to `refreshing`. The `complete()` method should be called when the async operation has completed.
ionStart
Emitted when the user begins to start pulling down.