tencent cloud

Last updated: 2025-04-28 18:13:10
Scroll
Last updated: 2025-04-28 18:13:10

pageScrollTo

This API is used via wx.pageScrollTo(Object object).
Feature Description: Scrolls the page to the desired location.
Parameter and Description: Object.
Attribute
Type
Default value
Required
Description
scrollTop
number
-
Yes
Scroll to the target position on the page, measured in pixels.
duration
number
300
No
Duration of the scrolling animation, measured in milliseconds.
success
function
-
No
Callback Function of Successful Interface Call
fail
function
-
No
Callback Function of Failing Interface Call
complete
function
-
No
Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
Sample Code
wx.pageScrollTo({
scrollTop: 0,
duration: 300
})

ScrollViewContext

Feature Description: Enhances ScrollView instance, which can be obtained through the wx.createSelectorQuery's NodesRef.node method. Effective only when the scroll-view component's enhanced attribute is enabled.
Attribute and Descriptions
Attribute
Type
Description
scrollEnabled
boolean
Scrolling Switch
bounces
boolean
Set the scroll boundary elasticity (currently unsupported)
showScrollbar
boolean
Set the visibility of the scrollbar
pagingEnabled
boolean
Pagination Slide Switch
fastDeceleration
boolean
Set scroll deceleration rate (iOS only)
decelerationDisabled
boolean
Cancel the scroll inertia (Effective only on iOS)
Sample Code
wx.createSelectorQuery()
.select('#scrollview')
.node()
.exec((res) => {
const scrollView = res[0].node;
scrollView.scrollEnabled = false;
})

.scrollIntoView

The method is used via: ScrollViewContext.scrollIntoView(string selector, object ScrollIntoViewOptions)
Feature Description: Scrolls the element to the top or bottom of the viewport.
Parameters and Description: string selector, element selector.

.scrollTo

The method is used via ScrollViewContext.scrollTo(Object object)
Feature Description: Scroll the element to the specified position, accurate to pixels.
Parameter and Description: Object.
Attribute
Type
Default value
Required
Description
top
number
-
No
Top distance
left
number
-
No
Left Boundary Distance
velocity
number
-
No
Initial Speed (iOS only)
duration
number
-
No
Scroll animation length (iOS only)
animated
boolean
-
No
Enable scroll animation or not

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback