ScrollView
Requires:
@ray-js/ray≥0.5.10
Description
Scrollable view container that supports horizontal or vertical scrolling, with configurable pull-to-refresh, scroll event listeners, and other features.
Props
| Property | Type | Required | Default | Description | Since |
|---|---|---|---|---|---|
scrollX | boolean | No | false | Enable horizontal scrolling | - |
scrollY | boolean | No | false | Enable vertical scrolling | - |
upperThreshold | number | string | No | 50 | Distance from the top/left at which the scrolltoupper event fires | - |
lowerThreshold | number | string | No | 50 | Distance from the bottom/right at which the scrolltolower event fires | - |
scrollTop | number | string | No | 0 | Set vertical scroll position | - |
scrollLeft | number | string | No | 0 | Set horizontal scroll position | - |
scrollIntoView | string | No | - | The value should be the id of a child element (id must not start with a digit). The element will be scrolled into view along the enabled scrolling direction | - |
scrollIntoViewOffset | number | No | 0 | Additional offset, in px, when scrolling to the scrollIntoView target node | v1.7.58 |
scrollWithAnimation | boolean | No | false | Use animated transition when setting the scroll position | - |
| No | - | Fires on scroll | - | ||
| No | - | Fires when scrolled to the top/left | - | ||
| No | - | Fires when scrolled to the bottom/right | - | ||
refresherEnabled | boolean | No | false | Enable custom pull-to-refresh | v0.9.3 |
refresherThreshold | number | No | 45 | Set the custom pull-to-refresh threshold | v0.9.3 |
refresherDefaultStyle | "black" | "white" | "none" | "auto" | No | black | Set the default style for custom pull-to-refresh | v0.9.3 |
refresherBackground | string | No | #FFF | Set the background color of the custom pull-to-refresh area | v0.9.3 |
refresherTriggered | boolean | No | false | Set the current pull-to-refresh state: true means pull-to-refresh has been triggered; false means it has not | v0.9.3 |
hideScrollbar | boolean | No | true | Hide the scrollbar | - |
bounces | boolean | No | true | Whether to enable the iOS scroll bounce effect (fully supported on iOS 16.0+) | v1.7.58 |
| No | - | Fires when the custom pull-to-refresh control is pulled | v0.9.3 | ||
| No | - | Fires when custom pull-to-refresh is triggered | v0.9.3 | ||
| No | - | Fires when custom pull-to-refresh is reset | v0.9.3 | ||
| No | - | Triggered when custom pull-to-refresh is aborted | v0.9.3 |
Referenced Types
interface
RefresherPullingEventinterface
RefresherRefreshEventinterface
RefresherRestoreEventinterface
RefresherAbortEventinterface
BaseEvent| Property | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Event type |
timeStamp | number | Yes | Time in milliseconds since the page opened |
| Yes | Source component of the event | ||
| Yes | Collection of property values for the current component | ||
mark | any | No | Event mark data |
interface
Target| Property | Type | Required | Description |
|---|---|---|---|
id | string | Yes | id of the event source component |
| Yes | Collection of custom attributes from the `dataset` on the event source component |
Valid Values
ScrollDirectionDetail.direction
| Value | Description | Since |
|---|---|---|
top | Scroll to the top | - |
left | Scroll to the left | - |
bottom | Scroll to the bottom | - |
right | Scroll to the right | - |
refresherDefaultStyle
| Value | Description | Since |
|---|---|---|
black | Black refresh indicator | - |
white | White refresh indicator | - |
none | Disable the default refresh indicator and implement a custom refresh style | - |
auto | Match the refresh indicator color to the app theme | - |
Examples
Basic usage
Pull to refresh
Horizontal scrolling
Scroll to a specific position
FAQ
Why can't scroll-view scroll inside a popup extension component?
Add the disableScroll attribute to the popup component and set it to false to enable scrolling.
How do I listen for scroll-view scrolling to the bottom?
You can handle this directly in the onScroll method, or use onScrollToLower to listen for the scroll height of scrollView to determine whether it has scrolled to the bottom.
scrollHeight is the total height of all View elements inside scrollView, and scrollTop is the scroll offset value.