#ListView ListView extends famo.us ScrollContainer with insert/remove animations, selection (single/multiple) and support for a placeholder.
- class: ListView ⏏
- new ListView(options)
- enum: ListView.Selection
- enum: ListView.ItemState
- ListView.setSurfaceClass
- listView.setOptions(options)
- listView.insert(index, renderable, [transitions], [callback])
- listView.remove(index, [count], [transitions], [callback])
- listView.getCount()
- listView.get(index)
- listView.setSelection(index, [count], [selected])
- listView.getSelection([indexes])
###new ListView(options) Params
- options
Object
- Options.- [selection]
Selection
- Selection-mode (e.g. Selection.NONE, Selection.SINGLE, Selection.MULTIPLE) - [setItemState]
function
- Function that is called whenever an item-state changes (default: ListView.setSurfaceClass) - [scrollContainer]
Object
- Options that are passed on to the internal scrollContainer - [insertSize]
Array.Number
- Start-size that is used to animate item insertion (default: [undefined, 0]) - [removeSize]
Array.Number
- End-size that is used to animate item removal (default: [undefined, 0]) - [insertOpacity]
Number
- Start opacity that is used to animate an item insertion (default: 0) - [removeOpacity]
Number
- End opacity that is used to animate an item removal (default: 0) - [showOpacity]
Number
- Opacity that is used to show an item (default: 1) - [insertTransform]
Transform
- Transform that is used when inserting an item - [removeTransform]
Transform
- Transform that is used when removing an item - [insertTransition]
Transition
- Transition that is used when inserting an item (default: {duration: 1000, curve: Easing.outExpo}) - [removeTransition]
Transition
- Transition that is used when removing an item (default: {duration: 200, curve: Easing.outExpo}) - [showPlaceholderTransition]
Transition
- Transition for showing the placeholder (default: {duration: 500}) - [hidePlaceholderTransition]
Transition
- Transition for hiding the placeholder (default: {duration: 500})
- [selection]
###enum: ListView.Selection
Properties: NONE
, SINGLE
, MULTIPLE
###enum: ListView.ItemState
Properties: SELECTED
, FIRST
, LAST
###ListView.setSurfaceClass
Default implementation for options.setItemState
which adds/removes a class
from a surface based on the state. This function effectively sets the
'first', 'last' and 'selected' classes for the renderable.
Params
- index
Number
- Index of the item - renderable
Renderable
- Renderable that was added to the list-view - state
ItemState
|String
- State to set or clear on the renderable - set
Boolean
- Set or clear the state
###listView.setOptions(options) Set internal options.
Params
- options
Object
###listView.insert(index, renderable, [transitions], [callback]) Inserts one ore more items using an animation
Params
- index
Number
- Index of the item to insert the item before (when -1 is specified, inserts at the tail) - renderable
Renderable
|Array
- One or more renderables to insert - [transitions]
Object
- Transitions to use for the animation - [callback]
function
- Function that is called upon completion (e.g. after animation)
###listView.remove(index, [count], [transitions], [callback]) Removes one or more items using an animation
Params
- index
Number
- Index of the item to remove (when -1 is specified, removes the last-items) - [count]
Number
- Number of items to process, starting from index - [transitions]
Object
- Transition to use for the animation - [callback]
function
- Function that is called upon completion (e.g. after animation)
###listView.getCount() Get the number of items
Returns: Number
- number of items
###listView.get(index)
Get item at specified index
Params
- index
Number
- index of item
Returns: Renderable
- item
###listView.setSelection(index, [count], [selected])
Set the selection status of one or more items
Params
- index
Number
- Index of the item to select/de-select - [count]
Number
- Number of items to process, starting from index - [selected]
Boolean
- select or de-select (when omitted, true is assumed)
###listView.getSelection([indexes]) Get all selected items
Params
- [indexes]
Number
- When set to true, returns the index rather than the renderable
Returns: Array
- array of renderables (or indexes)