Skip to main content

Scroll Container

ScrollView

Usage Instructions

Scroll Containers enable scrolling effects for pages or functional modules. When the total width/height of the component content within a scroll container exceeds the container's own width/height, scroll bars will appear. Users can view all content within the container by scrolling through these bars, as shown in the following example:

  1. Drag a Scroll Container component, and set the height to 300
Image 15e8ca4864efeda01609b062fc867675
  1. Add three image components to the scroll container, setting the height of each image component to 200. This causes the total height of components inside the container to exceed the container's own height, making scroll bars appear.
Image aca40c58815769adad57f551b994a8fe

Property Introduction

External properties received by the component

Property Name
Property Identifier
Type
Description
Rolled element ID(Web)scrollIntoViewstring

This feature is not supported in mini programs currently.

Scroll the current element into the viewable area of the browser window

horizontal scroll bar positionscrollLeftnumber

Input default value, the horizontal scroll bar will move to the position by default

vertical scroll positionscrollTopnumber

Input default value, the vertical scroll bar will move to the location by default

Trigger scrolltolower event when distance from bottom/right is reachedlowerThresholdnumber

Example: 50

How far from the top/left to trigger the scrolltoupper eventupperThresholdnumber

Example: 50

Control scrollbar visibility(Mini Program)showScrollbarboolean

Hide scrollbar requires scroll-view enablement to take effect after enhanced feature

Control whether to show/hide the scrollbar

Example: true

EnableEnable scroll-view enhanced feature(Mini Program)enhancedboolean

Enable scroll-view enhanced feature

Example: false

Elastic control of scroll-view boundary on iOS(Mini Program)bouncesboolean

Example: true

Paginate slide effect(Mini Program)pagingEnabledboolean

Example: false

Sliding deceleration rate control(Mini Program)fastDecelerationboolean

Example: false

enable pull-down refresh(Mini Program)refresherEnabledboolean

Enabled, you can customize pull-down refresh settings

Example: false

Set custom pull-down refresh threshold(Mini Program)refresherThresholdnumber

Example: 50

Set custom pull-down refresh default style(Mini Program)refresherDefaultStylestring

Example: "block"

Set custom pull-down refresh area background color(Mini Program)refresherBackgroundstring

Example: "#fff"

Set current dropdown refresh status(Mini Program)refresherTriggeredboolean

Example: false

Enable scroll anchoring feature(Mini Program)scrollAnchoringboolean

Enable scroll-anchoring feature

Example: false

Enable flexbox layout(Mini Program)enableFlexboolean

Enable flexbox layout

Example: false

On iOS, click the top status bar. On Android, double tap the title bar to return to top. Supports only vertical scrollbar.(Mini Program)enableBackToTopboolean

When enabled, the scrollbar will automatically return to top after performing corresponding operations.

Example: false

Use animation transition when setting the scrollbar position(Mini Program)scrollWithAnimationboolean

Enable scrollbar animation

Example: false

Enable horizontal scrollscrollXboolean

When enabled, the horizontal scroll bar will be activated, and the component supports scrolling left and right.

Example: false

Vertically scrollablescrollYboolean

When enabled, the vertical scroll bar will be activated, and the component supports scrolling up and down.

Example: true

Event Introduction

Events exposed by the component. You can listen to component events to trigger external actions

Event Name
Event Code
Event Output Parameters event.detail
Applicable Scenarios
Description
Trigger on scrollscrollCompatible with all platforms

-

Trigger on scroll to bottom/rightscrolltolowerCompatible with all platforms

-

Trigger on scroll to top/leftscrolltoupperCompatible with all platforms

-

Slide start event (Enable enhanced property simultaneously to take effect)dragstartMini Program

-

sliding event (enable simultaneously with enhanced property to take effect)draggingMini Program

-

Sliding end event (Enable enhanced property simultaneously to take effect)dragendMini Program

-

Custom pull-down refresh control was scrolled downrefresherpullingMini Program

-

Custom pull-down refresh triggeredrefresherrefreshMini Program

-

Custom pull-down refresh was resetrefresherrestoreMini Program

-

Custom pull-down refresh terminatedrefresherabortMini Program

-

Frequently Asked Questions

What is the difference between Generic Container / Grid Layout / Scroll Container?

Generic Container/Grid Layout/Scroll Container are three commonly used container types in WeDa. Their differences are as follows:

  • Generic Container: The Generic Container is the most basic container type, used to carry text, images, and other content on the page. It can nest other components and achieve different layout effects by setting styles. By default, it does not have a scrolling feature. If the content does not have a height set, it will automatically expand. Similar to View in mini-programs and div on the Web.
  • Grid Layout: Grid Layout is a container used for layout, expanding flexible layout functions based on ordinary containers. It divides the page into grids, allowing arbitrary combination of different grids to create various layouts, such as left-right layouts and multi-column rows. It also supports displaying different layouts on multiple devices.
  • Scroll Container: A container with scroll bars. After setting width and height, if the content exceeds the container's boundaries, users can scroll through the content within it. Similar to ScrollView in mini-programs.

In actual development, it is recommended to use Grid Layout for detailed arrangements of entire pages and internal modules. For multi-device requirements, you can configure display effects across different platforms. When content exceeds the visible area, implement scrolling functionality using Scroll Container.

How to Implement Partial Scrolling?

Scroll Container can be used to display content that requires scrolling when it exceeds boundaries.

When the total width/height of the component content within a scroll container exceeds the Scroll Container's own width/height, scroll bars will appear, allowing users to view all content within the container by scrolling through these bars.

Note that you must set the width and height for the Scroll Container to ensure that the dimensions of the internal content exceed those of the container, enabling the scrolling effect.

To achieve horizontal scrolling only, ensure that the width of the Scroll Container is less than the width of the content within it.

To achieve vertical scrolling only, ensure that the height of the Scroll Container is less than the height of the content within it.