Scrollview
The scrollview component is a UI tool that helps you easily implement common scrollview patterns.
Basic usage
<mobiscroll.ScrollView>
<div>
Sample content inside a custom horizontall scrollview component
</div>
<div>
Sample content inside a custom horizontall scrollview component
</div>
<div>
Sample content inside a custom horizontall scrollview component
</div>
</mobiscroll.ScrollView>
<mobiscroll.ScrollView itemWidth="150" theme="ios">
<div>
Sample content inside a custom horizontall scrollview component
</div>
<div>
Sample content inside a custom horizontall scrollview component
</div>
<div>
Sample content inside a custom horizontall scrollview component
</div>
</mobiscroll.ScrollView>
<mobiscroll.ScrollView itemWidth="100">
{this.state.items.map(function(item, index) {
return <div key={item.id}>Some text {index}</div>;
})}
</mobiscroll.ScrollView>
For many more examples - simple and complex use-cases - check out the scrollview demos for react.
Options
Name | Type | Default value | Description |
---|---|---|---|
context | String, HTMLElement | 'body' |
The DOM element in which the component is appended and positioned (if not inline). Can be a selector string or a DOM element. |
display | String | 'inline' |
Controls the position of the scrollview. Possible values:
|
itemWidth | Number | undefined |
If layout is 'fixed' , it represents the exact witdh of the items in pixels,
otherwise the minimum width of the items, and the items will be stretched to fill the container width.
|
layout |
String Number |
'liquid' |
Possible values:
|
mousewheel | Boolean | false |
Enables mousewheel / touchpad scroll. |
paging | Boolean | false |
Scroll one page at a time. The page size will be the width of the container. |
snap | Boolean | false |
When the scrollview is scrolled it snaps to the edge of the last visible item which is at the opposite direction of the scroll. |
theme | String | undefined |
Sets the visual appearance of the component.
If it is If the theme for the specific platform is not present, it will default to the Mobiscroll theme. Supplied themes:
Starting from v4.9.0 setting directly the dark version of the theme is deprecated.
Use the themeVariant option instead to control the light / dark appearance of the theme.
Make sure that the theme you set is included in the downloaded package.
|
themeVariant | String | undefined |
Controls which variant of the theme will be used (light or dark). Possible values:
If not set, only the theme setting will determine which theme to use.
To use the option with custom themes, make sure to create two custom themes,
where the dark version has the same name as the light one, suffixed with
The option will not have any effect if the theme option explicitly
sets the dark version of a theme, e.g.
theme: 'ios-dark' .
|
threshold | Number | 10 |
Minimum horizontal movement in pixels before the scrolling starts. |
Events
Name | Description | |
---|---|---|
onAnimationEnd(event, inst) | Gets fired when an autonomous scrolling/sliding ends.
Parameters
Example
|
|
onAnimationStart(event, inst) | Gets fired when an autonomous scrolling/sliding is starts.
Parameters
Example
|
|
onGestureEnd(event, inst) | Gets fired when the user ends the scrolling gesture.
Parameters
Example
|
|
onGestureStart(event, inst) | Gets fired when the user ends the scrolling(swiping) gesture.
Parameters
Example
|
|
onInit(event, inst) |
Triggered when the component is initialized.
Parameters
Example
|
|
onItemTap(event, inst) |
Triggered when an item is tapped.
Parameters
Example
|
|
onMarkupReady(event, inst) |
Triggered when the html markup of the component is generated, but it is not yet shown.
It is useful, if you want to make modifications to the markup (e.g. add custom elements), before the positioning runs.
Parameters
Example
|
|
onMove(event, inst) | Gets fired when an autonomous scrolling/sliding ends.
Parameters
Example
|
Methods
Name | Description | |
---|---|---|
navigate(item [, toggle ] [, animTime]) |
Scrolls the scrollview to the specified item.
Parameters
ExampleMethods can be called on an instance. For more details see calling methods
|
|
next([toggle]) | Scrolls the scrollview to the next item.
Parameters
ExampleMethods can be called on an instance. For more details see calling methods
|
|
option(options) |
Sets one or more options for the component.
Parameters
ExampleMethods can be called on an instance. For more details see calling methods
|
|
prev([toggle]) | Scrolls the scrollview to the previous item.
Parameters
ExampleMethods can be called on an instance. For more details see calling methods
|
|
refresh() |
Recalculate dimensions needed for scrolling.
ExampleMethods can be called on an instance. For more details see calling methods
|
|
tap(el, handler) |
Attaches the handler function to the tap event of element el .
Parameters
ExampleMethods can be called on an instance. For more details see calling methods
|
Localization
Name | Type | Default value | Description |
---|---|---|---|
lang | String | 'en-US' |
Language of the component. Based on the language string the component loads the language based default settings from the
language modules.
Supported languages:
|
rtl | Boolean | false |
Right to left display. |