@lynx-js/lynx-ui-scroll-view 3.130.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 +14 -0
- package/dist/ScrollViewWithBouncesHook.d.ts +1 -2
- package/dist/ScrollViewWithBouncesHook.d.ts.map +1 -1
- package/dist/ScrollViewWithBouncesHook.jsx +1 -1
- package/dist/ScrollViewWithBouncesHook.jsx.map +1 -1
- 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 +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.jsx +2 -1
- package/dist/index.jsx.map +1 -1
- package/dist/types/index.docs.d.ts +119 -1
- package/dist/types/index.docs.d.ts.map +1 -1
- package/dist/types/index.docs.jsx.map +1 -1
- package/package.json +3 -3
- package/src/ScrollViewWithBouncesHook.tsx +6 -3
- package/src/hooks/useBounce.tsx +834 -0
- package/src/index.tsx +5 -1
- package/src/types/index.docs.ts +122 -1
package/src/index.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import type { ForwardedRef, ReactNode } from '@lynx-js/react'
|
|
|
7
7
|
|
|
8
8
|
import '@lynx-js/gesture-runtime'
|
|
9
9
|
import type { GestureKind } from '@lynx-js/gesture-runtime'
|
|
10
|
-
import type {
|
|
10
|
+
import type { LazyOptions } from '@lynx-js/lynx-ui-common'
|
|
11
11
|
import {
|
|
12
12
|
ExposureEventsMapping,
|
|
13
13
|
LayoutEventsMapping,
|
|
@@ -24,12 +24,16 @@ import type {
|
|
|
24
24
|
import ScrollViewBasic from './ScrollViewBasic'
|
|
25
25
|
import ScrollViewWithBouncesHook from './ScrollViewWithBouncesHook'
|
|
26
26
|
import type {
|
|
27
|
+
BounceableBasicProps,
|
|
27
28
|
ScrollViewProps,
|
|
28
29
|
ScrollViewRef,
|
|
29
30
|
ScrollView as ScrollViewType,
|
|
30
31
|
} from './types'
|
|
31
32
|
|
|
32
33
|
export type { ScrollViewProps, ScrollViewRef }
|
|
34
|
+
export { useBounce } from './hooks/useBounce'
|
|
35
|
+
export type { bounceHandlers } from './hooks/useBounce'
|
|
36
|
+
export type { BounceableBasicProps } from './types'
|
|
33
37
|
|
|
34
38
|
export const ScrollView = memo(forwardRef(ScrollViewImpl)) as ScrollViewType
|
|
35
39
|
|
package/src/types/index.docs.ts
CHANGED
|
@@ -11,7 +11,6 @@ import type {
|
|
|
11
11
|
BaseUIExposureProps,
|
|
12
12
|
BaseUILayoutEvents,
|
|
13
13
|
BaseUITouchEvents,
|
|
14
|
-
BounceableBasicProps,
|
|
15
14
|
ComponentBasicProps,
|
|
16
15
|
LazyOptions,
|
|
17
16
|
} from '@lynx-js/lynx-ui-common'
|
|
@@ -271,6 +270,128 @@ export interface ScrollViewProps
|
|
|
271
270
|
}) => void
|
|
272
271
|
}
|
|
273
272
|
|
|
273
|
+
export interface scrollToBouncesInfo {
|
|
274
|
+
direction: 'upper' | 'lower'
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface BounceableBasicProps {
|
|
278
|
+
/**
|
|
279
|
+
* Whether to enable bounce effect
|
|
280
|
+
* @zh 是否开启回弹效果
|
|
281
|
+
* @iOS
|
|
282
|
+
* @Android
|
|
283
|
+
* @Harmony
|
|
284
|
+
*/
|
|
285
|
+
enableBounces: boolean
|
|
286
|
+
/**
|
|
287
|
+
* Trigger bounces effect during fling
|
|
288
|
+
* @zh 在快速滑动(fling)时触发回弹效果
|
|
289
|
+
* @defaultValue false
|
|
290
|
+
* @iOS
|
|
291
|
+
* @Android
|
|
292
|
+
* @Harmony
|
|
293
|
+
*/
|
|
294
|
+
enableBounceEventInFling?: boolean
|
|
295
|
+
/**
|
|
296
|
+
* The threshold distance of upper bounces, in pixels, when triggering the scrollToBounces event
|
|
297
|
+
* @zh 触发 `scrollToBounces` 事件时,上部回弹的阈值距离(单位:px)
|
|
298
|
+
* @defaultValue 0
|
|
299
|
+
* @iOS
|
|
300
|
+
* @Android
|
|
301
|
+
* @Harmony
|
|
302
|
+
*/
|
|
303
|
+
startBounceTriggerDistance?: number
|
|
304
|
+
/**
|
|
305
|
+
* The threshold distance of lower bounces, in pixels, when triggering the scrollToBounces event
|
|
306
|
+
* @zh 触发 `scrollToBounces` 事件时,下部回弹的阈值距离(单位:px)
|
|
307
|
+
* @defaultValue 0
|
|
308
|
+
* @iOS
|
|
309
|
+
* @Android
|
|
310
|
+
* @Harmony
|
|
311
|
+
*/
|
|
312
|
+
endBounceTriggerDistance?: number
|
|
313
|
+
/**
|
|
314
|
+
* Content of upper bounces view, which will be displayed during the upper bouncing effect.
|
|
315
|
+
* @zh 上部回弹视图的内容,将在上部回弹效果期间显示。
|
|
316
|
+
* @iOS
|
|
317
|
+
* @Android
|
|
318
|
+
* @Harmony
|
|
319
|
+
*/
|
|
320
|
+
// biome-ignore lint/suspicious/noExplicitAny: expected
|
|
321
|
+
upperBounceItem?: any
|
|
322
|
+
/**
|
|
323
|
+
* Content of lower bounces view, which will be displayed during the lower bouncing effect.
|
|
324
|
+
* @zh 下部回弹视图的内容,将在下部回弹效果期间显示。
|
|
325
|
+
* @iOS
|
|
326
|
+
* @Android
|
|
327
|
+
* @Harmony
|
|
328
|
+
*/
|
|
329
|
+
// biome-ignore lint/suspicious/noExplicitAny: expected
|
|
330
|
+
lowerBounceItem?: any
|
|
331
|
+
/**
|
|
332
|
+
* Whether the scrollable container can bounce when the content area of the scrollable container is smaller than the viewport area.
|
|
333
|
+
* @zh 当可滚动容器的内容区域小于视口区域时,是否允许容器回弹。
|
|
334
|
+
* @defaultValue true
|
|
335
|
+
* @iOS
|
|
336
|
+
* @Android
|
|
337
|
+
* @Harmony
|
|
338
|
+
*/
|
|
339
|
+
alwaysBouncing?: boolean
|
|
340
|
+
/**
|
|
341
|
+
* The direction of the bounce effect. 'both' for bouncing on both ends, 'none' to disable bounce, and 'upper'/'lower' for bouncing on either end
|
|
342
|
+
* @zh 回弹效果的方向。'both' 表示两端都回弹,'none' 表示禁用回弹,'upper'/'lower' 表示只在上端或下端回弹。
|
|
343
|
+
* @defaultValue 'both'
|
|
344
|
+
* @iOS
|
|
345
|
+
* @Android
|
|
346
|
+
* @Harmony
|
|
347
|
+
*/
|
|
348
|
+
singleSidedBounce?: 'upper' | 'lower' | 'both' | 'iOSBounces' | 'none'
|
|
349
|
+
/**
|
|
350
|
+
* Unit: px. Optional size hint for bounce effect. Recommended when used in List or <list/>.
|
|
351
|
+
* @zh 单位:px。可选的回弹效果尺寸提示。在列表或 `<list/>` 中使用时推荐设置。
|
|
352
|
+
* @Android
|
|
353
|
+
* @iOS
|
|
354
|
+
* @Harmony
|
|
355
|
+
*/
|
|
356
|
+
estimatedHeight?: number
|
|
357
|
+
/**
|
|
358
|
+
* Unit: px. Optional size hint for bounce effect. Recommended when used in List or <list/>.
|
|
359
|
+
* @zh 单位:px。可选的回弹效果尺寸提示。在列表或 `<list/>` 中使用时推荐设置。
|
|
360
|
+
* @Android
|
|
361
|
+
* @iOS
|
|
362
|
+
* @Harmony
|
|
363
|
+
*/
|
|
364
|
+
estimatedWidth?: number
|
|
365
|
+
/**
|
|
366
|
+
* Display debug logs. Open it when you find a bug.
|
|
367
|
+
* @zh 显示调试日志。当您发现错误时,请打开此选项。
|
|
368
|
+
* @defaultValue false
|
|
369
|
+
* @iOS
|
|
370
|
+
* @Android
|
|
371
|
+
* @Harmony
|
|
372
|
+
*/
|
|
373
|
+
debugLog?: boolean
|
|
374
|
+
/**
|
|
375
|
+
* requestAnimationFrame don't work under lynx version 2.15.2. This switch should be opened when the version is higher than 2.15.2.
|
|
376
|
+
* @zh `requestAnimationFrame` 在 lynx 2.15.2 以下版本中不起作用。当版本高于 2.15.2 时,应打开此开关。
|
|
377
|
+
* @defaultValue false
|
|
378
|
+
* @iOS
|
|
379
|
+
* @Android
|
|
380
|
+
* @Harmony
|
|
381
|
+
*/
|
|
382
|
+
validAnimationVersion?: boolean
|
|
383
|
+
/**
|
|
384
|
+
* 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.
|
|
385
|
+
* @zh 当触发回弹效果并且回弹距离在上侧或下侧大于 `startBounceDistance` 或 `endBounceDistance` 时,将触发 `scrollToBounces` 事件。
|
|
386
|
+
* @defaultValue 0
|
|
387
|
+
* @eventProperty
|
|
388
|
+
* @iOS
|
|
389
|
+
* @Android
|
|
390
|
+
* @Harmony
|
|
391
|
+
*/
|
|
392
|
+
onScrollToBounces?: (e: scrollToBouncesInfo) => void
|
|
393
|
+
}
|
|
394
|
+
|
|
274
395
|
export const ScrollEventMapping: Record<string, string> = {
|
|
275
396
|
onContentSizeChange: 'bindcontentsizechange',
|
|
276
397
|
}
|