Home

Awesome

Alloy Infinite Scroll widget

gitTio René Pot

I've taken this widget into my management. Many thanks to Fokke Zandbergen for creating and maintaining it for all this time.

The Infinite Scroll widget implements the design pattern also known as Dynamic Scroll or Endless Scroll for TableViews and ListViews in the Alloy MVC framework for Titanium by Appcelerator. A Titanium Classic implementation can be found in the KitchenSink.

Also take a look at my Pull to Refresh widget.

Overview

The widget automatically shows an ActivityIndicator in a TableView or ListView's FooterView when the user reached the end of the table. An event is triggered so that the implementing controller can load more rows.

screenshot

Features

Quick Start

Get it gitTio

Download this repository and consult the Alloy Documentation on how to install it, or simply use the gitTio CLI:

$ gittio install nl.fokkezb.infiniteScroll

Use it

Styling

The widget can be fully styled without touching the widget source. For Alloy 1.4 and later use the classnames below in your theme's app/themes/your-theme/widgets/nl.fokkezb.infiniteScroll/styles/widget.tss. For Alloy 1.3 and earlier use the ID's in your app's app.tss to override the default style, which is set on the classes.

class/IDDescription
isThe view to be added as FooterView
isCenterCan be used to align the content, but mainly to support iOS7's Ti.UI.Window.extendEdges by setting bottom to the height of the TabGroup (49).
isIndicatorThe ActivityIndicator showing during load
isTextThe message shown when not loading. Set visible to false if you want to hide the text until the first load has happened.

Options

There are no required options to pass via TSS properties or XML attributes, apart from the onEnd attribute to bind your callback to the end-event. You can change the displayed messages by using the following options:

ParameterTypeDefault
msgTapstringTap to load more...
msgDonestringNo more to load...
msgErrorstringTap to try again...

Methods

You can also manually trigger the loading state of the widget. You could use this for the first load when your window opens.

FunctionParametersUsage
setOptionsobjectSet any of the options
loadManually trigger the end event and loading state
statestate, stringManually set the state. The first argument should be one of the exported SUCCESS, DONE and ERROR constants. The second optional argument is a custom message to display instead of the message belonging to the state.
detachManually set the DONE state and remove the scroll listener
cleanupDetach and then unset the footerView
initTi.UI.TableView, Ti.UI.ListViewManually init the widget if it's the child element of the TableView or ListView, or to work around TC-3417 in Alloy 1.3.0 and later.
markIf add/remove items from the ListView via other ways then the widget call mark() so the widget is triggered on the last item.

Testing

There is a test app and instructions in the test branch.

Changelog

License

<pre> Copyright 2013 Fokke Zandbergen Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. </pre>