Skip to main content
Version: v3

swipeToIndex

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Scrolls the page to the Swiper's target item, only if the current page scroll mode is SCROLL_MODE_SWIPER.

Type

function swipeToIndex(option: Option): void

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
indexnumberY-Index of the target project, starting from 02.0
animationstringNSCROLL_ANIMATION_SMOOTHScrolling animation, value reference page scrolling animation constants2.0

Constants

Page scroll mode constants

ConstantDescriptionAPI_LEVEL
SCROLL_ANIMATION_SMOOTHScroll smoothly to the corresponding position2.0
SCROLL_ANIMATION_NONENo animation, scroll directly to the corresponding position2.0

Example

import { setScrollMode, swipeToIndex, SCROLL_MODE_SWIPER } from '@zos/page'

setScrollMode({
mode: SCROLL_MODE_SWIPER,
options: {
height: 480,
count: 10,
},
})

swipeToIndex({
index: 5,
})