@lynx-js/lynx-ui-scroll-view 0.0.0 → 3.131.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 +35 -0
- package/LICENSE +201 -0
- package/README.md +46 -0
- package/dist/ScrollViewBasic.d.ts +9 -0
- package/dist/ScrollViewBasic.d.ts.map +1 -0
- package/dist/ScrollViewBasic.jsx +11 -0
- package/dist/ScrollViewBasic.jsx.map +1 -0
- package/dist/ScrollViewWithBouncesHook.d.ts +13 -0
- package/dist/ScrollViewWithBouncesHook.d.ts.map +1 -0
- package/dist/ScrollViewWithBouncesHook.jsx +57 -0
- package/dist/ScrollViewWithBouncesHook.jsx.map +1 -0
- package/dist/hooks/useBounce.d.ts +43 -0
- package/dist/hooks/useBounce.d.ts.map +1 -0
- package/dist/hooks/useBounce.jsx +383 -0
- package/dist/hooks/useBounce.jsx.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.jsx +94 -0
- package/dist/index.jsx.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.docs.d.ts +364 -0
- package/dist/types/index.docs.d.ts.map +1 -0
- package/dist/types/index.docs.jsx +6 -0
- package/dist/types/index.docs.jsx.map +1 -0
- package/package.json +48 -4
- package/src/ScrollViewBasic.tsx +32 -0
- package/src/ScrollViewWithBouncesHook.tsx +150 -0
- package/src/hooks/useBounce.tsx +834 -0
- package/src/index.tsx +240 -0
- package/src/types/index.docs.ts +397 -0
- package/src/types/index.ts +5 -0
- package/tsconfig.docs.json +7 -0
- package/tsconfig.json +9 -0
- /package/{index.js → dist/types/index.jsx} +0 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from '@lynx-js/react';
|
|
2
|
+
import type { BaseGesture } from '@lynx-js/gesture-runtime';
|
|
3
|
+
import type { BaseScrollEvents, BaseUIExposureEvents, BaseUIExposureProps, BaseUILayoutEvents, BaseUITouchEvents, ComponentBasicProps, LazyOptions } from '@lynx-js/lynx-ui-common';
|
|
4
|
+
import type { CSSProperties } from '@lynx-js/types';
|
|
5
|
+
export type ScrollView = (props: ScrollViewProps) => ReactElement;
|
|
6
|
+
type ScrollPropagationBehaviorOption = 'native' | 'propagate' | 'preventPropagate';
|
|
7
|
+
export interface ScrollViewRef {
|
|
8
|
+
}
|
|
9
|
+
export interface ScrollViewProps extends BaseUITouchEvents, BaseScrollEvents, BaseUIExposureEvents, BaseUILayoutEvents, BaseUIExposureProps, ComponentBasicProps {
|
|
10
|
+
/**
|
|
11
|
+
* The id of the scrollview.
|
|
12
|
+
* @zh 滚动视图的id。
|
|
13
|
+
* @defaultValue "scrollview"
|
|
14
|
+
* @Android
|
|
15
|
+
* @iOS
|
|
16
|
+
*/
|
|
17
|
+
scrollviewId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Enable scroll interaction.
|
|
20
|
+
* @zh 启用滚动。
|
|
21
|
+
* @defaultValue true
|
|
22
|
+
* @Android
|
|
23
|
+
* @iOS
|
|
24
|
+
* @Harmony
|
|
25
|
+
*/
|
|
26
|
+
enableScroll?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Open the bouncing effect on iOS. If you want to use it on Android, please refer to the bounceableOption. If the bounceableOption is set, the iOSBounces property will be invalid.
|
|
29
|
+
* @zh 开启iOS上的回弹效果。如果想在安卓上使用,请参考bounceableOption。如果设置了bounceableOption,iOSBounces属性将失效。
|
|
30
|
+
* @defaultValue true
|
|
31
|
+
* @Android
|
|
32
|
+
* @iOS
|
|
33
|
+
*/
|
|
34
|
+
iOSBounces?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Testing Mode.
|
|
37
|
+
* @zh 测试模式
|
|
38
|
+
* @Android
|
|
39
|
+
* @iOS
|
|
40
|
+
*/
|
|
41
|
+
testing?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Be used to mark the exposure timing of lazy loading. Please ensure that it is unique throughout the page.
|
|
44
|
+
* @zh 用于标记懒加载的曝光时机。请确保页面中唯一。
|
|
45
|
+
* @Android
|
|
46
|
+
* @iOS
|
|
47
|
+
* @deprecated Please use lazyOptions instead.
|
|
48
|
+
*/
|
|
49
|
+
scene?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Horizontal scroll.
|
|
52
|
+
* @zh 水平滚动。
|
|
53
|
+
* @deprecated 3.119. Use scrollOrientation instead.
|
|
54
|
+
* @Android
|
|
55
|
+
* @iOS
|
|
56
|
+
*/
|
|
57
|
+
horizontal?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Set to 'vertical' for vertical scrolling and set to 'horizontal' for horizontal scrolling.
|
|
60
|
+
* @zh 设置为 'vertical' 为垂直滚动,设置为 'horizontal' 为水平滚动。
|
|
61
|
+
* @defaultValue 'vertical'
|
|
62
|
+
* @since 3.119
|
|
63
|
+
* @iOS
|
|
64
|
+
* @Android
|
|
65
|
+
* @Harmony
|
|
66
|
+
*/
|
|
67
|
+
scrollOrientation?: 'vertical' | 'horizontal';
|
|
68
|
+
/**
|
|
69
|
+
* When enabled, only the items that are about to enter the viewport are rendered, reducing initial load time and memory usage; remaining items are rendered as they approach visibility during scroll.
|
|
70
|
+
* @zh 启用懒渲染。只有当用户滚动到可见区域时,才会渲染 items,从而减少初始加载时间和内存使用。
|
|
71
|
+
* @defaultValue true
|
|
72
|
+
* @Android
|
|
73
|
+
* @iOS
|
|
74
|
+
*/
|
|
75
|
+
lazyOptions?: LazyOptions;
|
|
76
|
+
/**
|
|
77
|
+
* Estimated height and width of the items need to be set.
|
|
78
|
+
* @zh 需要设置 items 的预计高度和宽度。
|
|
79
|
+
* @Android
|
|
80
|
+
* @iOS
|
|
81
|
+
* @deprecated Please use lazyOptions instead.
|
|
82
|
+
*/
|
|
83
|
+
estimatedItemStyle?: CSSProperties;
|
|
84
|
+
/**
|
|
85
|
+
* When enabled, only the items that are about to enter the viewport are rendered, reducing initial load time and memory usage; remaining items are rendered as they approach visibility during scroll.
|
|
86
|
+
* @zh 启用懒渲染。只有当用户滚动到可见区域时,才会渲染 items,从而减少初始加载时间和内存使用。
|
|
87
|
+
* @defaultValue true
|
|
88
|
+
* @Android
|
|
89
|
+
* @iOS
|
|
90
|
+
* @deprecated Please use lazyOptions instead.
|
|
91
|
+
*/
|
|
92
|
+
lazy?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Sticky item, designed for `Tabs`.
|
|
95
|
+
* @zh 粘性元素,设计用于 `Tabs`。
|
|
96
|
+
* @Android
|
|
97
|
+
* @iOS
|
|
98
|
+
*/
|
|
99
|
+
sticky?: ReactElement;
|
|
100
|
+
/**
|
|
101
|
+
* Children in scroll-view.
|
|
102
|
+
* @zh `scroll-view` 的子元素。
|
|
103
|
+
* @Android
|
|
104
|
+
* @iOS
|
|
105
|
+
*/
|
|
106
|
+
children?: ReactNode;
|
|
107
|
+
/**
|
|
108
|
+
* exposure-screen-margin-top
|
|
109
|
+
* @zh 曝光屏幕上方边距
|
|
110
|
+
* @defaultValue '10px'
|
|
111
|
+
* @Android
|
|
112
|
+
* @iOS
|
|
113
|
+
* @deprecated Please use lazyOptions instead.
|
|
114
|
+
*/
|
|
115
|
+
exposureTop?: string;
|
|
116
|
+
/**
|
|
117
|
+
* exposure-screen-margin-bottom
|
|
118
|
+
* @zh 曝光屏幕下方边距
|
|
119
|
+
* @defaultValue '10px'
|
|
120
|
+
* @Android
|
|
121
|
+
* @iOS
|
|
122
|
+
* @deprecated Please use lazyOptions instead.
|
|
123
|
+
*/
|
|
124
|
+
exposureBottom?: string;
|
|
125
|
+
/**
|
|
126
|
+
* exposure-screen-margin-left
|
|
127
|
+
* @zh 曝光屏幕左侧边距
|
|
128
|
+
* @defaultValue '10px'
|
|
129
|
+
* @Android
|
|
130
|
+
* @iOS
|
|
131
|
+
* @deprecated Please use lazyOptions instead.
|
|
132
|
+
*/
|
|
133
|
+
exposureLeft?: string;
|
|
134
|
+
/**
|
|
135
|
+
* exposure-screen-margin-right
|
|
136
|
+
* @zh 曝光屏幕右侧边距
|
|
137
|
+
* @defaultValue '10px'
|
|
138
|
+
* @Android
|
|
139
|
+
* @iOS
|
|
140
|
+
* @deprecated Please use lazyOptions instead.
|
|
141
|
+
*/
|
|
142
|
+
exposureRight?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Enable scroll monitor.
|
|
145
|
+
* @zh 启用滚动监控。
|
|
146
|
+
* @defaultValue false
|
|
147
|
+
* @iOS
|
|
148
|
+
* @Android
|
|
149
|
+
* @Harmony
|
|
150
|
+
*/
|
|
151
|
+
enableScrollMonitor?: boolean;
|
|
152
|
+
/**
|
|
153
|
+
* The tag for scroll monitor.
|
|
154
|
+
* @zh 滚动监控的标签。
|
|
155
|
+
* @defaultValue false
|
|
156
|
+
* @iOS
|
|
157
|
+
* @Android
|
|
158
|
+
* @Harmony
|
|
159
|
+
*/
|
|
160
|
+
scrollMonitorTag?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Estimated first screen item count for lazy rendering. Remaining children will complete rendering based on exposure. When this estimate is small, it may cause a blank screen phenomenon where some nodes exist on the first screen.
|
|
163
|
+
* @zh 懒加载时预计的第一页项数。剩余的子元素会基于曝光状态完成渲染。当此预估较小时,可能会导致第一屏出现空白现象。
|
|
164
|
+
* @defaultValue 1
|
|
165
|
+
* @Android
|
|
166
|
+
* @iOS
|
|
167
|
+
* @deprecated Please use lazyOptions instead.
|
|
168
|
+
*/
|
|
169
|
+
firstScreenItemCount?: number;
|
|
170
|
+
/**
|
|
171
|
+
* Enable bouncing effect
|
|
172
|
+
* @zh 启用弹性效果
|
|
173
|
+
* @Android
|
|
174
|
+
* @iOS
|
|
175
|
+
* @deprecated Please use bounceableOptions instead.
|
|
176
|
+
*/
|
|
177
|
+
bounceable?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Props for bouncing effect
|
|
180
|
+
* @zh 弹性效果的参数
|
|
181
|
+
* @defaultValue { enableBounces: true, singleSidedBounce: "iOSBounces" },
|
|
182
|
+
* @Android
|
|
183
|
+
* @iOS
|
|
184
|
+
*/
|
|
185
|
+
bounceableOptions?: boolean | BounceableBasicProps;
|
|
186
|
+
/**
|
|
187
|
+
* Controls whether scroll events propagate to parent containers. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.
|
|
188
|
+
* @zh 控制滚动事件是否向父级容器传递。'preventPropagate' 在 iOS 上暂时需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。
|
|
189
|
+
* @experimental Currently, this property has limitations because its full functionality depends on a higher native SDK version: on iOS, `propagate` only works if both the parent and this component are set to` propagate` and `useRefactorList={true}` does not support 'propagate'. On Android, `preventPropagate` only functions when the parent is `x-swiper` or `x-viewpager-ng`.
|
|
190
|
+
* @defaultValue 'native'
|
|
191
|
+
* @iOS
|
|
192
|
+
* @Android
|
|
193
|
+
*/
|
|
194
|
+
scrollPropagationBehavior?: ScrollPropagationBehaviorOption;
|
|
195
|
+
/**
|
|
196
|
+
* The specific class name of the container that is blocked when 'scrollPropagationBehavior' is set to be 'preventPropagate', must be informed by the container provider. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.
|
|
197
|
+
* @zh 当 scrollPropagationBehavior 设为 'preventPropagate' 时,被阻止滚动的容器的具体类名。'preventPropagate' 需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。
|
|
198
|
+
* This is a temporary props and will be deprecated on new Lynx SDK version.
|
|
199
|
+
* @defaultValue 'BDXLynxViewPager'
|
|
200
|
+
* @iOS
|
|
201
|
+
*/
|
|
202
|
+
temporaryBlockScrollClass?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Used to specify the native container tag that is blocked when 'scrollPropagationBehavior' is set to be 'preventPropagate', corresponding to the Tag attribute of UIView. Needs to be specified by the native container provider. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.
|
|
205
|
+
* @zh 用于指定当 scrollPropagationBehavior 设为 'preventPropagate' 时被阻止滚动的原生容器标签(对应 UIView 的 Tag 属性)。该值需由原生容器提供方指定,且 'preventPropagate' 必须与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。
|
|
206
|
+
* This is a temporary props and will be deprecated on new Lynx SDK version.
|
|
207
|
+
* @defaultValue 0
|
|
208
|
+
* @iOS
|
|
209
|
+
*/
|
|
210
|
+
temporaryBlockScrollTag?: number;
|
|
211
|
+
/**
|
|
212
|
+
* Android-only temporary flag to control nested scroll; maps to native 'enable-nested-scroll'. Android default value is true.
|
|
213
|
+
* @zh 仅 Android 生效的临时开关,用于控制嵌套滚动冲突;映射到原生属性 'enable-nested-scroll'。Android上默认开启。
|
|
214
|
+
* @Android
|
|
215
|
+
*/
|
|
216
|
+
temporaryNestedScroll?: boolean;
|
|
217
|
+
/**
|
|
218
|
+
* If you want to use gesture, pass it here.
|
|
219
|
+
* @zh 如果想使用 gesture API,请传入该属性。
|
|
220
|
+
* @iOS
|
|
221
|
+
* @Android
|
|
222
|
+
*/
|
|
223
|
+
'main-thread:gesture'?: BaseGesture;
|
|
224
|
+
/**
|
|
225
|
+
* Android touch recognition mode. When inside a component that supports 'paging' mode, 'paging' must be enabled.
|
|
226
|
+
* @zh Android 触摸识别模式,当处于支持 'paging' 模式的元件中时,需要开启 'paging' 模式。
|
|
227
|
+
* @Android
|
|
228
|
+
*/
|
|
229
|
+
androidTouchSlop?: 'default' | 'paging';
|
|
230
|
+
/**
|
|
231
|
+
* Being triggered when scrolling content changes.
|
|
232
|
+
* @zh 滚动内容变化时触发。
|
|
233
|
+
* @eventProperty
|
|
234
|
+
* @Android
|
|
235
|
+
* @iOS
|
|
236
|
+
*/
|
|
237
|
+
onContentSizeChange?: (res: {
|
|
238
|
+
detail: {
|
|
239
|
+
scrollWidth: number;
|
|
240
|
+
scrollHeight: number;
|
|
241
|
+
};
|
|
242
|
+
}) => void;
|
|
243
|
+
}
|
|
244
|
+
export interface scrollToBouncesInfo {
|
|
245
|
+
direction: 'upper' | 'lower';
|
|
246
|
+
}
|
|
247
|
+
export interface BounceableBasicProps {
|
|
248
|
+
/**
|
|
249
|
+
* Whether to enable bounce effect
|
|
250
|
+
* @zh 是否开启回弹效果
|
|
251
|
+
* @iOS
|
|
252
|
+
* @Android
|
|
253
|
+
* @Harmony
|
|
254
|
+
*/
|
|
255
|
+
enableBounces: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Trigger bounces effect during fling
|
|
258
|
+
* @zh 在快速滑动(fling)时触发回弹效果
|
|
259
|
+
* @defaultValue false
|
|
260
|
+
* @iOS
|
|
261
|
+
* @Android
|
|
262
|
+
* @Harmony
|
|
263
|
+
*/
|
|
264
|
+
enableBounceEventInFling?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* The threshold distance of upper bounces, in pixels, when triggering the scrollToBounces event
|
|
267
|
+
* @zh 触发 `scrollToBounces` 事件时,上部回弹的阈值距离(单位:px)
|
|
268
|
+
* @defaultValue 0
|
|
269
|
+
* @iOS
|
|
270
|
+
* @Android
|
|
271
|
+
* @Harmony
|
|
272
|
+
*/
|
|
273
|
+
startBounceTriggerDistance?: number;
|
|
274
|
+
/**
|
|
275
|
+
* The threshold distance of lower bounces, in pixels, when triggering the scrollToBounces event
|
|
276
|
+
* @zh 触发 `scrollToBounces` 事件时,下部回弹的阈值距离(单位:px)
|
|
277
|
+
* @defaultValue 0
|
|
278
|
+
* @iOS
|
|
279
|
+
* @Android
|
|
280
|
+
* @Harmony
|
|
281
|
+
*/
|
|
282
|
+
endBounceTriggerDistance?: number;
|
|
283
|
+
/**
|
|
284
|
+
* Content of upper bounces view, which will be displayed during the upper bouncing effect.
|
|
285
|
+
* @zh 上部回弹视图的内容,将在上部回弹效果期间显示。
|
|
286
|
+
* @iOS
|
|
287
|
+
* @Android
|
|
288
|
+
* @Harmony
|
|
289
|
+
*/
|
|
290
|
+
upperBounceItem?: any;
|
|
291
|
+
/**
|
|
292
|
+
* Content of lower bounces view, which will be displayed during the lower bouncing effect.
|
|
293
|
+
* @zh 下部回弹视图的内容,将在下部回弹效果期间显示。
|
|
294
|
+
* @iOS
|
|
295
|
+
* @Android
|
|
296
|
+
* @Harmony
|
|
297
|
+
*/
|
|
298
|
+
lowerBounceItem?: any;
|
|
299
|
+
/**
|
|
300
|
+
* Whether the scrollable container can bounce when the content area of the scrollable container is smaller than the viewport area.
|
|
301
|
+
* @zh 当可滚动容器的内容区域小于视口区域时,是否允许容器回弹。
|
|
302
|
+
* @defaultValue true
|
|
303
|
+
* @iOS
|
|
304
|
+
* @Android
|
|
305
|
+
* @Harmony
|
|
306
|
+
*/
|
|
307
|
+
alwaysBouncing?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* The direction of the bounce effect. 'both' for bouncing on both ends, 'none' to disable bounce, and 'upper'/'lower' for bouncing on either end
|
|
310
|
+
* @zh 回弹效果的方向。'both' 表示两端都回弹,'none' 表示禁用回弹,'upper'/'lower' 表示只在上端或下端回弹。
|
|
311
|
+
* @defaultValue 'both'
|
|
312
|
+
* @iOS
|
|
313
|
+
* @Android
|
|
314
|
+
* @Harmony
|
|
315
|
+
*/
|
|
316
|
+
singleSidedBounce?: 'upper' | 'lower' | 'both' | 'iOSBounces' | 'none';
|
|
317
|
+
/**
|
|
318
|
+
* Unit: px. Optional size hint for bounce effect. Recommended when used in List or <list/>.
|
|
319
|
+
* @zh 单位:px。可选的回弹效果尺寸提示。在列表或 `<list/>` 中使用时推荐设置。
|
|
320
|
+
* @Android
|
|
321
|
+
* @iOS
|
|
322
|
+
* @Harmony
|
|
323
|
+
*/
|
|
324
|
+
estimatedHeight?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Unit: px. Optional size hint for bounce effect. Recommended when used in List or <list/>.
|
|
327
|
+
* @zh 单位:px。可选的回弹效果尺寸提示。在列表或 `<list/>` 中使用时推荐设置。
|
|
328
|
+
* @Android
|
|
329
|
+
* @iOS
|
|
330
|
+
* @Harmony
|
|
331
|
+
*/
|
|
332
|
+
estimatedWidth?: number;
|
|
333
|
+
/**
|
|
334
|
+
* Display debug logs. Open it when you find a bug.
|
|
335
|
+
* @zh 显示调试日志。当您发现错误时,请打开此选项。
|
|
336
|
+
* @defaultValue false
|
|
337
|
+
* @iOS
|
|
338
|
+
* @Android
|
|
339
|
+
* @Harmony
|
|
340
|
+
*/
|
|
341
|
+
debugLog?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* requestAnimationFrame don't work under lynx version 2.15.2. This switch should be opened when the version is higher than 2.15.2.
|
|
344
|
+
* @zh `requestAnimationFrame` 在 lynx 2.15.2 以下版本中不起作用。当版本高于 2.15.2 时,应打开此开关。
|
|
345
|
+
* @defaultValue false
|
|
346
|
+
* @iOS
|
|
347
|
+
* @Android
|
|
348
|
+
* @Harmony
|
|
349
|
+
*/
|
|
350
|
+
validAnimationVersion?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* When bounces effect is triggered and the bounce distance is larger than startBounceDistance or endBounceDistance on the upper or lower side, the scrollToBounces event will be triggered.
|
|
353
|
+
* @zh 当触发回弹效果并且回弹距离在上侧或下侧大于 `startBounceDistance` 或 `endBounceDistance` 时,将触发 `scrollToBounces` 事件。
|
|
354
|
+
* @defaultValue 0
|
|
355
|
+
* @eventProperty
|
|
356
|
+
* @iOS
|
|
357
|
+
* @Android
|
|
358
|
+
* @Harmony
|
|
359
|
+
*/
|
|
360
|
+
onScrollToBounces?: (e: scrollToBouncesInfo) => void;
|
|
361
|
+
}
|
|
362
|
+
export declare const ScrollEventMapping: Record<string, string>;
|
|
363
|
+
export {};
|
|
364
|
+
//# sourceMappingURL=index.docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types/index.docs.jsx","sources":["webpack://@lynx-js/lynx-ui-scroll-view/./src/types/index.docs.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { ReactElement, ReactNode } from '@lynx-js/react'\n\nimport type { BaseGesture } from '@lynx-js/gesture-runtime'\nimport type {\n BaseScrollEvents,\n BaseUIExposureEvents,\n BaseUIExposureProps,\n BaseUILayoutEvents,\n BaseUITouchEvents,\n ComponentBasicProps,\n LazyOptions,\n} from '@lynx-js/lynx-ui-common'\nimport type { CSSProperties } from '@lynx-js/types'\n\nexport type ScrollView = (props: ScrollViewProps) => ReactElement\n\ntype ScrollPropagationBehaviorOption =\n | 'native' // Follows platform default behavior\n | 'propagate' // Always allow scroll propagation\n // | 'propagateAtEdge' // @todo Child scrolls first; parent scrolls on next touch at edge\n | 'preventPropagate' // Never allow scroll propagation\n\n// biome-ignore lint/suspicious/noEmptyInterface: <explanation>\nexport interface ScrollViewRef {}\n\nexport interface ScrollViewProps\n extends\n BaseUITouchEvents,\n BaseScrollEvents,\n BaseUIExposureEvents,\n BaseUILayoutEvents,\n BaseUIExposureProps,\n ComponentBasicProps\n{\n /**\n * The id of the scrollview.\n * @zh 滚动视图的id。\n * @defaultValue \"scrollview\"\n * @Android\n * @iOS\n */\n scrollviewId?: string\n /**\n * Enable scroll interaction.\n * @zh 启用滚动。\n * @defaultValue true\n * @Android\n * @iOS\n * @Harmony\n */\n enableScroll?: boolean\n /**\n * Open the bouncing effect on iOS. If you want to use it on Android, please refer to the bounceableOption. If the bounceableOption is set, the iOSBounces property will be invalid.\n * @zh 开启iOS上的回弹效果。如果想在安卓上使用,请参考bounceableOption。如果设置了bounceableOption,iOSBounces属性将失效。\n * @defaultValue true\n * @Android\n * @iOS\n */\n iOSBounces?: boolean\n /**\n * Testing Mode.\n * @zh 测试模式\n * @Android\n * @iOS\n */\n testing?: boolean\n /**\n * Be used to mark the exposure timing of lazy loading. Please ensure that it is unique throughout the page.\n * @zh 用于标记懒加载的曝光时机。请确保页面中唯一。\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n scene?: string\n /**\n * Horizontal scroll.\n * @zh 水平滚动。\n * @deprecated 3.119. Use scrollOrientation instead.\n * @Android\n * @iOS\n */\n horizontal?: boolean\n /**\n * Set to 'vertical' for vertical scrolling and set to 'horizontal' for horizontal scrolling.\n * @zh 设置为 'vertical' 为垂直滚动,设置为 'horizontal' 为水平滚动。\n * @defaultValue 'vertical'\n * @since 3.119\n * @iOS\n * @Android\n * @Harmony\n */\n scrollOrientation?: 'vertical' | 'horizontal'\n /**\n * When enabled, only the items that are about to enter the viewport are rendered, reducing initial load time and memory usage; remaining items are rendered as they approach visibility during scroll.\n * @zh 启用懒渲染。只有当用户滚动到可见区域时,才会渲染 items,从而减少初始加载时间和内存使用。\n * @defaultValue true\n * @Android\n * @iOS\n */\n lazyOptions?: LazyOptions\n /**\n * Estimated height and width of the items need to be set.\n * @zh 需要设置 items 的预计高度和宽度。\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n estimatedItemStyle?: CSSProperties\n /**\n * When enabled, only the items that are about to enter the viewport are rendered, reducing initial load time and memory usage; remaining items are rendered as they approach visibility during scroll.\n * @zh 启用懒渲染。只有当用户滚动到可见区域时,才会渲染 items,从而减少初始加载时间和内存使用。\n * @defaultValue true\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n lazy?: boolean\n /**\n * Sticky item, designed for `Tabs`.\n * @zh 粘性元素,设计用于 `Tabs`。\n * @Android\n * @iOS\n */\n sticky?: ReactElement\n /**\n * Children in scroll-view.\n * @zh `scroll-view` 的子元素。\n * @Android\n * @iOS\n */\n children?: ReactNode\n /**\n * exposure-screen-margin-top\n * @zh 曝光屏幕上方边距\n * @defaultValue '10px'\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n exposureTop?: string\n /**\n * exposure-screen-margin-bottom\n * @zh 曝光屏幕下方边距\n * @defaultValue '10px'\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n exposureBottom?: string\n /**\n * exposure-screen-margin-left\n * @zh 曝光屏幕左侧边距\n * @defaultValue '10px'\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n exposureLeft?: string\n /**\n * exposure-screen-margin-right\n * @zh 曝光屏幕右侧边距\n * @defaultValue '10px'\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n exposureRight?: string\n /**\n * Enable scroll monitor.\n * @zh 启用滚动监控。\n * @defaultValue false\n * @iOS\n * @Android\n * @Harmony\n */\n enableScrollMonitor?: boolean\n /**\n * The tag for scroll monitor.\n * @zh 滚动监控的标签。\n * @defaultValue false\n * @iOS\n * @Android\n * @Harmony\n */\n scrollMonitorTag?: string\n /**\n * Estimated first screen item count for lazy rendering. Remaining children will complete rendering based on exposure. When this estimate is small, it may cause a blank screen phenomenon where some nodes exist on the first screen.\n * @zh 懒加载时预计的第一页项数。剩余的子元素会基于曝光状态完成渲染。当此预估较小时,可能会导致第一屏出现空白现象。\n * @defaultValue 1\n * @Android\n * @iOS\n * @deprecated Please use lazyOptions instead.\n */\n firstScreenItemCount?: number\n /**\n * Enable bouncing effect\n * @zh 启用弹性效果\n * @Android\n * @iOS\n * @deprecated Please use bounceableOptions instead.\n */\n bounceable?: boolean\n /**\n * Props for bouncing effect\n * @zh 弹性效果的参数\n * @defaultValue { enableBounces: true, singleSidedBounce: \"iOSBounces\" },\n * @Android\n * @iOS\n */\n bounceableOptions?: boolean | BounceableBasicProps\n /**\n * Controls whether scroll events propagate to parent containers. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.\n * @zh 控制滚动事件是否向父级容器传递。'preventPropagate' 在 iOS 上暂时需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。\n * @experimental Currently, this property has limitations because its full functionality depends on a higher native SDK version: on iOS, `propagate` only works if both the parent and this component are set to` propagate` and `useRefactorList={true}` does not support 'propagate'. On Android, `preventPropagate` only functions when the parent is `x-swiper` or `x-viewpager-ng`.\n * @defaultValue 'native'\n * @iOS\n * @Android\n */\n scrollPropagationBehavior?: ScrollPropagationBehaviorOption\n /**\n * The specific class name of the container that is blocked when 'scrollPropagationBehavior' is set to be 'preventPropagate', must be informed by the container provider. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.\n * @zh 当 scrollPropagationBehavior 设为 'preventPropagate' 时,被阻止滚动的容器的具体类名。'preventPropagate' 需与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。\n * This is a temporary props and will be deprecated on new Lynx SDK version.\n * @defaultValue 'BDXLynxViewPager'\n * @iOS\n */\n temporaryBlockScrollClass?: string\n /**\n * Used to specify the native container tag that is blocked when 'scrollPropagationBehavior' is set to be 'preventPropagate', corresponding to the Tag attribute of UIView. Needs to be specified by the native container provider. For now, 'preventPropagate' needs to be used together with temporaryBlockScrollClass and temporaryBlockScrollTag on iOS.\n * @zh 用于指定当 scrollPropagationBehavior 设为 'preventPropagate' 时被阻止滚动的原生容器标签(对应 UIView 的 Tag 属性)。该值需由原生容器提供方指定,且 'preventPropagate' 必须与 temporaryBlockScrollClass 和 temporaryBlockScrollTag 配合使用。\n * This is a temporary props and will be deprecated on new Lynx SDK version.\n * @defaultValue 0\n * @iOS\n */\n temporaryBlockScrollTag?: number\n /**\n * Android-only temporary flag to control nested scroll; maps to native 'enable-nested-scroll'. Android default value is true.\n * @zh 仅 Android 生效的临时开关,用于控制嵌套滚动冲突;映射到原生属性 'enable-nested-scroll'。Android上默认开启。\n * @Android\n */\n temporaryNestedScroll?: boolean\n /**\n * If you want to use gesture, pass it here.\n * @zh 如果想使用 gesture API,请传入该属性。\n * @iOS\n * @Android\n */\n 'main-thread:gesture'?: BaseGesture\n\n /**\n * Android touch recognition mode. When inside a component that supports 'paging' mode, 'paging' must be enabled.\n * @zh Android 触摸识别模式,当处于支持 'paging' 模式的元件中时,需要开启 'paging' 模式。\n * @Android\n */\n androidTouchSlop?: 'default' | 'paging'\n\n /**\n * Being triggered when scrolling content changes.\n * @zh 滚动内容变化时触发。\n * @eventProperty\n * @Android\n * @iOS\n */\n onContentSizeChange?: (res: {\n detail: { scrollWidth: number, scrollHeight: number }\n }) => void\n}\n\nexport interface scrollToBouncesInfo {\n direction: 'upper' | 'lower'\n}\n\nexport interface BounceableBasicProps {\n /**\n * Whether to enable bounce effect\n * @zh 是否开启回弹效果\n * @iOS\n * @Android\n * @Harmony\n */\n enableBounces: boolean\n /**\n * Trigger bounces effect during fling\n * @zh 在快速滑动(fling)时触发回弹效果\n * @defaultValue false\n * @iOS\n * @Android\n * @Harmony\n */\n enableBounceEventInFling?: boolean\n /**\n * The threshold distance of upper bounces, in pixels, when triggering the scrollToBounces event\n * @zh 触发 `scrollToBounces` 事件时,上部回弹的阈值距离(单位:px)\n * @defaultValue 0\n * @iOS\n * @Android\n * @Harmony\n */\n startBounceTriggerDistance?: number\n /**\n * The threshold distance of lower bounces, in pixels, when triggering the scrollToBounces event\n * @zh 触发 `scrollToBounces` 事件时,下部回弹的阈值距离(单位:px)\n * @defaultValue 0\n * @iOS\n * @Android\n * @Harmony\n */\n endBounceTriggerDistance?: number\n /**\n * Content of upper bounces view, which will be displayed during the upper bouncing effect.\n * @zh 上部回弹视图的内容,将在上部回弹效果期间显示。\n * @iOS\n * @Android\n * @Harmony\n */\n // biome-ignore lint/suspicious/noExplicitAny: expected\n upperBounceItem?: any\n /**\n * Content of lower bounces view, which will be displayed during the lower bouncing effect.\n * @zh 下部回弹视图的内容,将在下部回弹效果期间显示。\n * @iOS\n * @Android\n * @Harmony\n */\n // biome-ignore lint/suspicious/noExplicitAny: expected\n lowerBounceItem?: any\n /**\n * Whether the scrollable container can bounce when the content area of the scrollable container is smaller than the viewport area.\n * @zh 当可滚动容器的内容区域小于视口区域时,是否允许容器回弹。\n * @defaultValue true\n * @iOS\n * @Android\n * @Harmony\n */\n alwaysBouncing?: boolean\n /**\n * The direction of the bounce effect. 'both' for bouncing on both ends, 'none' to disable bounce, and 'upper'/'lower' for bouncing on either end\n * @zh 回弹效果的方向。'both' 表示两端都回弹,'none' 表示禁用回弹,'upper'/'lower' 表示只在上端或下端回弹。\n * @defaultValue 'both'\n * @iOS\n * @Android\n * @Harmony\n */\n singleSidedBounce?: 'upper' | 'lower' | 'both' | 'iOSBounces' | 'none'\n /**\n * Unit: px. Optional size hint for bounce effect. Recommended when used in List or <list/>.\n * @zh 单位:px。可选的回弹效果尺寸提示。在列表或 `<list/>` 中使用时推荐设置。\n * @Android\n * @iOS\n * @Harmony\n */\n estimatedHeight?: number\n /**\n * Unit: px. Optional size hint for bounce effect. Recommended when used in List or <list/>.\n * @zh 单位:px。可选的回弹效果尺寸提示。在列表或 `<list/>` 中使用时推荐设置。\n * @Android\n * @iOS\n * @Harmony\n */\n estimatedWidth?: number\n /**\n * Display debug logs. Open it when you find a bug.\n * @zh 显示调试日志。当您发现错误时,请打开此选项。\n * @defaultValue false\n * @iOS\n * @Android\n * @Harmony\n */\n debugLog?: boolean\n /**\n * requestAnimationFrame don't work under lynx version 2.15.2. This switch should be opened when the version is higher than 2.15.2.\n * @zh `requestAnimationFrame` 在 lynx 2.15.2 以下版本中不起作用。当版本高于 2.15.2 时,应打开此开关。\n * @defaultValue false\n * @iOS\n * @Android\n * @Harmony\n */\n validAnimationVersion?: boolean\n /**\n * When bounces effect is triggered and the bounce distance is larger than startBounceDistance or endBounceDistance on the upper or lower side, the scrollToBounces event will be triggered.\n * @zh 当触发回弹效果并且回弹距离在上侧或下侧大于 `startBounceDistance` 或 `endBounceDistance` 时,将触发 `scrollToBounces` 事件。\n * @defaultValue 0\n * @eventProperty\n * @iOS\n * @Android\n * @Harmony\n */\n onScrollToBounces?: (e: scrollToBouncesInfo) => void\n}\n\nexport const ScrollEventMapping: Record<string, string> = {\n onContentSizeChange: 'bindcontentsizechange',\n}\n"],"names":["ScrollEventMapping"],"mappings":"AA0YO,MAAMA,qBAA6C;IACxD,qBAAqB;AACvB"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-scroll-view",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
|
|
3
|
+
"version": "3.131.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
7
|
+
"directory": "packages/lynx-ui-scroll-view"
|
|
8
|
+
},
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "The Lynx Authors"
|
|
12
|
+
},
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.jsx",
|
|
16
|
+
"module": "./dist/index.jsx",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"src/**",
|
|
20
|
+
"README.md",
|
|
21
|
+
"CHANGELOG.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"tsconfig.docs.json",
|
|
24
|
+
"tsconfig.json",
|
|
25
|
+
"dist/**"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@lynx-js/gesture-runtime": "2.1.1",
|
|
29
|
+
"@lynx-js/lynx-ui-common": "3.131.0",
|
|
30
|
+
"@lynx-js/lynx-ui-lazy-component": "3.131.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@lynx-js/react": "0.113.0",
|
|
34
|
+
"@lynx-js/types": "3.6.0",
|
|
35
|
+
"@rslib/core": "^0.16.0",
|
|
36
|
+
"@types/react": "^18.3.8",
|
|
37
|
+
"typescript": "^5.5.3"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@lynx-js/react": ">=0.100.0",
|
|
41
|
+
"@lynx-js/types": "*",
|
|
42
|
+
"@types/react": "^18"
|
|
43
|
+
},
|
|
6
44
|
"publishConfig": {
|
|
7
45
|
"access": "public"
|
|
46
|
+
},
|
|
47
|
+
"jsnext:source": "./src/index.tsx",
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rslib build",
|
|
50
|
+
"build:watch": "rslib build --watch",
|
|
51
|
+
"test": "vitest"
|
|
8
52
|
}
|
|
9
|
-
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import type { ReactElement, ReactNode } from '@lynx-js/react'
|
|
6
|
+
|
|
7
|
+
import type { ScrollViewProps as ScrollViewElementProps } from '@lynx-js/types'
|
|
8
|
+
|
|
9
|
+
function ScrollViewBasic(
|
|
10
|
+
props: {
|
|
11
|
+
elementProps: ScrollViewElementProps
|
|
12
|
+
children?: ReactNode
|
|
13
|
+
sticky?: ReactElement
|
|
14
|
+
},
|
|
15
|
+
) {
|
|
16
|
+
const { children, sticky, elementProps } = props
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<scroll-view
|
|
20
|
+
{...elementProps}
|
|
21
|
+
android-touch-slop='page'
|
|
22
|
+
// This is a workaround for using RL3.0-ver 0.110.1 and SDK-ver <=3.4. It will force the scroll-view to update after the BTS is ready and flush the 'name' prop along with __AddEvents. Otherwise, a pure __AddEvents will be discarded by the engine and won't trigger the flush of the prop_bundle. As a result, all events will be lost.
|
|
23
|
+
// We do not use __MAIN_THREAD__ here to maintain compatibility with the old version of @lynx-js/react.
|
|
24
|
+
name={__LEPUS__ ? 'lepus' : 'background'}
|
|
25
|
+
>
|
|
26
|
+
{sticky}
|
|
27
|
+
{children}
|
|
28
|
+
</scroll-view>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ScrollViewBasic
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Copyright 2026 The Lynx Authors. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
import type { ForwardedRef, ReactElement, ReactNode } from '@lynx-js/react'
|
|
6
|
+
|
|
7
|
+
import '@lynx-js/gesture-runtime'
|
|
8
|
+
import type {
|
|
9
|
+
CSSProperties,
|
|
10
|
+
ScrollViewProps as ScrollViewElementProps,
|
|
11
|
+
} from '@lynx-js/types'
|
|
12
|
+
|
|
13
|
+
import { useBounce } from './hooks/useBounce'
|
|
14
|
+
import type {
|
|
15
|
+
BounceableBasicProps,
|
|
16
|
+
ScrollViewProps,
|
|
17
|
+
ScrollViewRef,
|
|
18
|
+
} from './types'
|
|
19
|
+
|
|
20
|
+
export type { ScrollViewProps, ScrollViewRef }
|
|
21
|
+
|
|
22
|
+
function ScrollViewWithBouncesHook(
|
|
23
|
+
props: {
|
|
24
|
+
elementProps: ScrollViewElementProps
|
|
25
|
+
children?: ReactNode
|
|
26
|
+
bounceableOptions?: BounceableBasicProps
|
|
27
|
+
sticky?: ReactElement
|
|
28
|
+
},
|
|
29
|
+
_ref: ForwardedRef<ScrollViewRef>,
|
|
30
|
+
) {
|
|
31
|
+
const { children, bounceableOptions, sticky, elementProps } = props
|
|
32
|
+
// @ts-expect-error Compatible with older versions
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
34
|
+
const horizontal = elementProps['scroll-x']
|
|
35
|
+
// @ts-expect-error Compatible with older versions
|
|
36
|
+
?? elementProps['scroll-y'] === false
|
|
37
|
+
const scrollViewId = elementProps.id
|
|
38
|
+
const { style } = elementProps as { style: CSSProperties }
|
|
39
|
+
// Initialize bounceableProps
|
|
40
|
+
let enableBounce = false
|
|
41
|
+
let bounceableProps: BounceableBasicProps = { enableBounces: false }
|
|
42
|
+
let startBounceView, endBounceView, upperExposureView, lowerExposureView
|
|
43
|
+
if (typeof bounceableOptions === 'boolean') {
|
|
44
|
+
enableBounce = bounceableOptions
|
|
45
|
+
bounceableProps = {
|
|
46
|
+
enableBounces: true,
|
|
47
|
+
singleSidedBounce: 'both',
|
|
48
|
+
alwaysBouncing: true,
|
|
49
|
+
validAnimationVersion: true,
|
|
50
|
+
}
|
|
51
|
+
} else if (typeof bounceableOptions === 'object') {
|
|
52
|
+
enableBounce = bounceableOptions.enableBounces
|
|
53
|
+
bounceableProps = bounceableOptions
|
|
54
|
+
bounceableProps.singleSidedBounce = bounceableOptions.singleSidedBounce
|
|
55
|
+
?? 'both'
|
|
56
|
+
bounceableProps.alwaysBouncing = bounceableOptions.alwaysBouncing ?? true
|
|
57
|
+
bounceableProps.validAnimationVersion =
|
|
58
|
+
bounceableOptions.validAnimationVersion ?? true
|
|
59
|
+
}
|
|
60
|
+
const bounceMTSProps = useBounce({
|
|
61
|
+
bounceableOptions: bounceableProps,
|
|
62
|
+
id: scrollViewId,
|
|
63
|
+
scrollOrientation: horizontal ? 'horizontal' : 'vertical',
|
|
64
|
+
})
|
|
65
|
+
if (enableBounce) {
|
|
66
|
+
if (bounceableProps.upperBounceItem) {
|
|
67
|
+
startBounceView = (
|
|
68
|
+
<view
|
|
69
|
+
id={`${scrollViewId}-upperBounceWrapper`}
|
|
70
|
+
style={`position:absolute;${
|
|
71
|
+
horizontal ? 'right:100%' : 'bottom:100%'
|
|
72
|
+
}; ${horizontal ? 'height:100%;' : 'width:100%;'};${
|
|
73
|
+
horizontal ? 'width:max-content' : 'height:max-content'
|
|
74
|
+
};`}
|
|
75
|
+
main-thread:gesture={elementProps['main-thread:gesture']}
|
|
76
|
+
>
|
|
77
|
+
{bounceableProps.upperBounceItem}
|
|
78
|
+
</view>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
if (bounceableProps.lowerBounceItem) {
|
|
82
|
+
endBounceView = (
|
|
83
|
+
<view
|
|
84
|
+
id={`${scrollViewId}-lowerBounceWrapper`}
|
|
85
|
+
style={`position:absolute;${horizontal ? 'left:100%' : 'top:100%'}; ${
|
|
86
|
+
horizontal ? 'height:100%;' : 'width:100%;'
|
|
87
|
+
};${horizontal ? 'width:max-content' : 'height:max-content'};`}
|
|
88
|
+
main-thread:gesture={elementProps['main-thread:gesture']}
|
|
89
|
+
>
|
|
90
|
+
{bounceableProps.lowerBounceItem}
|
|
91
|
+
</view>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
upperExposureView = (
|
|
95
|
+
<view
|
|
96
|
+
style={`display: flex; flex-direction: column; overflow:hidden; height: ${
|
|
97
|
+
horizontal ? '100%' : '1ppx'
|
|
98
|
+
}; width: ${horizontal ? '1ppx' : '100%'};`}
|
|
99
|
+
exposure-scene={scrollViewId}
|
|
100
|
+
exposure-id='upperExposureView'
|
|
101
|
+
id={`${scrollViewId}-upperExposureView`}
|
|
102
|
+
main-thread:binduidisappear={bounceMTSProps.onUpperDisexposure}
|
|
103
|
+
main-thread:binduiappear={bounceMTSProps.onUpperExposure}
|
|
104
|
+
main-thread:gesture={elementProps['main-thread:gesture']}
|
|
105
|
+
/>
|
|
106
|
+
)
|
|
107
|
+
lowerExposureView = (
|
|
108
|
+
<view
|
|
109
|
+
style={`display: flex; flex-direction: column; overflow:hidden; height: ${
|
|
110
|
+
horizontal ? '100%' : '1ppx'
|
|
111
|
+
}; width: ${horizontal ? '1ppx' : '100%'};`}
|
|
112
|
+
exposure-scene={scrollViewId}
|
|
113
|
+
exposure-id='lowerExposureView'
|
|
114
|
+
id={`${scrollViewId}-lowerExposureView`}
|
|
115
|
+
main-thread:binduidisappear={bounceMTSProps.onLowerDisexposure}
|
|
116
|
+
main-thread:binduiappear={bounceMTSProps.onLowerExposure}
|
|
117
|
+
main-thread:gesture={elementProps['main-thread:gesture']}
|
|
118
|
+
/>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<view
|
|
124
|
+
id={`${scrollViewId}-BounceWrapper`}
|
|
125
|
+
style={`display: flex; flex-direction: column; overflow:hidden; height: ${
|
|
126
|
+
horizontal ? '100%' : `${style?.height}`
|
|
127
|
+
}; width: ${horizontal ? `${style?.width}` : '100%'};`}
|
|
128
|
+
main-thread:gesture={elementProps['main-thread:gesture']}
|
|
129
|
+
>
|
|
130
|
+
<scroll-view
|
|
131
|
+
{...elementProps}
|
|
132
|
+
{...bounceMTSProps}
|
|
133
|
+
bounces={false}
|
|
134
|
+
ios-enable-simultaneous-touch={true}
|
|
135
|
+
// This is a workaround for using RL3.0-ver 0.110.1 and SDK-ver <=3.4. It will force the scroll-view to update after the BTS is ready and flush the 'name' prop along with __AddEvents. Otherwise, a pure __AddEvents will be discarded by the engine and won't trigger the flush of the prop_bundle. As a result, all events will be lost.
|
|
136
|
+
// We do not use __MAIN_THREAD__ here to maintain compatibility with the old version of @lynx-js/react.
|
|
137
|
+
name={__LEPUS__ ? 'lepus' : 'background'}
|
|
138
|
+
>
|
|
139
|
+
{upperExposureView}
|
|
140
|
+
{sticky}
|
|
141
|
+
{children}
|
|
142
|
+
{lowerExposureView}
|
|
143
|
+
</scroll-view>
|
|
144
|
+
{startBounceView}
|
|
145
|
+
{endBounceView}
|
|
146
|
+
</view>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export default ScrollViewWithBouncesHook
|