setScrollMode
Start from API_LEVEL
2.0. Please refer to API_LEVEL.
Set the scroll mode of the page.
Type
function setScrollMode(option: Option): Result
Parameters
Option
| Property | Type | Required | DefaultValue | Description | API_LEVEL |
|---|---|---|---|---|---|
| mode | string | Y | - | Page scroll mode, value reference page scroll mode constants | 2.0 |
| options | Options | N | - | Other Options | 2.0 |
Options
| Property | Type | Required | DefaultValue | Description | API_LEVEL |
|---|---|---|---|---|---|
| height | number | N | - | Specify the height of a single item in Swiper, effective only if the scroll mode is SCROLL_MODE_SWIPER | 2.0 |
| count | number | N | - | Specify the number of items in the Swiper, effective only if the scroll mode is SCROLL_MODE_SWIPER or SCROLL_MODE_SWIPER_HORIZONTAL | 2.0 |
| width | number | N | - | Specify the width of a single item in Swiper, effective only if the scroll mode is SCROLL_MODE_SWIPER_HORIZONTAL | 2.1 |
| modeParams | FreeModeParams|SwipeModeParams | N | - | Parameters for the scroll mode | 3.0 |
FreeModeParams
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| scroll_frame_func | (params: ScrollObj) => void | The callback function for each frame during scrolling | 3.0 |
| scroll_complete_func | (params: ScrollObj) => void | The end of the scroll callback function | 3.0 |
ScrollObj
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| type | number | Todo | 3.0 |
| yoffset | number | Pixel offset on the y axis | 3.0 |
SwipeModeParams
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| on_page | (pageIndex: number) => void | Callback function after page flipping, pageIndex is the page index after page flipping, and the index starts from 0 | 3.0 |
| crown_enable | boolean | Whether to respond to crown events, the default response, you can use the crown to control page turning | 3.0 |
Result
| Type | Description |
|---|---|
number | If true is returned, success is indicated |
Constants
Page scroll mode constants
| Constant | Description | API_LEVEL |
|---|---|---|
SCROLL_MODE_FREE | Free scrolling mode, system default scrolling mode | 2.0 |
SCROLL_MODE_SWIPER | Swiper mode, vertical rotating map, walking lights, by configuring the height and number of individual pages can achieve the whole screen scrolling effect | 2.0 |
SCROLL_MODE_SWIPER_HORIZONTAL | Swiper mode, horizontal rotating map, walking lights, by configuring the width and number of individual pages can achieve the whole screen scrolling effect | 2.1 |
Example
import { setScrollMode, SCROLL_MODE_SWIPER } from '@zos/page'
setScrollMode({
mode: SCROLL_MODE_SWIPER,
options: {
height: 480,
count: 10,
},
})