Skip to main content
Version: v3

PAGE_INDICATOR

Start from API_LEVEL 2.1 . Please refer to API_LEVEL.

When a page is set to Swiper scroll mode using the @zos/page setScrollMode method, an indicator control is created on the page to indicate the total number of pages and to indicate which page is currently stopped.

Create UI widget

import { createWidget, widget } from '@zos/ui'

const pageIndicator = createWidget(widget.PAGE_INDICATOR, Param)

Type

Param: object

PropertiesDescriptionRequiredTypeAPI_LEVEL
xThe x-axis coordinate of the widget.YESnumber2.1
yThe y-axis coordinate of the widget.YESnumber2.1
wThe width of the widget.YESnumber2.1
hThe height of the widget.YESnumber2.1
align_hThe alignment of the horizontal axis (see ALIGN for values).NOALIGN2.1
h_spaceHorizontal spacingNOnumber2.1
v_spaceVertical spacingNOnumber3.0
select_srcIndicator current page highlight image path, resource storage path reference Folder StructureYESstring2.1
unselect_srcIndicator non-current page highlight image path, resource storage path reference Folder StructureYESstring2.1
horizontalHorizontal or not, default is true, set false for vertical layoutNOboolean3.0

ALIGN alignment

ValueDescription
align.LEFTHorizontal axis-left aligned.
align.RIGHTHorizontal axis-align right.
align.CENTER_HHorizontal axis-centered.

Code Example

import { createWidget, widget, align } from '@zos/ui'
import { setScrollMode, SCROLL_MODE_SWIPER_HORIZONTAL } from '@zos/page'
import { px } from '@zos/utils'

Page({
build() {
const itemCount = 10
const pageSize = px(480)

setScrollMode({
mode: SCROLL_MODE_SWIPER_HORIZONTAL,
options: {
height: pageSize,
count: itemCount
}
})

const pageIndicator = createWidget(widget.PAGE_INDICATOR, {
x: 0,
y: px(470),
w: px(480),
h: px(10),
align_h: align.CENTER_H,
h_space: 8,
select_src: 'images/test/select/select.png',
unselect_src: 'images/test/select/unselect.png'
})

for (let i = 0; i < itemCount; i++) {
let xPos = 0
let yPos = px(400) + pageSize * i
createWidget(widget.TEXT, {
x: xPos,
y: yPos,
w: px(480),
h: px(120),
text_size: 35,
color: 0xffffff,
align_h: align.CENTER_H,
text: `PAGE ${i}`
})
}
}
})