Scroll
pageScrollTo
TIP
The API usage is as follows: wx.pageScrollTo(Object object)
- Functional description: Scroll the page to the target position.
- Parameters and descriptions: Object object
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| scrollTop | number | - | Yes | Scroll to the target position of the page, unit px |
| duration | number | 300 | No | Duration of the scrolling animation, unit ms |
| success | Function | - | No | Callback function for successful interface call |
| fail | Function | - | No | Callback function for failed interface call |
| complete | Function | - | No | Callback function for interface call completion (executed regardless of success or failure) |
- Sample code:
js
wx.pageScrollTo({
scrollTop: 0,
duration: 300
})ScrollViewContext
- Functional description: Enhance the ScrollView instance, which can be obtained through the wx.createSelectorQuery method of NodesRef.node . It only takes effect after the scroll-view component turns on the enhanced attribute.
- Attributes and descriptions
| Properties | Type | Description |
|---|---|---|
| scrollEnabled | boolean | Scroll switch |
| bounces | boolean | Set the scroll boundary elasticity (only effective on iOS) |
| showScrollbar | boolean | Set whether to display the scroll bar |
| pagingEnabled | boolean | Paging slide switch |
| fastDeceleration | boolean | Set the scroll deceleration rate (only valid on iOS) |
| decelerationDisabled | boolean | Cancel scroll inertia (only valid on iOS) |
- Sample code:
js
wx.createSelectorQuery()
.select('#scrollview')
.node()
.exec((res) => {
const scrollView = res[0].node;
scrollView.scrollEnabled = false;
}).scrollIntoView
TIP
The API usage is as follows: ScrollViewContext.scrollIntoView(string selector, object ScrollIntoViewOptions)
- Functional description: Scroll to the specified position.
- Parameters and descriptions: string selector, element selector
.scrollTo
TIP
The API usage is as follows: ScrollViewContext.scrollTo(Object object)
- Functional description: Scroll to the specified position.
- Parameters and descriptions: Object object。
| Properties | Type | Default value | Required | Description |
|---|---|---|---|---|
| top | number | - | No | Top distance |
| left | number | - | No | Left border distance |
| velocity | number | - | No | Initial speed (only valid on iOS) |
| duration | number | - | No | Scroll animation duration (only valid on iOS) |
| animated | number | - | No | Whether to enable scroll animation |