Native rail elements properties
This element goals is to draw and use native rail component
Properties
direction
Type | Default value | Supported value |
---|---|---|
string | $RailDirection.HORIZONTAL | $RailDirection.HORIZONTAL $RailDirection.VERTICAL |
Define how to align item (horizontally or vertically).
itemChooser
Type | Default value | Supported value |
---|---|---|
object | null | Not applicable |
itemChooser will allow to define which item will be used to draw a tile in you rail. You must respect following structure
Name | Type | Supported value | Explanation |
---|---|---|---|
key | string | Not applicable | Define the key that will be used in you data object to switch on |
values | Array<{keyValue, item}β₯ | Not applicable |
|
defaultItem | string | item to be used
|
As an example we would be able to have the following object :
const itemChooser = {
key: "ratio",
items : [
{
keyValue: "16:9",
item: "LandscapeItem"
},
{
keyValue: "4:3",
item: "PortraitItem"
}
],
defaultItem: "DefaultItem"
}
Getter / Setter
getIndex() β {Promise< Number >}
Get the index of the current focused item.
Returns
A Promise that returns the index of the current focused item
getItem(index) β {Promise< Object >}
Get the item data at the given index.
Parameters
Name | Mandatory | Type | Description |
---|---|---|---|
index | yes | number | The index of the item you want |
Returns
A Promise that returns an object that matches the item data of the asked index
setData(datas, index, chooser) β {Promise}
Send data to be used by the rail to create items.
You could use empty array to empty the rail.
If no index sent, 0 value will be used.
You can modify the chooser only when setting data.
Parameters
Name | Mandatory | Type | Description |
---|---|---|---|
datas | yes | Array | The data that are going to be used to fill the rail |
index | no | number | The index you want to scroll to |
chooser | no | Object | See itemChooser property description |
Returns
Promise that resolve is set has been successful.
Public interface
scrollTo(index) β {Promise< Boolean >}
Scroll to the item at the requested index.
Parameters
Name | Mandatory | Type | Description |
---|---|---|---|
index | yes | number | The index of the item you want |
Returns
True if the item has been scrolledTo, false else (out of bound). If the item is already scrolled to, return false.
Protected methods that needs implementations
_setData
Called by setData
_scrollTo
Called by scrollTo
_onScroll(index)
Function that needs to be connected to scroll native event
_onItemClicked(index)
Function that needs to be connected to clicked native event
Events
onScroll(index, Object)
Triggers each time an item has been scrolled to.
Send current item data.
onItemClicked(index, Object)
Triggers each time an item has been clicked on (remote OK or touch).
Send clicked item data.