@lynx-js/lynx-ui-scroll-view 3.142.0 → 3.143.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/SKILL.md +168 -0
- package/package.json +7 -6
- package/tsconfig.docs.json +0 -7
- package/tsconfig.json +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-scroll-view
|
|
2
2
|
|
|
3
|
+
## 3.143.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Include missing README/CHANGELOG/SKILL/LICENSE files in published tarballs and exclude test and workspace-only config files. ([#404](https://github.com/lynx-family/lynx-ui/pull/404))
|
|
8
|
+
- Updated dependencies [[`29beec7`](https://github.com/lynx-family/lynx-ui/commit/29beec7b241026010b83c417f7e1d1c961cd4f09)]:
|
|
9
|
+
- @lynx-js/lynx-ui-common@3.143.0
|
|
10
|
+
- @lynx-js/lynx-ui-lazy-component@3.143.0
|
|
11
|
+
|
|
3
12
|
## 3.142.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# lynx-ui-scroll-view SKILL
|
|
2
|
+
|
|
3
|
+
`ScrollView` is a general-purpose scroll container used to display content that exceeds the viewport in either vertical or horizontal direction. For massive datasets, prefer `List` or `FeedList` to ensure performance.
|
|
4
|
+
|
|
5
|
+
## 1. Core Capabilities
|
|
6
|
+
|
|
7
|
+
- **Vertical and Horizontal Scrolling**: Supports vertical (`scrollOrientation = 'vertical'`) and horizontal (`scrollOrientation = 'horizontal'`) scrolling.
|
|
8
|
+
- **Native Scroll Architecture**: `enableNewArch` defaults to `true` on Lynx SDK 4.3 and newer and to `false` on earlier versions. The new architecture uses native bounces across Android, iOS, and Harmony; set the prop explicitly to override the SDK-based default.
|
|
9
|
+
- **BounceableOptions**: Supports edge rubber-band and bounce effects, configurable via:
|
|
10
|
+
- `enableBounces`: enable/disable edge bounce
|
|
11
|
+
- `singleSidedBounce`: select bounce side (`'upper' | 'lower' | 'both'`)
|
|
12
|
+
- `alwaysBouncing`: allow bouncing even when content does not exceed the viewport
|
|
13
|
+
- `startBounceTriggerDistance` / `endBounceTriggerDistance`: threshold distance to trigger `onScrollToBounces`
|
|
14
|
+
- `onScrollToBounces(info)`: callback when reaching upper/lower edge (`info.direction` is `'upper' | 'lower'`)
|
|
15
|
+
- `enableBounceEventInFling`: trigger bounce events during inertial fling
|
|
16
|
+
- `validAnimationVersion`: compatibility switch to use `setTimeout` instead of `requestAnimationFrame` on lower Lynx versions
|
|
17
|
+
|
|
18
|
+
## 2. AI Coding Guide
|
|
19
|
+
|
|
20
|
+
### Minimal Usable Example
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { ScrollView } from '@lynx-js/lynx-ui'
|
|
24
|
+
|
|
25
|
+
function BasicScrollView() {
|
|
26
|
+
return (
|
|
27
|
+
<ScrollView
|
|
28
|
+
scrollOrientation='vertical'
|
|
29
|
+
style={{ height: '300px', width: '100%' }}
|
|
30
|
+
>
|
|
31
|
+
<view style={{ height: '800px', background: 'lightgray' }}>
|
|
32
|
+
<text>Very long content...</text>
|
|
33
|
+
</view>
|
|
34
|
+
</ScrollView>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Wrapper Usage (Flex Layout)
|
|
40
|
+
|
|
41
|
+
When you need `flex` layout, add a wrapper as the first child of `ScrollView`, and apply `flex` styles on that wrapper:
|
|
42
|
+
|
|
43
|
+
Also make sure the direct child of `ScrollView` is larger than the `ScrollView` viewport on the scrolling axis. Otherwise, the content does not overflow and the `ScrollView` will not scroll.
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { ScrollView } from '@lynx-js/lynx-ui'
|
|
47
|
+
|
|
48
|
+
function FlexWrapperExample() {
|
|
49
|
+
return (
|
|
50
|
+
<ScrollView scrollOrientation='vertical' style={{ height: '240px' }}>
|
|
51
|
+
{/* 第一层:wrapper view(设置 flex) */}
|
|
52
|
+
<view style={{ display: 'flex', flexDirection: 'row', gap: '8px' }}>
|
|
53
|
+
<view
|
|
54
|
+
className='card'
|
|
55
|
+
style={{ width: '100px', height: '100px', background: 'skyblue' }}
|
|
56
|
+
/>
|
|
57
|
+
<view
|
|
58
|
+
className='card'
|
|
59
|
+
style={{ width: '100px', height: '100px', background: 'salmon' }}
|
|
60
|
+
/>
|
|
61
|
+
<view
|
|
62
|
+
className='card'
|
|
63
|
+
style={{ width: '100px', height: '100px', background: 'khaki' }}
|
|
64
|
+
/>
|
|
65
|
+
</view>
|
|
66
|
+
</ScrollView>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Recommended Prompt Formula
|
|
72
|
+
|
|
73
|
+
> **Scenario Description** + **Scroll Configuration (direction, events)** + **Content and Style**
|
|
74
|
+
|
|
75
|
+
**Example Prompt:**
|
|
76
|
+
|
|
77
|
+
- "Create a vertically scrollable `ScrollView` with a height of 400px. The content within it has a total height of 1000px."
|
|
78
|
+
- "Implement a `ScrollView` that triggers a ‘load more’ function when scrolled to the bottom, using `onScrollToLower`."
|
|
79
|
+
- "Create a `ScrollView` and a ‘Back to Top’ button. When the button is clicked, smoothly scroll back to the top."
|
|
80
|
+
|
|
81
|
+
## 3. Use Cases & Best Practices
|
|
82
|
+
|
|
83
|
+
### Vertical Scrolling
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { ScrollView } from '@lynx-js/lynx-ui'
|
|
87
|
+
|
|
88
|
+
function VerticalScrollView() {
|
|
89
|
+
return (
|
|
90
|
+
<ScrollView scrollY={true} style={{ height: '200px' }}>
|
|
91
|
+
<view style={{ height: '500px' }}>
|
|
92
|
+
{/* ... Long content ... */}
|
|
93
|
+
</view>
|
|
94
|
+
</ScrollView>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Example Path**: `apps/examples/src/ScrollView/Basic/index.tsx`
|
|
100
|
+
|
|
101
|
+
### Horizontal Scrolling
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
import { ScrollView } from '@lynx-js/lynx-ui'
|
|
105
|
+
|
|
106
|
+
function HorizontalScrollView() {
|
|
107
|
+
return (
|
|
108
|
+
<ScrollView scrollOrientation='horizontal' style={{ width: '100%' }}>
|
|
109
|
+
<view style={{ flexDirection: 'row' }}>
|
|
110
|
+
{[...Array(10)].map((_, i) => <view key={i} className='card' />)}
|
|
111
|
+
</view>
|
|
112
|
+
</ScrollView>
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Example Path**: `apps/examples/src/ScrollView/Basic/index.tsx`
|
|
118
|
+
|
|
119
|
+
### Listening for Scroll to Bottom (Load More)
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import { ScrollView } from '@lynx-js/lynx-ui'
|
|
123
|
+
|
|
124
|
+
function LoadMoreScrollView() {
|
|
125
|
+
const loadMore = () => {
|
|
126
|
+
console.log('Reached the bottom, loading more data...')
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<ScrollView
|
|
131
|
+
scrollY={true}
|
|
132
|
+
style={{ height: '300px' }}
|
|
133
|
+
onScrollToLower={loadMore}
|
|
134
|
+
lower-threshold='50'
|
|
135
|
+
>
|
|
136
|
+
{/* ... list content ... */}
|
|
137
|
+
</ScrollView>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Example Path**: `apps/examples/src/ScrollView/Event/index.tsx`
|
|
143
|
+
|
|
144
|
+
### 4. FAQ
|
|
145
|
+
|
|
146
|
+
**Q: Why can't my `ScrollView` scroll?**
|
|
147
|
+
|
|
148
|
+
A: `ScrollView` needs a determined boundary. Set a fixed size (e.g., `height: '300px'`) or place it in a flex container and use `flex: 1`. Also ensure the direct child of `ScrollView` is larger than the viewport on the scrolling axis. For example, a vertical `ScrollView` with `height: '300px'` needs a direct child taller than `300px`; otherwise it will not scroll.
|
|
149
|
+
|
|
150
|
+
**Q: `ScrollView` inside `Popup` causes drag conflicts?**
|
|
151
|
+
|
|
152
|
+
A: Pass the `main-thread:gesture` object provided by `Popup` to `ScrollView`'s `main-thread:gesture` for proper gesture arbitration.
|
|
153
|
+
|
|
154
|
+
**Q: Long lists stutter with `ScrollView` + `.map()`?**
|
|
155
|
+
|
|
156
|
+
A: Use `List` or `FeedList` for large datasets; they provide virtualization and view reuse. `ScrollView` suits limited content scenarios.
|
|
157
|
+
|
|
158
|
+
**Q: How to implement “Back to Top”?
|
|
159
|
+
|
|
160
|
+
A: Maintain a scroll position state and programmatically set `scroll-top` (or use native APIs) on interaction.
|
|
161
|
+
|
|
162
|
+
**Q: How to use flex layout inside `ScrollView`?**
|
|
163
|
+
|
|
164
|
+
A: The first-level direct child of `ScrollView` is constrained to `display: linear`. If you need `flex`, add a wrapper `view` as the first child and apply all flex-related styles to that wrapper.
|
|
165
|
+
|
|
166
|
+
## 5. Sub components
|
|
167
|
+
|
|
168
|
+
`ScrollView` is a container component. Its direct child elements are the scrollable content. There are no named child components.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-scroll-view",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.143.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
"module": "./dist/index.jsx",
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"files": [
|
|
19
|
-
"src
|
|
19
|
+
"src",
|
|
20
|
+
"!src/**/__tests__/**",
|
|
21
|
+
"!src/**/*.test.*",
|
|
20
22
|
"README.md",
|
|
23
|
+
"SKILL.md",
|
|
21
24
|
"CHANGELOG.md",
|
|
22
25
|
"LICENSE",
|
|
23
|
-
"tsconfig.docs.json",
|
|
24
|
-
"tsconfig.json",
|
|
25
26
|
"dist/**"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@lynx-js/gesture-runtime": "2.1.1",
|
|
29
|
-
"@lynx-js/lynx-ui-common": "3.
|
|
30
|
-
"@lynx-js/lynx-ui-lazy-component": "3.
|
|
30
|
+
"@lynx-js/lynx-ui-common": "3.143.0",
|
|
31
|
+
"@lynx-js/lynx-ui-lazy-component": "3.143.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@lynx-js/react": "0.123.1",
|
package/tsconfig.docs.json
DELETED