@lynx-js/lynx-ui-scroll-view 3.137.0 → 3.140.1
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 +22 -0
- package/dist/hooks/useBounce.d.ts +6 -4
- package/dist/hooks/useBounce.d.ts.map +1 -1
- package/dist/hooks/useBounce.jsx +1 -1
- package/dist/hooks/useBounce.jsx.map +1 -1
- package/dist/hooks/useNativeBounce.jsx.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.jsx.map +1 -1
- package/dist/types/index.docs.d.ts +3 -4
- 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/hooks/useBounce.tsx +12 -9
- package/src/hooks/useNativeBounce.tsx +2 -2
- package/src/index.tsx +7 -4
- package/src/types/index.docs.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-scroll-view
|
|
2
2
|
|
|
3
|
+
## 3.140.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Keep implementation-only component signatures out of public documentation ([#355](https://github.com/lynx-family/lynx-ui/pull/355))
|
|
8
|
+
types.
|
|
9
|
+
|
|
10
|
+
- Add PascalCase names for public hook types and normalize supporting type names, ([#355](https://github.com/lynx-family/lynx-ui/pull/355))
|
|
11
|
+
retaining deprecated aliases for existing public names.
|
|
12
|
+
- Updated dependencies [[`20f5316`](https://github.com/lynx-family/lynx-ui/commit/20f531645f7c0e6766269d15129de93f53d9c8ea)]:
|
|
13
|
+
- @lynx-js/lynx-ui-lazy-component@3.140.1
|
|
14
|
+
|
|
15
|
+
## 3.139.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Correct generated API types for scroll callbacks and union-valued arrays. ([#273](https://github.com/lynx-family/lynx-ui/pull/273))
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [[`1a4ad19`](https://github.com/lynx-family/lynx-ui/commit/1a4ad190993d57425b4c377a7dd63882cc65a8d2)]:
|
|
22
|
+
- @lynx-js/lynx-ui-common@3.139.0
|
|
23
|
+
- @lynx-js/lynx-ui-lazy-component@3.139.0
|
|
24
|
+
|
|
3
25
|
## 3.137.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CommonEvent, MainThread, ScrollEvent } from '@lynx-js/types';
|
|
2
|
-
export interface
|
|
2
|
+
export interface ScrollToBouncesInfo {
|
|
3
3
|
direction: 'upper' | 'lower';
|
|
4
4
|
}
|
|
5
5
|
export interface BounceableBasicProps {
|
|
@@ -14,7 +14,7 @@ export interface BounceableBasicProps {
|
|
|
14
14
|
estimatedHeight?: number;
|
|
15
15
|
estimatedWidth?: number;
|
|
16
16
|
validAnimationVersion?: boolean;
|
|
17
|
-
onScrollToBounces?: (e:
|
|
17
|
+
onScrollToBounces?: (e: ScrollToBouncesInfo) => void;
|
|
18
18
|
}
|
|
19
19
|
export interface useBounceOptions {
|
|
20
20
|
bounceableOptions: BounceableBasicProps;
|
|
@@ -29,7 +29,7 @@ export interface useBounceOptions {
|
|
|
29
29
|
*/
|
|
30
30
|
scrollOrientation: 'vertical' | 'horizontal';
|
|
31
31
|
}
|
|
32
|
-
export interface
|
|
32
|
+
export interface BounceHandlers {
|
|
33
33
|
'main-thread:bindtouchstart': (event: MainThread.TouchEvent) => void;
|
|
34
34
|
'main-thread:bindtouchend': () => void;
|
|
35
35
|
'main-thread:bindtouchmove': (event: MainThread.TouchEvent) => void;
|
|
@@ -40,5 +40,7 @@ export interface bounceHandlers {
|
|
|
40
40
|
onLowerExposure: (_event: CommonEvent) => void;
|
|
41
41
|
onLowerDisexposure: (_event: CommonEvent) => void;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
/** @deprecated Use `BounceHandlers` instead. */
|
|
44
|
+
export type bounceHandlers = BounceHandlers;
|
|
45
|
+
export declare function useBounce(options: useBounceOptions): BounceHandlers;
|
|
44
46
|
//# sourceMappingURL=useBounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBounce.d.ts","sourceRoot":"","sources":["../../src/hooks/useBounce.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE1E,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAA;CAC7B;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,OAAO,CAAA;IACtB,wBAAwB,CAAC,EAAE,OAAO,CAAA;IAClC,0BAA0B,CAAC,EAAE,MAAM,CAAA;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAA;IAEjC,eAAe,CAAC,EAAE,GAAG,CAAA;IAErB,eAAe,CAAC,EAAE,GAAG,CAAA;IACrB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,iBAAiB,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,CAAA;IACtE,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACrD;AAED,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,EAAE,oBAAoB,CAAA;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,iBAAiB,EAAE,UAAU,GAAG,YAAY,CAAA;CAC7C;AAED,MAAM,WAAW,cAAc;IAC7B,4BAA4B,EAA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}
|
|
104
104
|
function bouncingSetStyle(offset) {
|
|
105
105
|
'main thread';
|
|
106
|
-
if (isNaN(Number(offset))) return void mtsLog(true, '[lynx-ui-scroll-view][useBounce] ERROR! bouncingOffset is NaN');
|
|
106
|
+
if (Number.isNaN(Number(offset))) return void mtsLog(true, '[lynx-ui-scroll-view][useBounce] ERROR! bouncingOffset is NaN');
|
|
107
107
|
if (isEmpty(bouncingPositionInfo.current)) bouncingPositionInfo.current.velocity = 0;
|
|
108
108
|
else {
|
|
109
109
|
const timeDiff = Date.now() - bouncingPositionInfo.current.timeStamp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useBounce.jsx","sources":["../../src/hooks/useBounce.tsx"],"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 { runOnBackground, useMainThreadRef } from '@lynx-js/react'\n\nimport { log, mtsLog, selectorMT } from '@lynx-js/lynx-ui-common'\nimport type { CommonEvent, MainThread, ScrollEvent } from '@lynx-js/types'\n\nexport interface scrollToBouncesInfo {\n direction: 'upper' | 'lower'\n}\n\nexport interface BounceableBasicProps {\n enableBounces: boolean\n enableBounceEventInFling?: boolean\n startBounceTriggerDistance?: number\n endBounceTriggerDistance?: number\n // biome-ignore lint/suspicious/noExplicitAny: expected\n upperBounceItem?: any\n // biome-ignore lint/suspicious/noExplicitAny: expected\n lowerBounceItem?: any\n alwaysBouncing?: boolean\n singleSidedBounce?: 'upper' | 'lower' | 'both' | 'iOSBounces' | 'none'\n estimatedHeight?: number\n estimatedWidth?: number\n validAnimationVersion?: boolean\n onScrollToBounces?: (e: scrollToBouncesInfo) => void\n}\n\nexport interface useBounceOptions {\n bounceableOptions: BounceableBasicProps\n debugLog?: boolean\n enableRTL?: boolean\n /**\n * idSelector of scroll container\n */\n id?: string\n /**\n * scroll direction\n */\n scrollOrientation: 'vertical' | 'horizontal'\n}\n\nexport interface bounceHandlers {\n 'main-thread:bindtouchstart': (event: MainThread.TouchEvent) => void\n 'main-thread:bindtouchend': () => void\n 'main-thread:bindtouchmove': (event: MainThread.TouchEvent) => void\n 'main-thread:bindlayoutchange': (event: CommonEvent) => void\n 'main-thread:bindscroll': (event: ScrollEvent) => void\n onUpperExposure: (_event: CommonEvent) => void\n onUpperDisexposure: (_event: CommonEvent) => void\n onLowerExposure: (_event: CommonEvent) => void\n onLowerDisexposure: (_event: CommonEvent) => void\n}\n\nexport function useBounce(options: useBounceOptions): bounceHandlers {\n // Control the damping coefficient during rubber effect. The smaller it is, the harder the spring effect.\n const rubberC = useMainThreadRef(0.55)\n // Control the fling deceleration coefficient during dropdown. The smaller it is, the faster it stops.\n const flingDeceleratingRate = useMainThreadRef(0.99)\n // The rebound coefficient during bounce back, the larger it is, the faster the rebound speed.\n const beta = useMainThreadRef(15)\n\n const debugLogEnabled = Boolean(options.debugLog)\n\n const singleSidedBounce = useMainThreadRef(\n options.bounceableOptions.singleSidedBounce ?? 'both',\n )\n\n // The starting point of current touch procedure\n const startTouch = useMainThreadRef<MainThread.TouchEvent['touches'] | null>(\n null,\n )\n // Record the previous touch and clear it on touchEnd. If current is not empty, then it means that the scrollable object is being dragged.\n const prevTouch = useMainThreadRef<MainThread.TouchEvent['touches'] | null>(\n null,\n )\n\n // Current scroll velocity.\n const scrollVelocity = useMainThreadRef(0)\n // Current bouncing position.\n const bouncingPositionInfo = useMainThreadRef({})\n\n // If reaches edge and bouncing starts during dragging, save the touch point and calculate later touch delta for rubberEffect.\n const startBouncingTouch = useMainThreadRef<\n MainThread.TouchEvent['touches'] | null\n >(null)\n // If reaches edge and bouncing starts during dragging, save current bouncingPosition and continues rubberEffect's calculation from this point.\n const startTouchBouncingDelta = useMainThreadRef({})\n // when touch starts during bouncing, save current bouncingPosition and continues rubberEffect's calculation from this point.\n const bouncingTouchStartPosition = useMainThreadRef({})\n\n // Used to record the previous scroll position and calculate current scroll velocity.\n const prevScroll = useMainThreadRef({})\n\n // scroll container's basic info.\n const height = useMainThreadRef(\n options.bounceableOptions.estimatedHeight\n ?? SystemInfo.pixelHeight / SystemInfo.pixelRatio,\n )\n const width = useMainThreadRef(\n options.bounceableOptions.estimatedWidth\n ?? SystemInfo.pixelWidth / SystemInfo.pixelRatio,\n )\n const scrollX = useMainThreadRef(0)\n const scrollY = useMainThreadRef(0)\n\n // Flags for ending bouncing animation.\n const touchEndFrameEnableFlag = useMainThreadRef(false)\n const touchingEndBouncingBackEnableFlag = useMainThreadRef(false)\n const flingEndWithBouncingEnableFlag = useMainThreadRef(false)\n\n // Flags for reaches upper/lower edge.\n // When content's size is smaller than viewport, these two flags are both true.\n const toUpper = useMainThreadRef(false)\n const toLower = useMainThreadRef(false)\n\n // Read from props\n const containerID = options.id ?? 'bounceableContainer'\n const { enableBounces, onScrollToBounces } = options.bounceableOptions\n const alwaysBouncing = options.bounceableOptions.alwaysBouncing ?? false\n const scrollOrientation = options.scrollOrientation ?? 'vertical'\n const enableRTL = useMainThreadRef(options.enableRTL ?? false)\n const enableBounceEventInFling =\n options.bounceableOptions.enableBounceEventInFling ?? true\n const startBounceTriggerDistance =\n options.bounceableOptions.startBounceTriggerDistance ?? 0\n const endBounceTriggerDistance =\n options.bounceableOptions.endBounceTriggerDistance ?? 0\n // Temporary workaround as requestAnimationFrame will crash below Lynx 2.15.2.\n const temporaryValidVersionCheckForRAF = useMainThreadRef(\n options.bounceableOptions.validAnimationVersion ?? false,\n )\n log(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] init, enableBounces: ${enableBounces}, orientation: ${scrollOrientation}, enableRTL: ${\n options.enableRTL ?? false\n }`,\n )\n\n const bouncingStatus = {\n inScrollingRange: 0,\n upperBouncing: 1,\n lowerBouncing: 2,\n noBouncing: 3,\n alwaysBouncing: 4,\n }\n\n function isVertical() {\n 'main thread'\n return scrollOrientation === 'vertical'\n }\n\n function threshold() {\n 'main thread'\n return 1.0 / Number(SystemInfo.pixelRatio)\n }\n\n function normalizedHorizontalValue(value: number) {\n 'main thread'\n return enableRTL.current ? -value : value\n }\n\n function isAndroid() {\n 'main thread'\n return SystemInfo.platform === 'Android'\n }\n\n function isEmpty(obj: Record<string, unknown>) {\n 'main thread'\n return !obj || Object.keys(obj).length === 0\n }\n\n function enableScroll(enable: boolean) {\n 'main thread'\n // Android will trigger scroll during bouncing, cancel it while bouncing.\n if (isAndroid()) {\n selectorMT(containerID)?.setAttribute('enable-scroll', enable)\n }\n }\n\n // Clear all temps when a touch procedure ends.\n function clearTouchInfo() {\n 'main thread'\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] clear touch info')\n startTouch.current = null\n bouncingTouchStartPosition.current = 0\n prevTouch.current = null\n startBouncingTouch.current = null\n startTouchBouncingDelta.current = 0\n }\n\n // Temporary workaround as requestAnimationFrame will crash below Lynx 2.15.2.\n function customRequestAnimationFrame(animationFunc: () => void) {\n 'main thread'\n if (temporaryValidVersionCheckForRAF.current) {\n requestAnimationFrame(animationFunc)\n } else {\n setTimeout(animationFunc, 8)\n }\n }\n\n // Calculate current touch delta based on 'startPoint'. The startPoint here should be startBouncingTouch which means this bouncing effect happens during a touch procedure.\n function getCurrentDelta(event: MainThread.TouchEvent) {\n 'main thread'\n if (startTouch.current !== null) {\n if (startBouncingTouch.current === null) {\n return scrollOrientation === 'vertical'\n ? event.touches[0].pageY - startTouch.current[0].pageY\n : normalizedHorizontalValue(\n event.touches[0].pageX - startTouch.current[0].pageX,\n )\n } else {\n return scrollOrientation === 'vertical'\n ? event.touches[0].pageY - startBouncingTouch.current[0].pageY\n : normalizedHorizontalValue(\n event.touches[0].pageX - startBouncingTouch.current[0].pageX,\n )\n }\n }\n return 0\n }\n\n // Key bouncing status judgement.\n function getBouncingStatus() {\n 'main thread'\n // @ts-expect-error Expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const currentPosition = bouncingPositionInfo.current?.bouncingOffset ?? 0\n if (Boolean(toUpper.current) && Boolean(toLower.current)) {\n return alwaysBouncing\n ? bouncingStatus.alwaysBouncing\n : bouncingStatus.noBouncing\n }\n\n // upper bouncing\n const initialLayoutPosition = 0\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] get bouncing status, initialLayoutPosition: ${initialLayoutPosition}, currentPosition: ${currentPosition}`,\n )\n\n if (currentPosition > initialLayoutPosition) {\n return bouncingStatus.upperBouncing\n }\n\n // bottom bouncing\n if (currentPosition < initialLayoutPosition) {\n return bouncingStatus.lowerBouncing\n }\n return bouncingStatus.inScrollingRange\n }\n\n // Whether fling and bouncing back step should be triggered.\n function shouldBounceWhenTouchEnd(status: number) {\n 'main thread'\n if (\n status === bouncingStatus.inScrollingRange\n || status === bouncingStatus.noBouncing\n ) {\n return false\n }\n\n if (\n status === bouncingStatus.upperBouncing\n || status === bouncingStatus.lowerBouncing\n ) {\n return true\n }\n\n if (status === bouncingStatus.alwaysBouncing) {\n return alwaysBouncing\n }\n return false\n }\n\n // Use translate to implement real bouncing effect\n function bouncingSetStyle(offset: number) {\n 'main thread'\n if (isNaN(Number(offset))) {\n mtsLog(\n true,\n '[lynx-ui-scroll-view][useBounce] ERROR! bouncingOffset is NaN',\n )\n return\n }\n // update bouncingPositionInfo first\n if (isEmpty(bouncingPositionInfo.current)) {\n // @ts-expect-error expected\n bouncingPositionInfo.current.velocity = 0\n } else {\n // @ts-expect-error expected\n const timeDiff = Date.now() - bouncingPositionInfo.current.timeStamp\n // @ts-expect-error expected\n const offsetDiff = offset - bouncingPositionInfo.current.bouncingOffset\n || 0\n if (timeDiff > 0) {\n // @ts-expect-error expected\n bouncingPositionInfo.current.velocity = offsetDiff / timeDiff\n }\n // If timeDiff <= 0, we keep the previous velocity to maintain momentum continuity.\n }\n // @ts-expect-error expected\n bouncingPositionInfo.current.bouncingOffset = offset\n // @ts-expect-error expected\n bouncingPositionInfo.current.timeStamp = Date.now()\n // When bouncing effect ends, clear startTouch and bouncingTouchStartPosition\n if (offset === 0 && prevTouch.current !== null) {\n startTouch.current = prevTouch.current\n bouncingTouchStartPosition.current = {}\n }\n // trigger translate\n if (isVertical()) {\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] apply transform, orientation: vertical, rawOffset: ${offset}, containerTransform: translateY(${offset}px)`,\n )\n selectorMT(containerID)?.setStyleProperty(\n 'transform',\n `translateY(${offset}px)`,\n )\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${offset}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${offset}px)`,\n )\n } else {\n const visualOffset = enableRTL.current ? -offset : offset\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] apply transform, orientation: horizontal, rawOffset: ${offset}, enableRTL: ${\n String(enableRTL.current)\n }, visualOffset: ${visualOffset}, containerTransform: translateX(${visualOffset}px)`,\n )\n selectorMT(containerID)?.setStyleProperty(\n 'transform',\n `translateX(${visualOffset}px)`,\n )\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${visualOffset}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${visualOffset}px)`,\n )\n }\n }\n\n function onScrollToBouncesJS(info: scrollToBouncesInfo) {\n if (enableBounces && onScrollToBounces) {\n onScrollToBounces(info)\n }\n }\n\n // send the scrollToBounces event\n function triggerScrollToBouncesEvent(isUpper: boolean) {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] trigger scrollToBounces, direction: ${\n isUpper ? 'upper' : 'lower'\n }`,\n )\n\n const info: scrollToBouncesInfo = {\n direction: isUpper ? 'upper' : 'lower',\n }\n runOnBackground(onScrollToBouncesJS)(info)\n }\n\n function rubberEffect(isNegative: 1 | -1, delta: number) {\n 'main thread'\n const scrollViewFrameSize = isVertical() ? height.current : width.current\n // If the touchStartPosition is not zero, it means this rubber effect happens during a touch or another bouncing effect. So the real 'start delta' should be recalculated.\n const touchStartPosition = Math.abs(\n Number(\n isEmpty(startTouchBouncingDelta.current)\n ? bouncingTouchStartPosition.current\n : startTouchBouncingDelta.current,\n ),\n )\n // This deltaYForTouchStartPosition is the inverse function of rubberEffect function\n const deltaYForTouchStartPosition =\n (scrollViewFrameSize * touchStartPosition)\n / ((scrollViewFrameSize - touchStartPosition) * rubberC.current) || 0\n // Here it calculate the next touchDelta. deltaYForNextPosition = (touch point where bouncing happens + corresponding touch delta where previous bouncing position locates)\n // This isNegative is used to handle the upper/lower bounce. RubberEffect function is different in the range (-inf,0) and [0, inf). We only use the [0, inf) part.\n const deltaYForNextPosition = bouncingTouchStartPosition.current\n ? deltaYForTouchStartPosition + isNegative * delta\n : isNegative * delta\n // Real calculation. Note that we don't use the raw touchDelta for calculating, instead, we use deltaYForNextPosition.\n const rubberBandingDistance = Math.max(\n 0,\n (1.0\n - 1.0\n / ((deltaYForNextPosition * rubberC.current) / scrollViewFrameSize\n + 1.0))\n * scrollViewFrameSize,\n )\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] rubber effect, scrollViewFrameSize: ${scrollViewFrameSize}, touchStartPosition: ${touchStartPosition}, deltaYForTouchStartPosition: ${deltaYForTouchStartPosition}, deltaYForNextPosition: ${deltaYForNextPosition}, rubberBandingDistance: ${rubberBandingDistance}`,\n )\n\n bouncingSetStyle(isNegative * rubberBandingDistance)\n }\n\n function triggerRubberEffectIfCrossingEdge(event: MainThread.TouchEvent) {\n 'main thread'\n const delta = getCurrentDelta(event)\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] check crossing edge, delta: ${delta}, toUpper: ${\n String(toUpper.current)\n }, toLower: ${String(toLower.current)}`,\n )\n\n // Crossing top range\n if (\n toUpper.current === true && delta > 0\n && (singleSidedBounce.current === 'both'\n || singleSidedBounce.current === 'upper')\n ) {\n enableScroll(false)\n rubberEffect(delta > 0 ? 1 : -1, delta)\n }\n\n // Crossing bottom range\n if (\n toLower.current === true && delta < 0\n && (singleSidedBounce.current === 'both'\n || singleSidedBounce.current === 'lower')\n ) {\n enableScroll(false)\n rubberEffect(delta > 0 ? 1 : -1, delta)\n }\n enableScroll(true)\n }\n\n // return true if scrollToBounces should be sent\n function isOverTriggerDistance() {\n 'main thread'\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const bouncingTop: number = bouncingPositionInfo.current.bouncingOffset ?? 0\n const triggerDistance =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0\n ? startBounceTriggerDistance\n : endBounceTriggerDistance\n const delta = Math.abs(bouncingTop) - Math.abs(triggerDistance)\n return delta > threshold()\n }\n\n function bouncingBack() {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling forward end',\n )\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bounce back starts',\n )\n\n // step3: bounce back\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const C1 = bouncingPositionInfo.current.bouncingOffset ?? 0\n const startTime = Date.now()\n const touchingEndBouncingBackFrame = () => {\n if (Boolean(touchingEndBouncingBackEnableFlag.current) === false) {\n return\n }\n const currentTime = Date.now() - startTime\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touching end bouncing back frame',\n )\n\n // critical damping\n const C2 = beta.current * C1\n const easedDistance = (C1 + C2 * (currentTime / 1000))\n * Math.pow(Math.E, -beta.current * (currentTime / 1000))\n bouncingSetStyle(easedDistance)\n if (Math.abs(easedDistance) < threshold()) {\n // Make sure it backs to 0\n bouncingSetStyle(0)\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bounce back ends',\n )\n } else {\n customRequestAnimationFrame(touchingEndBouncingBackFrame)\n }\n }\n\n customRequestAnimationFrame(touchingEndBouncingBackFrame)\n touchingEndBouncingBackEnableFlag.current = true\n }\n\n // bindtouchstart. Save startTouch and bouncingPosition if a bouncing effect is happening.\n function bounceableTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n startTouch.current = event.touches\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] touch start')\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bouncingTouchStartPosition.current =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset ?? 0\n // reset all animation flags. No animation should play during a touch.\n touchEndFrameEnableFlag.current = false\n touchingEndBouncingBackEnableFlag.current = false\n flingEndWithBouncingEnableFlag.current = false\n }\n\n function bounceableTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n prevTouch.current = event.touches\n if (startTouch.current === null) {\n // It means current situation is illegal. A touchMove event happens without a touchStart event beforehand. Or a touchMove event happens after a touchEnd event.\n mtsLog(true, '[lynx-ui-scroll-view][useBounce] ERROR! touch not started')\n } else {\n const delta = getCurrentDelta(event)\n const currentBouncingStatus = getBouncingStatus()\n // Judge the status and trigger rubberEffect. The TouchMove should only consider rubberEffect and nothing else.\n switch (currentBouncingStatus) {\n case bouncingStatus.upperBouncing: {\n enableScroll(false)\n rubberEffect(1, delta)\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move upper bouncing',\n )\n break\n }\n case bouncingStatus.lowerBouncing: {\n enableScroll(false)\n rubberEffect(-1, delta)\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move lower bouncing',\n )\n break\n }\n case bouncingStatus.alwaysBouncing: {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move always bouncing',\n )\n if (alwaysBouncing) {\n triggerRubberEffectIfCrossingEdge(event)\n }\n break\n }\n case bouncingStatus.inScrollingRange: {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move in scrolling range',\n )\n triggerRubberEffectIfCrossingEdge(event)\n break\n }\n default:\n break\n }\n }\n }\n\n // bindtouchend. In touchEnd event the fling forward animation and bouncingBack animation should be triggered if necessary.\n function bounceableTouchEnd() {\n 'main thread'\n // Reset the state. The touch information should be reset, and we should no longer ban the enable-scroll.\n clearTouchInfo()\n enableScroll(true)\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] touch end')\n if (shouldBounceWhenTouchEnd(getBouncingStatus())) {\n const startTime = Date.now()\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const dragEndVelocity = bouncingPositionInfo.current?.velocity\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const dragEndPosition = bouncingPositionInfo.current?.bouncingOffset ?? 0\n // Send scrolltobounces event.\n if (isOverTriggerDistance()) {\n triggerScrollToBouncesEvent(\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0,\n )\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let currentVelocity: number = dragEndVelocity\n const touchEndProcessFrame = () => {\n if (Boolean(touchEndFrameEnableFlag.current) === false) {\n return\n }\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch end process frame',\n )\n if (Math.abs(currentVelocity) <= threshold()) {\n // If the velocity is already under threshold, skip fling and start step3: bounce back.\n bouncingBack()\n } else {\n // If the drag end with a velocity, start fling to consume it.\n // step 2: fling down\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling down start',\n )\n // This function is obtained by integrating the velocity function with a deceleration rate of flingDeceleratingRate.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const distance: number = dragEndPosition\n + (dragEndVelocity\n * (Math.pow(\n flingDeceleratingRate.current,\n Date.now() - startTime,\n )\n - 1))\n / Math.log(flingDeceleratingRate.current)\n bouncingSetStyle(distance)\n currentVelocity = dragEndVelocity\n * Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n if (touchEndFrameEnableFlag.current) {\n customRequestAnimationFrame(touchEndProcessFrame)\n }\n }\n }\n customRequestAnimationFrame(touchEndProcessFrame)\n touchEndFrameEnableFlag.current = true\n }\n }\n\n // Save the bindscroll info and calculate velocity.\n function bounceableHandleScroll(event: ScrollEvent) {\n 'main thread'\n scrollX.current = event.detail.scrollLeft\n scrollY.current = event.detail.scrollTop\n if (!isEmpty(prevScroll.current)) {\n const prev = prevScroll.current as {\n timestamp: number\n detail: { scrollTop: number, scrollLeft: number }\n }\n const timeDuration = Date.now() - prev.timestamp\n if (timeDuration > 0) {\n const deltaY = isVertical()\n ? event.detail.scrollTop - prev.detail.scrollTop\n : normalizedHorizontalValue(\n event.detail.scrollLeft - prev.detail.scrollLeft,\n )\n const velocity = deltaY / timeDuration\n if (Number.isFinite(velocity)) {\n scrollVelocity.current = velocity\n }\n }\n }\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] handle scroll near edge, scrollLeft: ${event.detail.scrollLeft}, scrollTop: ${event.detail.scrollTop}, velocity: ${scrollVelocity.current}`,\n )\n prevScroll.current = event\n }\n\n function onUpperDisexposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] upper disexposure',\n )\n toUpper.current = false\n }\n\n // Handle scrolltoupper event.\n function onUpperExposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] upper exposure')\n toUpper.current = true\n if (\n singleSidedBounce.current !== 'upper'\n && singleSidedBounce.current !== 'both'\n ) {\n return\n }\n if (prevScroll.current) {\n // reaches edge during touch\n startBouncingTouch.current = prevTouch.current\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n startTouchBouncingDelta.current =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset ?? 0\n } else if (Math.abs(scrollVelocity.current) > threshold()) {\n // reaches edge during fling\n const velocity = scrollVelocity.current\n let currentVelocity = velocity\n const startTime = Date.now()\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] fling to upper event start, velocity: ${velocity}`,\n )\n let sentScrollToBouncesEvent = false // only sent scrollToBounces once\n const flingEndWithBouncingFrame = () => {\n if (Boolean(flingEndWithBouncingEnableFlag.current) === false) {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] flingEndWithBouncingEnableFlag early return',\n )\n return\n }\n if (Math.abs(currentVelocity) <= threshold()) {\n flingEndWithBouncingEnableFlag.current = false\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling to upper event end',\n )\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bouncing to upper event start',\n )\n bouncingBack()\n } else {\n // step 1: fling\n const distance = (currentVelocity\n * (Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n - 1))\n / Math.log(flingDeceleratingRate.current)\n bouncingSetStyle(-distance)\n if (!sentScrollToBouncesEvent && isOverTriggerDistance()) {\n triggerScrollToBouncesEvent(\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0,\n )\n sentScrollToBouncesEvent = true\n }\n currentVelocity = velocity\n * Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n if (flingEndWithBouncingEnableFlag.current) {\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n }\n }\n }\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n flingEndWithBouncingEnableFlag.current = true\n }\n }\n\n function onLowerDisexposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] lower disexposure',\n )\n toLower.current = false\n }\n\n function onLowerExposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] lower exposure')\n toLower.current = true\n if (\n singleSidedBounce.current !== 'lower'\n && singleSidedBounce.current !== 'both'\n ) {\n return\n }\n // reaches lower during dragging\n if (prevTouch.current !== null) {\n startBouncingTouch.current = prevTouch.current\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n startTouchBouncingDelta.current =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset ?? 0\n } else if (enableBounceEventInFling && scrollVelocity.current > 0) {\n const velocity = scrollVelocity.current\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] lower velocity: ${velocity}`,\n )\n\n // scroll to end with velocity, start bouncing effect\n if (Math.abs(velocity) > threshold()) {\n let currentVelocity = velocity\n const startTime = Date.now()\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] fling to lower event start, velocity: ${velocity}`,\n )\n let sentScrollToBouncesEvent = false // only sent scrollToBounces once\n const flingEndWithBouncingFrame = () => {\n if (Boolean(flingEndWithBouncingEnableFlag.current) === false) {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] flingEndWithBouncingEnableFlag early return',\n )\n return\n }\n if (Math.abs(currentVelocity) <= threshold()) {\n flingEndWithBouncingEnableFlag.current = false\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling to lower event end',\n )\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bouncing to lower event start',\n )\n bouncingBack()\n } else {\n // step 1: fling\n const distance = (currentVelocity\n * (Math.pow(\n flingDeceleratingRate.current,\n Date.now() - startTime,\n )\n - 1))\n / Math.log(flingDeceleratingRate.current)\n bouncingSetStyle(-distance)\n if (!sentScrollToBouncesEvent && isOverTriggerDistance()) {\n triggerScrollToBouncesEvent(\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0,\n )\n sentScrollToBouncesEvent = true\n }\n currentVelocity = velocity\n * Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n if (flingEndWithBouncingEnableFlag) {\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n }\n }\n }\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n flingEndWithBouncingEnableFlag.current = true\n }\n }\n }\n\n // Used to get the size of scroll container.\n function bounceableLayoutChange(event: CommonEvent) {\n 'main thread'\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n height.current = (isAndroid() ? event.params?.height : event.detail?.height)\n ?? 0\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n width.current = (isAndroid() ? event.params?.width : event.detail?.width)\n ?? 0\n }\n\n return {\n 'main-thread:bindtouchstart': bounceableTouchStart,\n 'main-thread:bindtouchend': bounceableTouchEnd,\n 'main-thread:bindtouchmove': bounceableTouchMove,\n 'main-thread:bindlayoutchange': bounceableLayoutChange,\n 'main-thread:bindscroll': bounceableHandleScroll,\n onUpperExposure,\n onUpperDisexposure,\n onLowerExposure,\n onLowerDisexposure,\n }\n}\n"],"names":["useBounce","options","rubberC","useMainThreadRef","flingDeceleratingRate","beta","debugLogEnabled","Boolean","singleSidedBounce","startTouch","prevTouch","scrollVelocity","bouncingPositionInfo","startBouncingTouch","startTouchBouncingDelta","bouncingTouchStartPosition","prevScroll","height","SystemInfo","width","scrollX","scrollY","touchEndFrameEnableFlag","touchingEndBouncingBackEnableFlag","flingEndWithBouncingEnableFlag","toUpper","toLower","containerID","enableBounces","onScrollToBounces","alwaysBouncing","scrollOrientation","enableRTL","enableBounceEventInFling","startBounceTriggerDistance","endBounceTriggerDistance","temporaryValidVersionCheckForRAF","log","bouncingStatus","isVertical","threshold","Number","normalizedHorizontalValue","value","isAndroid","isEmpty","obj","Object","enableScroll","enable","selectorMT","clearTouchInfo","mtsLog","customRequestAnimationFrame","animationFunc","requestAnimationFrame","setTimeout","getCurrentDelta","event","getBouncingStatus","currentPosition","initialLayoutPosition","shouldBounceWhenTouchEnd","status","bouncingSetStyle","offset","isNaN","timeDiff","Date","offsetDiff","visualOffset","String","onScrollToBouncesJS","info","triggerScrollToBouncesEvent","isUpper","runOnBackground","rubberEffect","isNegative","delta","scrollViewFrameSize","touchStartPosition","Math","deltaYForTouchStartPosition","deltaYForNextPosition","rubberBandingDistance","triggerRubberEffectIfCrossingEdge","isOverTriggerDistance","bouncingTop","triggerDistance","bouncingBack","C1","startTime","touchingEndBouncingBackFrame","currentTime","C2","easedDistance","bounceableTouchStart","bounceableTouchMove","currentBouncingStatus","bounceableTouchEnd","dragEndVelocity","dragEndPosition","currentVelocity","touchEndProcessFrame","distance","bounceableHandleScroll","prev","timeDuration","deltaY","velocity","onUpperDisexposure","_event","onUpperExposure","sentScrollToBouncesEvent","flingEndWithBouncingFrame","onLowerDisexposure","onLowerExposure","bounceableLayoutChange"],"mappings":";;AAwDO,SAASA,UAAUC,OAAyB;IAEjD,MAAMC,UAAUC,iBAAiB;IAEjC,MAAMC,wBAAwBD,iBAAiB;IAE/C,MAAME,OAAOF,iBAAiB;IAE9B,MAAMG,kBAAkBC,QAAQN,QAAQ,QAAQ;IAEhD,MAAMO,oBAAoBL,iBACxBF,QAAQ,iBAAiB,CAAC,iBAAiB,IAAI;IAIjD,MAAMQ,aAAaN,iBACjB;IAGF,MAAMO,YAAYP,iBAChB;IAIF,MAAMQ,iBAAiBR,iBAAiB;IAExC,MAAMS,uBAAuBT,iBAAiB,CAAC;IAG/C,MAAMU,qBAAqBV,iBAEzB;IAEF,MAAMW,0BAA0BX,iBAAiB,CAAC;IAElD,MAAMY,6BAA6BZ,iBAAiB,CAAC;IAGrD,MAAMa,aAAab,iBAAiB,CAAC;IAGrC,MAAMc,SAASd,iBACbF,QAAQ,iBAAiB,CAAC,eAAe,IACpCiB,WAAW,WAAW,GAAGA,WAAW,UAAU;IAErD,MAAMC,QAAQhB,iBACZF,QAAQ,iBAAiB,CAAC,cAAc,IACnCiB,WAAW,UAAU,GAAGA,WAAW,UAAU;IAEpD,MAAME,UAAUjB,iBAAiB;IACjC,MAAMkB,UAAUlB,iBAAiB;IAGjC,MAAMmB,0BAA0BnB,iBAAiB;IACjD,MAAMoB,oCAAoCpB,iBAAiB;IAC3D,MAAM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AAuB5D,KAAkB;QAChD;QAGAzC,OAAO,OAAO,GAAI2B,AAAAA,CAAAA,cAAcc,MAAM,MAAM,EAAE,SAASA,MAAM,MAAM,EAAE,MAAK,KACrE;QAGLvC,MAAM,OAAO,GAAIyB,AAAAA,CAAAA,cAAcc,MAAM,MAAM,EAAE,QAAQA,MAAM,MAAM,EAAE,KAAI,KAClE;IACP;IAEA,OAAO;QACL,8BAA8BuC;QAC9B,4BAA4BG;QAC5B,6BAA6BF;QAC7B,gCAAgCoB;QAChC,0BAA0BZ;QAC1BO;QACAF;QACAM;QACAD;IACF;AACF"}
|
|
1
|
+
{"version":3,"file":"hooks/useBounce.jsx","sources":["../../src/hooks/useBounce.tsx"],"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 { runOnBackground, useMainThreadRef } from '@lynx-js/react'\n\nimport { log, mtsLog, selectorMT } from '@lynx-js/lynx-ui-common'\nimport type { CommonEvent, MainThread, ScrollEvent } from '@lynx-js/types'\n\nexport interface ScrollToBouncesInfo {\n direction: 'upper' | 'lower'\n}\n\nexport interface BounceableBasicProps {\n enableBounces: boolean\n enableBounceEventInFling?: boolean\n startBounceTriggerDistance?: number\n endBounceTriggerDistance?: number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic callback\n upperBounceItem?: any\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic callback\n lowerBounceItem?: any\n alwaysBouncing?: boolean\n singleSidedBounce?: 'upper' | 'lower' | 'both' | 'iOSBounces' | 'none'\n estimatedHeight?: number\n estimatedWidth?: number\n validAnimationVersion?: boolean\n onScrollToBounces?: (e: ScrollToBouncesInfo) => void\n}\n\nexport interface useBounceOptions {\n bounceableOptions: BounceableBasicProps\n debugLog?: boolean\n enableRTL?: boolean\n /**\n * idSelector of scroll container\n */\n id?: string\n /**\n * scroll direction\n */\n scrollOrientation: 'vertical' | 'horizontal'\n}\n\nexport interface BounceHandlers {\n 'main-thread:bindtouchstart': (event: MainThread.TouchEvent) => void\n 'main-thread:bindtouchend': () => void\n 'main-thread:bindtouchmove': (event: MainThread.TouchEvent) => void\n 'main-thread:bindlayoutchange': (event: CommonEvent) => void\n 'main-thread:bindscroll': (event: ScrollEvent) => void\n onUpperExposure: (_event: CommonEvent) => void\n onUpperDisexposure: (_event: CommonEvent) => void\n onLowerExposure: (_event: CommonEvent) => void\n onLowerDisexposure: (_event: CommonEvent) => void\n}\n\n/** @deprecated Use `BounceHandlers` instead. */\nexport type bounceHandlers = BounceHandlers\n\nexport function useBounce(options: useBounceOptions): BounceHandlers {\n // Control the damping coefficient during rubber effect. The smaller it is, the harder the spring effect.\n const rubberC = useMainThreadRef(0.55)\n // Control the fling deceleration coefficient during dropdown. The smaller it is, the faster it stops.\n const flingDeceleratingRate = useMainThreadRef(0.99)\n // The rebound coefficient during bounce back, the larger it is, the faster the rebound speed.\n const beta = useMainThreadRef(15)\n\n const debugLogEnabled = Boolean(options.debugLog)\n\n const singleSidedBounce = useMainThreadRef(\n options.bounceableOptions.singleSidedBounce ?? 'both',\n )\n\n // The starting point of current touch procedure\n const startTouch = useMainThreadRef<MainThread.TouchEvent['touches'] | null>(\n null,\n )\n // Record the previous touch and clear it on touchEnd. If current is not empty, then it means that the scrollable object is being dragged.\n const prevTouch = useMainThreadRef<MainThread.TouchEvent['touches'] | null>(\n null,\n )\n\n // Current scroll velocity.\n const scrollVelocity = useMainThreadRef(0)\n // Current bouncing position.\n const bouncingPositionInfo = useMainThreadRef({})\n\n // If reaches edge and bouncing starts during dragging, save the touch point and calculate later touch delta for rubberEffect.\n const startBouncingTouch = useMainThreadRef<\n MainThread.TouchEvent['touches'] | null\n >(null)\n // If reaches edge and bouncing starts during dragging, save current bouncingPosition and continues rubberEffect's calculation from this point.\n const startTouchBouncingDelta = useMainThreadRef({})\n // when touch starts during bouncing, save current bouncingPosition and continues rubberEffect's calculation from this point.\n const bouncingTouchStartPosition = useMainThreadRef({})\n\n // Used to record the previous scroll position and calculate current scroll velocity.\n const prevScroll = useMainThreadRef({})\n\n // scroll container's basic info.\n const height = useMainThreadRef(\n options.bounceableOptions.estimatedHeight\n ?? SystemInfo.pixelHeight / SystemInfo.pixelRatio,\n )\n const width = useMainThreadRef(\n options.bounceableOptions.estimatedWidth\n ?? SystemInfo.pixelWidth / SystemInfo.pixelRatio,\n )\n const scrollX = useMainThreadRef(0)\n const scrollY = useMainThreadRef(0)\n\n // Flags for ending bouncing animation.\n const touchEndFrameEnableFlag = useMainThreadRef(false)\n const touchingEndBouncingBackEnableFlag = useMainThreadRef(false)\n const flingEndWithBouncingEnableFlag = useMainThreadRef(false)\n\n // Flags for reaches upper/lower edge.\n // When content's size is smaller than viewport, these two flags are both true.\n const toUpper = useMainThreadRef(false)\n const toLower = useMainThreadRef(false)\n\n // Read from props\n const containerID = options.id ?? 'bounceableContainer'\n const { enableBounces, onScrollToBounces } = options.bounceableOptions\n const alwaysBouncing = options.bounceableOptions.alwaysBouncing ?? false\n const scrollOrientation = options.scrollOrientation ?? 'vertical'\n const enableRTL = useMainThreadRef(options.enableRTL ?? false)\n const enableBounceEventInFling =\n options.bounceableOptions.enableBounceEventInFling ?? true\n const startBounceTriggerDistance =\n options.bounceableOptions.startBounceTriggerDistance ?? 0\n const endBounceTriggerDistance =\n options.bounceableOptions.endBounceTriggerDistance ?? 0\n // Temporary workaround as requestAnimationFrame will crash below Lynx 2.15.2.\n const temporaryValidVersionCheckForRAF = useMainThreadRef(\n options.bounceableOptions.validAnimationVersion ?? false,\n )\n log(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] init, enableBounces: ${enableBounces}, orientation: ${scrollOrientation}, enableRTL: ${\n options.enableRTL ?? false\n }`,\n )\n\n const bouncingStatus = {\n inScrollingRange: 0,\n upperBouncing: 1,\n lowerBouncing: 2,\n noBouncing: 3,\n alwaysBouncing: 4,\n }\n\n function isVertical() {\n 'main thread'\n return scrollOrientation === 'vertical'\n }\n\n function threshold() {\n 'main thread'\n return 1.0 / Number(SystemInfo.pixelRatio)\n }\n\n function normalizedHorizontalValue(value: number) {\n 'main thread'\n return enableRTL.current ? -value : value\n }\n\n function isAndroid() {\n 'main thread'\n return SystemInfo.platform === 'Android'\n }\n\n function isEmpty(obj: Record<string, unknown>) {\n 'main thread'\n return !obj || Object.keys(obj).length === 0\n }\n\n function enableScroll(enable: boolean) {\n 'main thread'\n // Android will trigger scroll during bouncing, cancel it while bouncing.\n if (isAndroid()) {\n selectorMT(containerID)?.setAttribute('enable-scroll', enable)\n }\n }\n\n // Clear all temps when a touch procedure ends.\n function clearTouchInfo() {\n 'main thread'\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] clear touch info')\n startTouch.current = null\n bouncingTouchStartPosition.current = 0\n prevTouch.current = null\n startBouncingTouch.current = null\n startTouchBouncingDelta.current = 0\n }\n\n // Temporary workaround as requestAnimationFrame will crash below Lynx 2.15.2.\n function customRequestAnimationFrame(animationFunc: () => void) {\n 'main thread'\n if (temporaryValidVersionCheckForRAF.current) {\n requestAnimationFrame(animationFunc)\n } else {\n setTimeout(animationFunc, 8)\n }\n }\n\n // Calculate current touch delta based on 'startPoint'. The startPoint here should be startBouncingTouch which means this bouncing effect happens during a touch procedure.\n function getCurrentDelta(event: MainThread.TouchEvent) {\n 'main thread'\n if (startTouch.current !== null) {\n if (startBouncingTouch.current === null) {\n return scrollOrientation === 'vertical'\n ? event.touches[0].pageY - startTouch.current[0].pageY\n : normalizedHorizontalValue(\n event.touches[0].pageX - startTouch.current[0].pageX,\n )\n } else {\n return scrollOrientation === 'vertical'\n ? event.touches[0].pageY - startBouncingTouch.current[0].pageY\n : normalizedHorizontalValue(\n event.touches[0].pageX - startBouncingTouch.current[0].pageX,\n )\n }\n }\n return 0\n }\n\n // Key bouncing status judgement.\n function getBouncingStatus() {\n 'main thread'\n // @ts-expect-error Expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const currentPosition = bouncingPositionInfo.current?.bouncingOffset ?? 0\n if (Boolean(toUpper.current) && Boolean(toLower.current)) {\n return alwaysBouncing\n ? bouncingStatus.alwaysBouncing\n : bouncingStatus.noBouncing\n }\n\n // upper bouncing\n const initialLayoutPosition = 0\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] get bouncing status, initialLayoutPosition: ${initialLayoutPosition}, currentPosition: ${currentPosition}`,\n )\n\n if (currentPosition > initialLayoutPosition) {\n return bouncingStatus.upperBouncing\n }\n\n // bottom bouncing\n if (currentPosition < initialLayoutPosition) {\n return bouncingStatus.lowerBouncing\n }\n return bouncingStatus.inScrollingRange\n }\n\n // Whether fling and bouncing back step should be triggered.\n function shouldBounceWhenTouchEnd(status: number) {\n 'main thread'\n if (\n status === bouncingStatus.inScrollingRange\n || status === bouncingStatus.noBouncing\n ) {\n return false\n }\n\n if (\n status === bouncingStatus.upperBouncing\n || status === bouncingStatus.lowerBouncing\n ) {\n return true\n }\n\n if (status === bouncingStatus.alwaysBouncing) {\n return alwaysBouncing\n }\n return false\n }\n\n // Use translate to implement real bouncing effect\n function bouncingSetStyle(offset: number) {\n 'main thread'\n if (Number.isNaN(Number(offset))) {\n mtsLog(\n true,\n '[lynx-ui-scroll-view][useBounce] ERROR! bouncingOffset is NaN',\n )\n return\n }\n // update bouncingPositionInfo first\n if (isEmpty(bouncingPositionInfo.current)) {\n // @ts-expect-error expected\n bouncingPositionInfo.current.velocity = 0\n } else {\n // @ts-expect-error expected\n const timeDiff = Date.now() - bouncingPositionInfo.current.timeStamp\n // @ts-expect-error expected\n const offsetDiff = offset - bouncingPositionInfo.current.bouncingOffset\n || 0\n if (timeDiff > 0) {\n // @ts-expect-error expected\n bouncingPositionInfo.current.velocity = offsetDiff / timeDiff\n }\n // If timeDiff <= 0, we keep the previous velocity to maintain momentum continuity.\n }\n // @ts-expect-error expected\n bouncingPositionInfo.current.bouncingOffset = offset\n // @ts-expect-error expected\n bouncingPositionInfo.current.timeStamp = Date.now()\n // When bouncing effect ends, clear startTouch and bouncingTouchStartPosition\n if (offset === 0 && prevTouch.current !== null) {\n startTouch.current = prevTouch.current\n bouncingTouchStartPosition.current = {}\n }\n // trigger translate\n if (isVertical()) {\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] apply transform, orientation: vertical, rawOffset: ${offset}, containerTransform: translateY(${offset}px)`,\n )\n selectorMT(containerID)?.setStyleProperty(\n 'transform',\n `translateY(${offset}px)`,\n )\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${offset}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${offset}px)`,\n )\n } else {\n const visualOffset = enableRTL.current ? -offset : offset\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] apply transform, orientation: horizontal, rawOffset: ${offset}, enableRTL: ${\n String(enableRTL.current)\n }, visualOffset: ${visualOffset}, containerTransform: translateX(${visualOffset}px)`,\n )\n selectorMT(containerID)?.setStyleProperty(\n 'transform',\n `translateX(${visualOffset}px)`,\n )\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${visualOffset}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${visualOffset}px)`,\n )\n }\n }\n\n function onScrollToBouncesJS(info: ScrollToBouncesInfo) {\n if (enableBounces && onScrollToBounces) {\n onScrollToBounces(info)\n }\n }\n\n // send the scrollToBounces event\n function triggerScrollToBouncesEvent(isUpper: boolean) {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] trigger scrollToBounces, direction: ${\n isUpper ? 'upper' : 'lower'\n }`,\n )\n\n const info: ScrollToBouncesInfo = {\n direction: isUpper ? 'upper' : 'lower',\n }\n runOnBackground(onScrollToBouncesJS)(info)\n }\n\n function rubberEffect(isNegative: 1 | -1, delta: number) {\n 'main thread'\n const scrollViewFrameSize = isVertical() ? height.current : width.current\n // If the touchStartPosition is not zero, it means this rubber effect happens during a touch or another bouncing effect. So the real 'start delta' should be recalculated.\n const touchStartPosition = Math.abs(\n Number(\n isEmpty(startTouchBouncingDelta.current)\n ? bouncingTouchStartPosition.current\n : startTouchBouncingDelta.current,\n ),\n )\n // This deltaYForTouchStartPosition is the inverse function of rubberEffect function\n const deltaYForTouchStartPosition =\n (scrollViewFrameSize * touchStartPosition)\n / ((scrollViewFrameSize - touchStartPosition) * rubberC.current) || 0\n // Here it calculate the next touchDelta. deltaYForNextPosition = (touch point where bouncing happens + corresponding touch delta where previous bouncing position locates)\n // This isNegative is used to handle the upper/lower bounce. RubberEffect function is different in the range (-inf,0) and [0, inf). We only use the [0, inf) part.\n const deltaYForNextPosition = bouncingTouchStartPosition.current\n ? deltaYForTouchStartPosition + isNegative * delta\n : isNegative * delta\n // Real calculation. Note that we don't use the raw touchDelta for calculating, instead, we use deltaYForNextPosition.\n const rubberBandingDistance = Math.max(\n 0,\n (1.0\n - 1.0\n / ((deltaYForNextPosition * rubberC.current) / scrollViewFrameSize\n + 1.0))\n * scrollViewFrameSize,\n )\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] rubber effect, scrollViewFrameSize: ${scrollViewFrameSize}, touchStartPosition: ${touchStartPosition}, deltaYForTouchStartPosition: ${deltaYForTouchStartPosition}, deltaYForNextPosition: ${deltaYForNextPosition}, rubberBandingDistance: ${rubberBandingDistance}`,\n )\n\n bouncingSetStyle(isNegative * rubberBandingDistance)\n }\n\n function triggerRubberEffectIfCrossingEdge(event: MainThread.TouchEvent) {\n 'main thread'\n const delta = getCurrentDelta(event)\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] check crossing edge, delta: ${delta}, toUpper: ${\n String(toUpper.current)\n }, toLower: ${String(toLower.current)}`,\n )\n\n // Crossing top range\n if (\n toUpper.current === true && delta > 0\n && (singleSidedBounce.current === 'both'\n || singleSidedBounce.current === 'upper')\n ) {\n enableScroll(false)\n rubberEffect(delta > 0 ? 1 : -1, delta)\n }\n\n // Crossing bottom range\n if (\n toLower.current === true && delta < 0\n && (singleSidedBounce.current === 'both'\n || singleSidedBounce.current === 'lower')\n ) {\n enableScroll(false)\n rubberEffect(delta > 0 ? 1 : -1, delta)\n }\n enableScroll(true)\n }\n\n // return true if scrollToBounces should be sent\n function isOverTriggerDistance() {\n 'main thread'\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const bouncingTop: number = bouncingPositionInfo.current.bouncingOffset ?? 0\n const triggerDistance =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0\n ? startBounceTriggerDistance\n : endBounceTriggerDistance\n const delta = Math.abs(bouncingTop) - Math.abs(triggerDistance)\n return delta > threshold()\n }\n\n function bouncingBack() {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling forward end',\n )\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bounce back starts',\n )\n\n // step3: bounce back\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const C1 = bouncingPositionInfo.current.bouncingOffset ?? 0\n const startTime = Date.now()\n const touchingEndBouncingBackFrame = () => {\n if (Boolean(touchingEndBouncingBackEnableFlag.current) === false) {\n return\n }\n const currentTime = Date.now() - startTime\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touching end bouncing back frame',\n )\n\n // critical damping\n const C2 = beta.current * C1\n const easedDistance = (C1 + C2 * (currentTime / 1000))\n * Math.pow(Math.E, -beta.current * (currentTime / 1000))\n bouncingSetStyle(easedDistance)\n if (Math.abs(easedDistance) < threshold()) {\n // Make sure it backs to 0\n bouncingSetStyle(0)\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bounce back ends',\n )\n } else {\n customRequestAnimationFrame(touchingEndBouncingBackFrame)\n }\n }\n\n customRequestAnimationFrame(touchingEndBouncingBackFrame)\n touchingEndBouncingBackEnableFlag.current = true\n }\n\n // bindtouchstart. Save startTouch and bouncingPosition if a bouncing effect is happening.\n function bounceableTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n startTouch.current = event.touches\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] touch start')\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n bouncingTouchStartPosition.current =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset ?? 0\n // reset all animation flags. No animation should play during a touch.\n touchEndFrameEnableFlag.current = false\n touchingEndBouncingBackEnableFlag.current = false\n flingEndWithBouncingEnableFlag.current = false\n }\n\n function bounceableTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n prevTouch.current = event.touches\n if (startTouch.current === null) {\n // It means current situation is illegal. A touchMove event happens without a touchStart event beforehand. Or a touchMove event happens after a touchEnd event.\n mtsLog(true, '[lynx-ui-scroll-view][useBounce] ERROR! touch not started')\n } else {\n const delta = getCurrentDelta(event)\n const currentBouncingStatus = getBouncingStatus()\n // Judge the status and trigger rubberEffect. The TouchMove should only consider rubberEffect and nothing else.\n switch (currentBouncingStatus) {\n case bouncingStatus.upperBouncing: {\n enableScroll(false)\n rubberEffect(1, delta)\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move upper bouncing',\n )\n break\n }\n case bouncingStatus.lowerBouncing: {\n enableScroll(false)\n rubberEffect(-1, delta)\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move lower bouncing',\n )\n break\n }\n case bouncingStatus.alwaysBouncing: {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move always bouncing',\n )\n if (alwaysBouncing) {\n triggerRubberEffectIfCrossingEdge(event)\n }\n break\n }\n case bouncingStatus.inScrollingRange: {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch move in scrolling range',\n )\n triggerRubberEffectIfCrossingEdge(event)\n break\n }\n default:\n break\n }\n }\n }\n\n // bindtouchend. In touchEnd event the fling forward animation and bouncingBack animation should be triggered if necessary.\n function bounceableTouchEnd() {\n 'main thread'\n // Reset the state. The touch information should be reset, and we should no longer ban the enable-scroll.\n clearTouchInfo()\n enableScroll(true)\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] touch end')\n if (shouldBounceWhenTouchEnd(getBouncingStatus())) {\n const startTime = Date.now()\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const dragEndVelocity = bouncingPositionInfo.current?.velocity\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const dragEndPosition = bouncingPositionInfo.current?.bouncingOffset ?? 0\n // Send scrolltobounces event.\n if (isOverTriggerDistance()) {\n triggerScrollToBouncesEvent(\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0,\n )\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n let currentVelocity: number = dragEndVelocity\n const touchEndProcessFrame = () => {\n if (Boolean(touchEndFrameEnableFlag.current) === false) {\n return\n }\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] touch end process frame',\n )\n if (Math.abs(currentVelocity) <= threshold()) {\n // If the velocity is already under threshold, skip fling and start step3: bounce back.\n bouncingBack()\n } else {\n // If the drag end with a velocity, start fling to consume it.\n // step 2: fling down\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling down start',\n )\n // This function is obtained by integrating the velocity function with a deceleration rate of flingDeceleratingRate.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const distance: number = dragEndPosition\n + (dragEndVelocity\n * (Math.pow(\n flingDeceleratingRate.current,\n Date.now() - startTime,\n )\n - 1))\n / Math.log(flingDeceleratingRate.current)\n bouncingSetStyle(distance)\n currentVelocity = dragEndVelocity\n * Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n if (touchEndFrameEnableFlag.current) {\n customRequestAnimationFrame(touchEndProcessFrame)\n }\n }\n }\n customRequestAnimationFrame(touchEndProcessFrame)\n touchEndFrameEnableFlag.current = true\n }\n }\n\n // Save the bindscroll info and calculate velocity.\n function bounceableHandleScroll(event: ScrollEvent) {\n 'main thread'\n scrollX.current = event.detail.scrollLeft\n scrollY.current = event.detail.scrollTop\n if (!isEmpty(prevScroll.current)) {\n const prev = prevScroll.current as {\n timestamp: number\n detail: { scrollTop: number, scrollLeft: number }\n }\n const timeDuration = Date.now() - prev.timestamp\n if (timeDuration > 0) {\n const deltaY = isVertical()\n ? event.detail.scrollTop - prev.detail.scrollTop\n : normalizedHorizontalValue(\n event.detail.scrollLeft - prev.detail.scrollLeft,\n )\n const velocity = deltaY / timeDuration\n if (Number.isFinite(velocity)) {\n scrollVelocity.current = velocity\n }\n }\n }\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] handle scroll near edge, scrollLeft: ${event.detail.scrollLeft}, scrollTop: ${event.detail.scrollTop}, velocity: ${scrollVelocity.current}`,\n )\n prevScroll.current = event\n }\n\n function onUpperDisexposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] upper disexposure',\n )\n toUpper.current = false\n }\n\n // Handle scrolltoupper event.\n function onUpperExposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] upper exposure')\n toUpper.current = true\n if (\n singleSidedBounce.current !== 'upper'\n && singleSidedBounce.current !== 'both'\n ) {\n return\n }\n if (prevScroll.current) {\n // reaches edge during touch\n startBouncingTouch.current = prevTouch.current\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n startTouchBouncingDelta.current =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset ?? 0\n } else if (Math.abs(scrollVelocity.current) > threshold()) {\n // reaches edge during fling\n const velocity = scrollVelocity.current\n let currentVelocity = velocity\n const startTime = Date.now()\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] fling to upper event start, velocity: ${velocity}`,\n )\n let sentScrollToBouncesEvent = false // only sent scrollToBounces once\n const flingEndWithBouncingFrame = () => {\n if (Boolean(flingEndWithBouncingEnableFlag.current) === false) {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] flingEndWithBouncingEnableFlag early return',\n )\n return\n }\n if (Math.abs(currentVelocity) <= threshold()) {\n flingEndWithBouncingEnableFlag.current = false\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling to upper event end',\n )\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bouncing to upper event start',\n )\n bouncingBack()\n } else {\n // step 1: fling\n const distance = (currentVelocity\n * (Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n - 1))\n / Math.log(flingDeceleratingRate.current)\n bouncingSetStyle(-distance)\n if (!sentScrollToBouncesEvent && isOverTriggerDistance()) {\n triggerScrollToBouncesEvent(\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0,\n )\n sentScrollToBouncesEvent = true\n }\n currentVelocity = velocity\n * Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n if (flingEndWithBouncingEnableFlag.current) {\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n }\n }\n }\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n flingEndWithBouncingEnableFlag.current = true\n }\n }\n\n function onLowerDisexposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] lower disexposure',\n )\n toLower.current = false\n }\n\n function onLowerExposure(_event: CommonEvent) {\n 'main thread'\n mtsLog(debugLogEnabled, '[lynx-ui-scroll-view][useBounce] lower exposure')\n toLower.current = true\n if (\n singleSidedBounce.current !== 'lower'\n && singleSidedBounce.current !== 'both'\n ) {\n return\n }\n // reaches lower during dragging\n if (prevTouch.current !== null) {\n startBouncingTouch.current = prevTouch.current\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n startTouchBouncingDelta.current =\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset ?? 0\n } else if (enableBounceEventInFling && scrollVelocity.current > 0) {\n const velocity = scrollVelocity.current\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] lower velocity: ${velocity}`,\n )\n\n // scroll to end with velocity, start bouncing effect\n if (Math.abs(velocity) > threshold()) {\n let currentVelocity = velocity\n const startTime = Date.now()\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useBounce] fling to lower event start, velocity: ${velocity}`,\n )\n let sentScrollToBouncesEvent = false // only sent scrollToBounces once\n const flingEndWithBouncingFrame = () => {\n if (Boolean(flingEndWithBouncingEnableFlag.current) === false) {\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] flingEndWithBouncingEnableFlag early return',\n )\n return\n }\n if (Math.abs(currentVelocity) <= threshold()) {\n flingEndWithBouncingEnableFlag.current = false\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] fling to lower event end',\n )\n mtsLog(\n debugLogEnabled,\n '[lynx-ui-scroll-view][useBounce] bouncing to lower event start',\n )\n bouncingBack()\n } else {\n // step 1: fling\n const distance = (currentVelocity\n * (Math.pow(\n flingDeceleratingRate.current,\n Date.now() - startTime,\n )\n - 1))\n / Math.log(flingDeceleratingRate.current)\n bouncingSetStyle(-distance)\n if (!sentScrollToBouncesEvent && isOverTriggerDistance()) {\n triggerScrollToBouncesEvent(\n // @ts-expect-error expected\n bouncingPositionInfo.current?.bouncingOffset > 0,\n )\n sentScrollToBouncesEvent = true\n }\n currentVelocity = velocity\n * Math.pow(flingDeceleratingRate.current, Date.now() - startTime)\n if (flingEndWithBouncingEnableFlag) {\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n }\n }\n }\n customRequestAnimationFrame(flingEndWithBouncingFrame)\n flingEndWithBouncingEnableFlag.current = true\n }\n }\n }\n\n // Used to get the size of scroll container.\n function bounceableLayoutChange(event: CommonEvent) {\n 'main thread'\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n height.current = (isAndroid() ? event.params?.height : event.detail?.height)\n ?? 0\n // @ts-expect-error expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n width.current = (isAndroid() ? event.params?.width : event.detail?.width)\n ?? 0\n }\n\n return {\n 'main-thread:bindtouchstart': bounceableTouchStart,\n 'main-thread:bindtouchend': bounceableTouchEnd,\n 'main-thread:bindtouchmove': bounceableTouchMove,\n 'main-thread:bindlayoutchange': bounceableLayoutChange,\n 'main-thread:bindscroll': bounceableHandleScroll,\n onUpperExposure,\n onUpperDisexposure,\n onLowerExposure,\n onLowerDisexposure,\n }\n}\n"],"names":["useBounce","options","rubberC","useMainThreadRef","flingDeceleratingRate","beta","debugLogEnabled","Boolean","singleSidedBounce","startTouch","prevTouch","scrollVelocity","bouncingPositionInfo","startBouncingTouch","startTouchBouncingDelta","bouncingTouchStartPosition","prevScroll","height","SystemInfo","width","scrollX","scrollY","touchEndFrameEnableFlag","touchingEndBouncingBackEnableFlag","flingEndWithBouncingEnableFlag","toUpper","toLower","containerID","enableBounces","onScrollToBounces","alwaysBouncing","scrollOrientation","enableRTL","enableBounceEventInFling","startBounceTriggerDistance","endBounceTriggerDistance","temporaryValidVersionCheckForRAF","log","bouncingStatus","isVertical","threshold","Number","normalizedHorizontalValue","value","isAndroid","isEmpty","obj","Object","enableScroll","enable","selectorMT","clearTouchInfo","mtsLog","customRequestAnimationFrame","animationFunc","requestAnimationFrame","setTimeout","getCurrentDelta","event","getBouncingStatus","currentPosition","initialLayoutPosition","shouldBounceWhenTouchEnd","status","bouncingSetStyle","offset","timeDiff","Date","offsetDiff","visualOffset","String","onScrollToBouncesJS","info","triggerScrollToBouncesEvent","isUpper","runOnBackground","rubberEffect","isNegative","delta","scrollViewFrameSize","touchStartPosition","Math","deltaYForTouchStartPosition","deltaYForNextPosition","rubberBandingDistance","triggerRubberEffectIfCrossingEdge","isOverTriggerDistance","bouncingTop","triggerDistance","bouncingBack","C1","startTime","touchingEndBouncingBackFrame","currentTime","C2","easedDistance","bounceableTouchStart","bounceableTouchMove","currentBouncingStatus","bounceableTouchEnd","dragEndVelocity","dragEndPosition","currentVelocity","touchEndProcessFrame","distance","bounceableHandleScroll","prev","timeDuration","deltaY","velocity","onUpperDisexposure","_event","onUpperExposure","sentScrollToBouncesEvent","flingEndWithBouncingFrame","onLowerDisexposure","onLowerExposure","bounceableLayoutChange"],"mappings":";;AA2DO,SAASA,UAAUC,OAAyB;IAEjD,MAAMC,UAAUC,iBAAiB;IAEjC,MAAMC,wBAAwBD,iBAAiB;IAE/C,MAAME,OAAOF,iBAAiB;IAE9B,MAAMG,kBAAkBC,QAAQN,QAAQ,QAAQ;IAEhD,MAAMO,oBAAoBL,iBACxBF,QAAQ,iBAAiB,CAAC,iBAAiB,IAAI;IAIjD,MAAMQ,aAAaN,iBACjB;IAGF,MAAMO,YAAYP,iBAChB;IAIF,MAAMQ,iBAAiBR,iBAAiB;IAExC,MAAMS,uBAAuBT,iBAAiB,CAAC;IAG/C,MAAMU,qBAAqBV,iBAEzB;IAEF,MAAMW,0BAA0BX,iBAAiB,CAAC;IAElD,MAAMY,6BAA6BZ,iBAAiB,CAAC;IAGrD,MAAMa,aAAab,iBAAiB,CAAC;IAGrC,MAAMc,SAASd,iBACbF,QAAQ,iBAAiB,CAAC,eAAe,IACpCiB,WAAW,WAAW,GAAGA,WAAW,UAAU;IAErD,MAAMC,QAAQhB,iBACZF,QAAQ,iBAAiB,CAAC,cAAc,IACnCiB,WAAW,UAAU,GAAGA,WAAW,UAAU;IAEpD,MAAME,UAAUjB,iBAAiB;IACjC,MAAMkB,UAAUlB,iBAAiB;IAGj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;gBACA7D,4BAA4B6D;gBAC5B1F,+BAA+B,OAAO,GAAG;YAC3C;QACF;IACF;IAGA,SAAS6F,uBAAuB3D,KAAkB;QAChD;QAGAzC,OAAO,OAAO,GAAI2B,AAAAA,CAAAA,cAAcc,MAAM,MAAM,EAAE,SAASA,MAAM,MAAM,EAAE,MAAK,KACrE;QAGLvC,MAAM,OAAO,GAAIyB,AAAAA,CAAAA,cAAcc,MAAM,MAAM,EAAE,QAAQA,MAAM,MAAM,EAAE,KAAI,KAClE;IACP;IAEA,OAAO;QACL,8BAA8BsC;QAC9B,4BAA4BG;QAC5B,6BAA6BF;QAC7B,gCAAgCoB;QAChC,0BAA0BZ;QAC1BO;QACAF;QACAM;QACAD;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useNativeBounce.jsx","sources":["../../src/hooks/useNativeBounce.tsx"],"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 { runOnBackground, useMainThreadRef } from '@lynx-js/react'\n\nimport { mtsLog, selectorMT } from '@lynx-js/lynx-ui-common'\nimport type { CommonEvent, ScrollEvent } from '@lynx-js/types'\n\nimport type { BounceableBasicProps, scrollToBouncesInfo } from '../types'\nimport { getNativeBounceMetricsMT } from './nativeBounceUtils'\n\ninterface UseNativeBounceOptions {\n bounceableOptions: BounceableBasicProps\n debugLog?: boolean\n enableRTL?: boolean\n id?: string\n scrollOrientation: 'vertical' | 'horizontal'\n}\n\ninterface NativeBounceHandlers {\n 'main-thread:bindlayoutchange': (event: CommonEvent) => void\n 'main-thread:bindscroll': (event: ScrollEvent) => void\n 'main-thread:bindscrollend': (event: ScrollEvent) => void\n}\n\nexport function useNativeBounce(\n options: UseNativeBounceOptions,\n): NativeBounceHandlers {\n const containerID = options.id ?? 'bounceableContainer'\n const isVertical = options.scrollOrientation === 'vertical'\n const enableRTL = options.enableRTL ?? false\n const debugLogEnabled = Boolean(options.debugLog)\n const height = useMainThreadRef(\n options.bounceableOptions.estimatedHeight ?? 0,\n )\n const width = useMainThreadRef(\n options.bounceableOptions.estimatedWidth ?? 0,\n )\n const maxUpperDistance = useMainThreadRef(0)\n const maxLowerDistance = useMainThreadRef(0)\n const lastBounceDirection = useMainThreadRef<'upper' | 'lower' | null>(null)\n\n const singleSidedBounce = options.bounceableOptions.singleSidedBounce\n ?? 'both'\n const enableUpper = singleSidedBounce === 'upper'\n || singleSidedBounce === 'both'\n || singleSidedBounce === 'iOSBounces'\n const enableLower = singleSidedBounce === 'lower'\n || singleSidedBounce === 'both'\n || singleSidedBounce === 'iOSBounces'\n\n function setBounceViewOffset(upperDistance: number, lowerDistance: number) {\n 'main thread'\n if (isVertical) {\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${upperDistance}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${-lowerDistance}px)`,\n )\n } else {\n const direction = enableRTL ? -1 : 1\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${direction * upperDistance}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${-direction * lowerDistance}px)`,\n )\n }\n }\n\n function onScrollToBouncesJS(info: scrollToBouncesInfo) {\n options.bounceableOptions.onScrollToBounces?.(info)\n }\n\n function nativeBounceLayoutChange(event: CommonEvent) {\n 'main thread'\n const isAndroid = SystemInfo.platform === 'Android'\n // @ts-expect-error Expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n height.current = (isAndroid ? event.params?.height : event.detail?.height)\n ?? 0\n // @ts-expect-error Expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n width.current = (isAndroid ? event.params?.width : event.detail?.width) ?? 0\n\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useNativeBounce] layout change, height: ${height.current}, width: ${width.current}`,\n )\n }\n\n function nativeBounceScroll(event: ScrollEvent) {\n 'main thread'\n const offset = isVertical\n ? event.detail.scrollTop\n : event.detail.scrollLeft\n const scrollSize = isVertical\n ? event.detail.scrollHeight\n : event.detail.scrollWidth\n const viewportSize = isVertical ? height.current : width.current\n const {\n maxScrollOffset,\n upperDistance,\n lowerDistance,\n } = getNativeBounceMetricsMT(\n offset,\n scrollSize,\n viewportSize,\n enableUpper,\n enableLower,\n )\n\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useNativeBounce] scroll, offset: ${offset}, scrollSize: ${scrollSize}, viewportSize: ${viewportSize}, maxScrollOffset: ${maxScrollOffset}, upperDistance: ${upperDistance}, lowerDistance: ${lowerDistance}`,\n )\n\n setBounceViewOffset(upperDistance, lowerDistance)\n\n if (upperDistance > 0) {\n maxUpperDistance.current = Math.max(\n maxUpperDistance.current,\n upperDistance,\n )\n lastBounceDirection.current = 'upper'\n } else if (lowerDistance > 0) {\n maxLowerDistance.current = Math.max(\n maxLowerDistance.current,\n lowerDistance,\n )\n lastBounceDirection.current = 'lower'\n }\n }\n\n function nativeBounceScrollEnd(event: ScrollEvent) {\n 'main thread'\n const offset = isVertical\n ? event.detail.scrollTop\n : event.detail.scrollLeft\n const scrollSize = isVertical\n ? event.detail.scrollHeight\n : event.detail.scrollWidth\n const viewportSize = isVertical ? height.current : width.current\n const { upperDistance, lowerDistance } = getNativeBounceMetricsMT(\n offset,\n scrollSize,\n viewportSize,\n enableUpper,\n enableLower,\n )\n\n setBounceViewOffset(upperDistance, lowerDistance)\n\n const direction = lastBounceDirection.current\n const triggerDistance = direction === 'upper'\n ? (options.bounceableOptions.startBounceTriggerDistance ?? 0)\n : (options.bounceableOptions.endBounceTriggerDistance ?? 0)\n const maxDistance = direction === 'upper'\n ? maxUpperDistance.current\n : maxLowerDistance.current\n\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useNativeBounce] scroll end, offset: ${offset}, upperDistance: ${upperDistance}, lowerDistance: ${lowerDistance}, direction: ${\n String(direction)\n }, maxUpperDistance: ${maxUpperDistance.current}, maxLowerDistance: ${maxLowerDistance.current}, triggerDistance: ${triggerDistance}`,\n )\n\n if (\n direction !== null\n && maxDistance > triggerDistance\n ) {\n runOnBackground(onScrollToBouncesJS)({ direction })\n }\n\n maxUpperDistance.current = 0\n maxLowerDistance.current = 0\n lastBounceDirection.current = null\n }\n\n return {\n 'main-thread:bindlayoutchange': nativeBounceLayoutChange,\n 'main-thread:bindscroll': nativeBounceScroll,\n 'main-thread:bindscrollend': nativeBounceScrollEnd,\n }\n}\n"],"names":["useNativeBounce","options","containerID","isVertical","enableRTL","debugLogEnabled","Boolean","height","useMainThreadRef","width","maxUpperDistance","maxLowerDistance","lastBounceDirection","singleSidedBounce","enableUpper","enableLower","setBounceViewOffset","upperDistance","lowerDistance","selectorMT","direction","onScrollToBouncesJS","info","nativeBounceLayoutChange","event","isAndroid","SystemInfo","mtsLog","nativeBounceScroll","offset","scrollSize","viewportSize","maxScrollOffset","getNativeBounceMetricsMT","Math","nativeBounceScrollEnd","triggerDistance","maxDistance","String","runOnBackground"],"mappings":";;;AA0BO,SAASA,gBACdC,OAA+B;IAE/B,MAAMC,cAAcD,QAAQ,EAAE,IAAI;IAClC,MAAME,aAAaF,AAA8B,eAA9BA,QAAQ,iBAAiB;IAC5C,MAAMG,YAAYH,QAAQ,SAAS,IAAI;IACvC,MAAMI,kBAAkBC,QAAQL,QAAQ,QAAQ;IAChD,MAAMM,SAASC,iBACbP,QAAQ,iBAAiB,CAAC,eAAe,IAAI;IAE/C,MAAMQ,QAAQD,iBACZP,QAAQ,iBAAiB,CAAC,cAAc,IAAI;IAE9C,MAAMS,mBAAmBF,iBAAiB;IAC1C,MAAMG,mBAAmBH,iBAAiB;IAC1C,MAAMI,sBAAsBJ,iBAA2C;IAEvE,MAAMK,oBAAoBZ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AMwB,kBAAkBhB,AAAc,YAAdA,YACnBnB,QAAQ,iBAAiB,CAAC,0BAA0B,IAAI,IACxDA,QAAQ,iBAAiB,CAAC,wBAAwB,IAAI;QAC3D,MAAMoC,cAAcjB,AAAc,YAAdA,YAChBV,iBAAiB,OAAO,GACxBC,iBAAiB,OAAO;QAE5BgB,OACEtB,iBACA,CAAC,2DAA2D,EAAEwB,OAAO,iBAAiB,EAAEZ,cAAc,iBAAiB,EAAEC,cAAc,aAAa,EAClJoB,OAAOlB,WACR,oBAAoB,EAAEV,iBAAiB,OAAO,CAAC,oBAAoB,EAAEC,iBAAiB,OAAO,CAAC,mBAAmB,EAAEyB,iBAAiB;QAGvI,IACEhB,AAAc,SAAdA,aACGiB,cAAcD,iBAEjBG,gBAAgBlB,qBAAqB;YAAED;QAAU;QAGnDV,iBAAiB,OAAO,GAAG;QAC3BC,iBAAiB,OAAO,GAAG;QAC3BC,oBAAoB,OAAO,GAAG;IAChC;IAEA,OAAO;QACL,gCAAgCW;QAChC,0BAA0BK;QAC1B,6BAA6BO;IAC/B;AACF"}
|
|
1
|
+
{"version":3,"file":"hooks/useNativeBounce.jsx","sources":["../../src/hooks/useNativeBounce.tsx"],"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 { runOnBackground, useMainThreadRef } from '@lynx-js/react'\n\nimport { mtsLog, selectorMT } from '@lynx-js/lynx-ui-common'\nimport type { CommonEvent, ScrollEvent } from '@lynx-js/types'\n\nimport type { BounceableBasicProps, ScrollToBouncesInfo } from '../types'\nimport { getNativeBounceMetricsMT } from './nativeBounceUtils'\n\ninterface UseNativeBounceOptions {\n bounceableOptions: BounceableBasicProps\n debugLog?: boolean\n enableRTL?: boolean\n id?: string\n scrollOrientation: 'vertical' | 'horizontal'\n}\n\ninterface NativeBounceHandlers {\n 'main-thread:bindlayoutchange': (event: CommonEvent) => void\n 'main-thread:bindscroll': (event: ScrollEvent) => void\n 'main-thread:bindscrollend': (event: ScrollEvent) => void\n}\n\nexport function useNativeBounce(\n options: UseNativeBounceOptions,\n): NativeBounceHandlers {\n const containerID = options.id ?? 'bounceableContainer'\n const isVertical = options.scrollOrientation === 'vertical'\n const enableRTL = options.enableRTL ?? false\n const debugLogEnabled = Boolean(options.debugLog)\n const height = useMainThreadRef(\n options.bounceableOptions.estimatedHeight ?? 0,\n )\n const width = useMainThreadRef(\n options.bounceableOptions.estimatedWidth ?? 0,\n )\n const maxUpperDistance = useMainThreadRef(0)\n const maxLowerDistance = useMainThreadRef(0)\n const lastBounceDirection = useMainThreadRef<'upper' | 'lower' | null>(null)\n\n const singleSidedBounce = options.bounceableOptions.singleSidedBounce\n ?? 'both'\n const enableUpper = singleSidedBounce === 'upper'\n || singleSidedBounce === 'both'\n || singleSidedBounce === 'iOSBounces'\n const enableLower = singleSidedBounce === 'lower'\n || singleSidedBounce === 'both'\n || singleSidedBounce === 'iOSBounces'\n\n function setBounceViewOffset(upperDistance: number, lowerDistance: number) {\n 'main thread'\n if (isVertical) {\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${upperDistance}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateY(${-lowerDistance}px)`,\n )\n } else {\n const direction = enableRTL ? -1 : 1\n selectorMT(`${containerID}-upperBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${direction * upperDistance}px)`,\n )\n selectorMT(`${containerID}-lowerBounceWrapper`)?.setStyleProperty(\n 'transform',\n `translateX(${-direction * lowerDistance}px)`,\n )\n }\n }\n\n function onScrollToBouncesJS(info: ScrollToBouncesInfo) {\n options.bounceableOptions.onScrollToBounces?.(info)\n }\n\n function nativeBounceLayoutChange(event: CommonEvent) {\n 'main thread'\n const isAndroid = SystemInfo.platform === 'Android'\n // @ts-expect-error Expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n height.current = (isAndroid ? event.params?.height : event.detail?.height)\n ?? 0\n // @ts-expect-error Expected\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n width.current = (isAndroid ? event.params?.width : event.detail?.width) ?? 0\n\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useNativeBounce] layout change, height: ${height.current}, width: ${width.current}`,\n )\n }\n\n function nativeBounceScroll(event: ScrollEvent) {\n 'main thread'\n const offset = isVertical\n ? event.detail.scrollTop\n : event.detail.scrollLeft\n const scrollSize = isVertical\n ? event.detail.scrollHeight\n : event.detail.scrollWidth\n const viewportSize = isVertical ? height.current : width.current\n const {\n maxScrollOffset,\n upperDistance,\n lowerDistance,\n } = getNativeBounceMetricsMT(\n offset,\n scrollSize,\n viewportSize,\n enableUpper,\n enableLower,\n )\n\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useNativeBounce] scroll, offset: ${offset}, scrollSize: ${scrollSize}, viewportSize: ${viewportSize}, maxScrollOffset: ${maxScrollOffset}, upperDistance: ${upperDistance}, lowerDistance: ${lowerDistance}`,\n )\n\n setBounceViewOffset(upperDistance, lowerDistance)\n\n if (upperDistance > 0) {\n maxUpperDistance.current = Math.max(\n maxUpperDistance.current,\n upperDistance,\n )\n lastBounceDirection.current = 'upper'\n } else if (lowerDistance > 0) {\n maxLowerDistance.current = Math.max(\n maxLowerDistance.current,\n lowerDistance,\n )\n lastBounceDirection.current = 'lower'\n }\n }\n\n function nativeBounceScrollEnd(event: ScrollEvent) {\n 'main thread'\n const offset = isVertical\n ? event.detail.scrollTop\n : event.detail.scrollLeft\n const scrollSize = isVertical\n ? event.detail.scrollHeight\n : event.detail.scrollWidth\n const viewportSize = isVertical ? height.current : width.current\n const { upperDistance, lowerDistance } = getNativeBounceMetricsMT(\n offset,\n scrollSize,\n viewportSize,\n enableUpper,\n enableLower,\n )\n\n setBounceViewOffset(upperDistance, lowerDistance)\n\n const direction = lastBounceDirection.current\n const triggerDistance = direction === 'upper'\n ? (options.bounceableOptions.startBounceTriggerDistance ?? 0)\n : (options.bounceableOptions.endBounceTriggerDistance ?? 0)\n const maxDistance = direction === 'upper'\n ? maxUpperDistance.current\n : maxLowerDistance.current\n\n mtsLog(\n debugLogEnabled,\n `[lynx-ui-scroll-view][useNativeBounce] scroll end, offset: ${offset}, upperDistance: ${upperDistance}, lowerDistance: ${lowerDistance}, direction: ${\n String(direction)\n }, maxUpperDistance: ${maxUpperDistance.current}, maxLowerDistance: ${maxLowerDistance.current}, triggerDistance: ${triggerDistance}`,\n )\n\n if (\n direction !== null\n && maxDistance > triggerDistance\n ) {\n runOnBackground(onScrollToBouncesJS)({ direction })\n }\n\n maxUpperDistance.current = 0\n maxLowerDistance.current = 0\n lastBounceDirection.current = null\n }\n\n return {\n 'main-thread:bindlayoutchange': nativeBounceLayoutChange,\n 'main-thread:bindscroll': nativeBounceScroll,\n 'main-thread:bindscrollend': nativeBounceScrollEnd,\n }\n}\n"],"names":["useNativeBounce","options","containerID","isVertical","enableRTL","debugLogEnabled","Boolean","height","useMainThreadRef","width","maxUpperDistance","maxLowerDistance","lastBounceDirection","singleSidedBounce","enableUpper","enableLower","setBounceViewOffset","upperDistance","lowerDistance","selectorMT","direction","onScrollToBouncesJS","info","nativeBounceLayoutChange","event","isAndroid","SystemInfo","mtsLog","nativeBounceScroll","offset","scrollSize","viewportSize","maxScrollOffset","getNativeBounceMetricsMT","Math","nativeBounceScrollEnd","triggerDistance","maxDistance","String","runOnBackground"],"mappings":";;;AA0BO,SAASA,gBACdC,OAA+B;IAE/B,MAAMC,cAAcD,QAAQ,EAAE,IAAI;IAClC,MAAME,aAAaF,AAA8B,eAA9BA,QAAQ,iBAAiB;IAC5C,MAAMG,YAAYH,QAAQ,SAAS,IAAI;IACvC,MAAMI,kBAAkBC,QAAQL,QAAQ,QAAQ;IAChD,MAAMM,SAASC,iBACbP,QAAQ,iBAAiB,CAAC,eAAe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AaI,OAAO,OAAO,GAAGE,MAAM,OAAO;QAChE,MAAM,EAAEQ,aAAa,EAAEC,aAAa,EAAE,GAAGe,yBACvCJ,QACAC,YACAC,cACAjB,aACAC;QAGFC,oBAAoBC,eAAeC;QAEnC,MAAME,YAAYR,oBAAoB,OAAO;QAC7C,MAAMwB,kBAAkBhB,AAAc,YAAdA,YACnBnB,QAAQ,iBAAiB,CAAC,0BAA0B,IAAI,IACxDA,QAAQ,iBAAiB,CAAC,wBAAwB,IAAI;QAC3D,MAAMoC,cAAcjB,AAAc,YAAdA,YAChBV,iBAAiB,OAAO,GACxBC,iBAAiB,OAAO;QAE5BgB,OACEtB,iBACA,CAAC,2DAA2D,EAAEwB,OAAO,iBAAiB,EAAEZ,cAAc,iBAAiB,EAAEC,cAAc,aAAa,EAClJoB,OAAOlB,WACR,oBAAoB,EAAEV,iBAAiB,OAAO,CAAC,oBAAoB,EAAEC,iBAAiB,OAAO,CAAC,mBAAmB,EAAEyB,iBAAiB;QAGvI,IACEhB,AAAc,SAAdA,aACGiB,cAAcD,iBAEjBG,gBAAgBlB,qBAAqB;YAAED;QAAU;QAGnDV,iBAAiB,OAAO,GAAG;QAC3BC,iBAAiB,OAAO,GAAG;QAC3BC,oBAAoB,OAAO,GAAG;IAChC;IAEA,OAAO;QACL,gCAAgCW;QAChC,0BAA0BK;QAC1B,6BAA6BO;IAC/B;AACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ReactElement } from '@lynx-js/react';
|
|
1
2
|
import '@lynx-js/gesture-runtime';
|
|
2
|
-
import type { ScrollViewProps, ScrollViewRef
|
|
3
|
+
import type { ScrollViewProps, ScrollViewRef } from './types/index.js';
|
|
3
4
|
export type { ScrollViewProps, ScrollViewRef };
|
|
4
5
|
export { useBounce } from './hooks/useBounce.js';
|
|
5
|
-
export type { bounceHandlers } from './hooks/useBounce.js';
|
|
6
|
+
export type { BounceHandlers, bounceHandlers } from './hooks/useBounce.js';
|
|
6
7
|
export type { BounceableBasicProps } from './types/index.js';
|
|
7
|
-
|
|
8
|
+
type ScrollViewComponent = (props: ScrollViewProps) => ReactElement;
|
|
9
|
+
export declare const ScrollView: ScrollViewComponent;
|
|
8
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAgB,YAAY,EAAa,MAAM,gBAAgB,CAAA;AAE3E,OAAO,0BAA0B,CAAA;AAmBjC,OAAO,KAAK,EAEV,eAAe,EACf,aAAa,EACd,MAAM,SAAS,CAAA;AAEhB,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvE,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnD,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,YAAY,CAAA;AAEnE,eAAO,MAAM,UAAU,EAElB,mBAAmB,CAAA"}
|
package/dist/index.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.jsx","sources":["../src/index.tsx"],"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 { forwardRef, memo, useRef } from '@lynx-js/react'\nimport type { ForwardedRef, ReactNode } from '@lynx-js/react'\n\nimport '@lynx-js/gesture-runtime'\nimport type { GestureKind } from '@lynx-js/gesture-runtime'\nimport type { LazyOptions } from '@lynx-js/lynx-ui-common'\nimport {\n ExposureEventsMapping,\n LayoutEventsMapping,\n ScrollEventsMapping,\n TouchEventsMapping,\n nativeLynxSDKVersionLessThan,\n useRegisteredEvents,\n} from '@lynx-js/lynx-ui-common'\nimport { LazyComponent } from '@lynx-js/lynx-ui-lazy-component'\nimport type {\n CSSProperties,\n ScrollViewProps as ScrollViewElementProps,\n} from '@lynx-js/types'\n\nimport ScrollViewBasic from './ScrollViewBasic'\nimport ScrollViewWithBouncesHook from './ScrollViewWithBouncesHook'\nimport type {\n BounceableBasicProps,\n ScrollViewProps,\n ScrollViewRef,\n ScrollView as ScrollViewType,\n} from './types'\n\nexport type { ScrollViewProps, ScrollViewRef }\nexport { useBounce } from './hooks/useBounce'\nexport type { bounceHandlers } from './hooks/useBounce'\nexport type { BounceableBasicProps } from './types'\n\nexport const ScrollView = memo(forwardRef(ScrollViewImpl)) as ScrollViewType\n\nconst ScrollViewEventMapping: Record<string, string> = {\n onContentSizeChange: 'bindcontentsizechanged',\n onWheel: 'bindwheel',\n}\n\n/**\n * @example\n * ```javascript\n * <ScrollView\n scene={`viewpager_${index1}`}\n style={{ width: '100%', height: '100%' }}\n estimatedItemStyle={{ width: '100%', height: '800px' }}\n scrollOrientation='vertical'\n exposureRight=\"50px\"\n exposureBottom=\"220px\"\n >\n {scrollview.map((item, index) => (\n <view\n style={`width:100%;height:580rpx;`}\n >\n <text>{`slot-${index}`}</text>\n </view>\n ))}\n </ScrollView>\n * ```\n */\nfunction ScrollViewImpl(\n props: ScrollViewProps,\n _ref: ForwardedRef<ScrollViewRef>,\n) {\n const {\n scrollviewId = 'scrollview',\n horizontal = false,\n style,\n children,\n scrollOrientation,\n lazyOptions,\n className = '',\n debugLog = false,\n enableRTL = false,\n bounceableOptions = {\n enableBounces: true,\n singleSidedBounce: 'iOSBounces',\n },\n enableScroll = true,\n enableScrollMonitor = false,\n enableNewArch: enableNewArchProp,\n scrollMonitorTag,\n sticky,\n scrollPropagationBehavior = 'native',\n temporaryBlockScrollClass = 'BDXLynxViewPager',\n temporaryBlockScrollTag = 0,\n temporaryNestedScroll,\n experimentalNestedScrollForward,\n experimentalNestedScrollBackward,\n androidTouchSlop,\n 'main-thread:gesture': gesture,\n } = props\n const enableNewArch = enableNewArchProp\n ?? !nativeLynxSDKVersionLessThan('4.3')\n // generates binding events dynamically\n const scrollViewRegisteredEvents = useRef<Record<string, string>>({\n ...ScrollEventsMapping,\n ...ExposureEventsMapping,\n ...TouchEventsMapping,\n ...LayoutEventsMapping,\n ...ScrollViewEventMapping,\n })\n const normalizedLazyOptions: LazyOptions | undefined = lazyOptions\n ? { firstScreenItemCount: 1, ...lazyOptions }\n : undefined\n const registerEvents = useRegisteredEvents(\n props,\n scrollViewRegisteredEvents.current,\n )\n const normalizedStyle: CSSProperties = {\n zIndex: 0,\n ...style,\n }\n\n const isHorizontal = () => {\n return scrollOrientation ? scrollOrientation === 'horizontal' : horizontal\n }\n\n // Initialize bounceableProps\n let enableBounce = false\n let bounceableProps: BounceableBasicProps = { enableBounces: false }\n if (typeof bounceableOptions === 'boolean') {\n // Initialize the default value if the bounceableOptions is simply 'true' without specific options\n enableBounce = bounceableOptions\n bounceableProps = {\n enableBounces: enableBounce,\n singleSidedBounce: 'both',\n alwaysBouncing: true,\n validAnimationVersion: true,\n }\n } else if (typeof bounceableOptions === 'object') {\n enableBounce = bounceableOptions.enableBounces\n bounceableProps = bounceableOptions\n bounceableProps.singleSidedBounce = bounceableOptions.singleSidedBounce\n ?? 'both'\n bounceableProps.alwaysBouncing = bounceableOptions.alwaysBouncing ?? true\n bounceableProps.validAnimationVersion =\n bounceableOptions.validAnimationVersion ?? true\n }\n // The new architecture provides native bounces on every platform. On the\n // legacy architecture, native bounces are only used for iOSBounces.\n const nativeBounces = enableBounce\n && (enableNewArch\n ? bounceableProps.singleSidedBounce !== 'none'\n : bounceableProps.singleSidedBounce === 'iOSBounces')\n\n const shouldEnableNested = () => {\n if (\n SystemInfo.platform === 'iOS' && scrollPropagationBehavior !== 'propagate'\n ) {\n return false\n }\n return true\n }\n\n const renderChildren = (\n children: ReactNode,\n lazyOptions: LazyOptions | undefined,\n ) => {\n if (!Array.isArray(children)) {\n return children\n }\n const lazy = lazyOptions?.enableLazy\n return children.map((item: ReactNode, index: number) => {\n if (lazy && index >= Number(lazyOptions?.firstScreenItemCount)) {\n return (\n <LazyComponent\n key={`${scrollviewId}_lazy_${index}`}\n scene={lazyOptions?.scene}\n pid={`pid_${index}`}\n estimatedStyle={lazyOptions?.estimatedItemStyle}\n top={lazyOptions?.exposureTop}\n bottom={lazyOptions?.exposureBottom}\n left={lazyOptions?.exposureLeft}\n right={lazyOptions?.exposureRight}\n >\n {item}\n </LazyComponent>\n )\n }\n return item\n })\n }\n\n // These props will be spread directly to <scroll-view> element. Make sure it's valid\n type ExtendedScrollViewElementProps = ScrollViewElementProps & {\n 'scroll-x': boolean\n 'scroll-y': boolean\n 'scroll-orientation'?: 'horizontal' | 'vertical'\n 'scroll-view-new-arch'?: boolean\n }\n const elementProps: ExtendedScrollViewElementProps & {\n 'enable-scroll-monitor': boolean\n 'scroll-monitor-tag'?: string\n 'main-thread:gesture'?: GestureKind\n 'enable-new-nested'?: boolean\n 'enable-nested-scroll'?: boolean\n 'temporary-nested-scroll-forward'?: ScrollViewProps[\n 'experimentalNestedScrollForward'\n ]\n 'temporary-nested-scroll-backward'?: ScrollViewProps[\n 'experimentalNestedScrollBackward'\n ]\n 'force-can-scroll'?: boolean\n 'ios-block-gesture-class'?: string\n 'ios-recognized-view-tag'?: number\n 'className'?: string\n 'style'?: CSSProperties\n 'bounces'?: boolean\n } = {\n 'id': scrollviewId,\n 'scroll-x': isHorizontal(),\n 'scroll-y': !isHorizontal(),\n ...(enableNewArch && {\n 'scroll-orientation': isHorizontal() ? 'horizontal' : 'vertical',\n 'scroll-view-new-arch': true,\n }),\n 'enable-scroll-monitor': enableScrollMonitor,\n 'scroll-monitor-tag': scrollMonitorTag,\n 'main-thread:gesture': gesture,\n 'force-can-scroll': scrollPropagationBehavior === 'preventPropagate',\n 'ios-block-gesture-class': scrollPropagationBehavior === 'preventPropagate'\n ? temporaryBlockScrollClass\n : '',\n 'ios-recognized-view-tag': scrollPropagationBehavior === 'preventPropagate'\n ? temporaryBlockScrollTag\n : 0,\n 'enable-nested-scroll': SystemInfo.platform === 'Android'\n ? (temporaryNestedScroll ?? true)\n : shouldEnableNested(),\n 'enable-new-nested': true,\n 'className': className,\n 'style': normalizedStyle,\n 'bounces': nativeBounces,\n 'enable-scroll': enableScroll,\n ...(androidTouchSlop !== undefined\n && { 'android-touch-slop': androidTouchSlop }),\n ...(experimentalNestedScrollForward !== undefined && {\n 'temporary-nested-scroll-forward': experimentalNestedScrollForward,\n }),\n ...(experimentalNestedScrollBackward !== undefined && {\n 'temporary-nested-scroll-backward': experimentalNestedScrollBackward,\n }),\n ...registerEvents,\n }\n\n if (enableNewArch) {\n if (\n nativeBounces\n && (bounceableProps.upperBounceItem\n || bounceableProps.lowerBounceItem\n || bounceableProps.onScrollToBounces)\n ) {\n return (\n <ScrollViewWithBouncesHook\n elementProps={elementProps}\n bounceableOptions={bounceableProps}\n debugLog={debugLog}\n enableRTL={enableRTL}\n nativeBounces={true}\n sticky={sticky}\n >\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewWithBouncesHook>\n )\n }\n return (\n <ScrollViewBasic elementProps={elementProps} sticky={sticky}>\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewBasic>\n )\n } else if (\n enableBounce\n && bounceableProps.singleSidedBounce !== 'iOSBounces'\n && bounceableProps.singleSidedBounce !== 'none'\n ) {\n return (\n <ScrollViewWithBouncesHook\n elementProps={elementProps}\n bounceableOptions={bounceableProps}\n debugLog={debugLog}\n enableRTL={enableRTL}\n sticky={sticky}\n >\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewWithBouncesHook>\n )\n } else {\n return (\n <ScrollViewBasic elementProps={elementProps} sticky={sticky}>\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewBasic>\n )\n }\n}\n"],"names":["ScrollView","memo","forwardRef","ScrollViewImpl","ScrollViewEventMapping","props","_ref","scrollviewId","horizontal","style","children","scrollOrientation","lazyOptions","className","debugLog","enableRTL","bounceableOptions","enableScroll","enableScrollMonitor","enableNewArchProp","scrollMonitorTag","sticky","scrollPropagationBehavior","temporaryBlockScrollClass","temporaryBlockScrollTag","temporaryNestedScroll","experimentalNestedScrollForward","experimentalNestedScrollBackward","androidTouchSlop","gesture","enableNewArch","nativeLynxSDKVersionLessThan","scrollViewRegisteredEvents","useRef","ScrollEventsMapping","ExposureEventsMapping","TouchEventsMapping","LayoutEventsMapping","normalizedLazyOptions","undefined","registerEvents","useRegisteredEvents","normalizedStyle","isHorizontal","enableBounce","bounceableProps","nativeBounces","shouldEnableNested","SystemInfo","renderChildren","Array","lazy","item","index","Number","LazyComponent","elementProps","ScrollViewWithBouncesHook","ScrollViewBasic"],"mappings":";;;;;;AAsCO,MAAMA,aAAaC,KAAKC,WAAWC;AAE1C,MAAMC,yBAAiD;IACrD,qBAAqB;IACrB,SAAS;AACX;AAuBA,SAASD,eACPE,KAAsB,EACtBC,IAAiC;IAEjC,MAAM,EACJC,eAAe,YAAY,EAC3BC,aAAa,KAAK,EAClBC,KAAK,EACLC,QAAQ,EACRC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EAAE,EACdC,WAAW,KAAK,EAChBC,YAAY,KAAK,EACjBC,oBAAoB;QAClB,eAAe;QACf,mBAAmB;IACrB,CAAC,EACDC,eAAe,IAAI,EACnBC,sBAAsB,KAAK,EAC3B,eAAeC,iBAAiB,EAChCC,gBAAgB,EAChBC,MAAM,EACNC,4BAA4B,QAAQ,EACpCC,4BAA4B,kBAAkB,EAC9CC,0BAA0B,CAAC,EAC3BC,qBAAqB,EACrBC,+BAA+B,EAC/BC,gCAAgC,EAChCC,gBAAgB,EAChB,uBAAuBC,OAAO,EAC/B,GAAGxB;IACJ,MAAMyB,gBAAgBX,qBACjB,CAACY,6BAA6B;IAEnC,MAAMC,6BAA6BC,OAA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,CAAC4B,eAAevC,UAAU4B,uBAAuB;QACnD,EAAEmB;QAGN,QACGC,gBAAgB,cAAcF,cAAc,QAAQnC,QAAQ;QAC3D,CAAC4B,eAAevC,UAAU4B,uBAAuB;MACnD,EAAEoB;IAEN;IAAO,IACLd,gBACGC,AAAsC,iBAAtCA,gBAAgB,iBAAiB,IACjCA,AAAsC,WAAtCA,gBAAgB,iBAAiB,EAEpC,QACGY,0BACC,cAAcD,cACd,mBAAmBX,iBACnB,UAAU/B,UACV,WAAWC,WACX,QAAQM,QACT;QACC,CAAC4B,eAAevC,UAAU4B,uBAAuB;MACnD,EAAEmB;IAGJ,QACGC,gBAAgB,cAAcF,cAAc,QAAQnC,QAAQ;QAC3D,CAAC4B,eAAevC,UAAU4B,uBAAuB;MACnD,EAAEoB;AAGR"}
|
|
1
|
+
{"version":3,"file":"index.jsx","sources":["../src/index.tsx"],"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 { forwardRef, memo, useRef } from '@lynx-js/react'\nimport type { ForwardedRef, ReactElement, ReactNode } from '@lynx-js/react'\n\nimport '@lynx-js/gesture-runtime'\nimport type { GestureKind } from '@lynx-js/gesture-runtime'\nimport type { LazyOptions } from '@lynx-js/lynx-ui-common'\nimport {\n ExposureEventsMapping,\n LayoutEventsMapping,\n ScrollEventsMapping,\n TouchEventsMapping,\n nativeLynxSDKVersionLessThan,\n useRegisteredEvents,\n} from '@lynx-js/lynx-ui-common'\nimport { LazyComponent } from '@lynx-js/lynx-ui-lazy-component'\nimport type {\n CSSProperties,\n ScrollViewProps as ScrollViewElementProps,\n} from '@lynx-js/types'\n\nimport ScrollViewBasic from './ScrollViewBasic'\nimport ScrollViewWithBouncesHook from './ScrollViewWithBouncesHook'\nimport type {\n BounceableBasicProps,\n ScrollViewProps,\n ScrollViewRef,\n} from './types'\n\nexport type { ScrollViewProps, ScrollViewRef }\nexport { useBounce } from './hooks/useBounce'\nexport type { BounceHandlers, bounceHandlers } from './hooks/useBounce'\nexport type { BounceableBasicProps } from './types'\n\ntype ScrollViewComponent = (props: ScrollViewProps) => ReactElement\n\nexport const ScrollView = memo(\n forwardRef(ScrollViewImpl),\n) as ScrollViewComponent\n\nconst ScrollViewEventMapping: Record<string, string> = {\n onContentSizeChange: 'bindcontentsizechanged',\n onWheel: 'bindwheel',\n}\n\n/**\n * @example\n * ```javascript\n * <ScrollView\n scene={`viewpager_${index1}`}\n style={{ width: '100%', height: '100%' }}\n estimatedItemStyle={{ width: '100%', height: '800px' }}\n scrollOrientation='vertical'\n exposureRight=\"50px\"\n exposureBottom=\"220px\"\n >\n {scrollview.map((item, index) => (\n <view\n style={`width:100%;height:580rpx;`}\n >\n <text>{`slot-${index}`}</text>\n </view>\n ))}\n </ScrollView>\n * ```\n */\nfunction ScrollViewImpl(\n props: ScrollViewProps,\n _ref: ForwardedRef<ScrollViewRef>,\n) {\n const {\n scrollviewId = 'scrollview',\n horizontal = false,\n style,\n children,\n scrollOrientation,\n lazyOptions,\n className = '',\n debugLog = false,\n enableRTL = false,\n bounceableOptions = {\n enableBounces: true,\n singleSidedBounce: 'iOSBounces',\n },\n enableScroll = true,\n enableScrollMonitor = false,\n enableNewArch: enableNewArchProp,\n scrollMonitorTag,\n sticky,\n scrollPropagationBehavior = 'native',\n temporaryBlockScrollClass = 'BDXLynxViewPager',\n temporaryBlockScrollTag = 0,\n temporaryNestedScroll,\n experimentalNestedScrollForward,\n experimentalNestedScrollBackward,\n androidTouchSlop,\n 'main-thread:gesture': gesture,\n } = props\n const enableNewArch = enableNewArchProp\n ?? !nativeLynxSDKVersionLessThan('4.3')\n // generates binding events dynamically\n const scrollViewRegisteredEvents = useRef<Record<string, string>>({\n ...ScrollEventsMapping,\n ...ExposureEventsMapping,\n ...TouchEventsMapping,\n ...LayoutEventsMapping,\n ...ScrollViewEventMapping,\n })\n const normalizedLazyOptions: LazyOptions | undefined = lazyOptions\n ? { firstScreenItemCount: 1, ...lazyOptions }\n : undefined\n const registerEvents = useRegisteredEvents(\n props,\n scrollViewRegisteredEvents.current,\n )\n const normalizedStyle: CSSProperties = {\n zIndex: 0,\n ...style,\n }\n\n const isHorizontal = () => {\n return scrollOrientation ? scrollOrientation === 'horizontal' : horizontal\n }\n\n // Initialize bounceableProps\n let enableBounce = false\n let bounceableProps: BounceableBasicProps = { enableBounces: false }\n if (typeof bounceableOptions === 'boolean') {\n // Initialize the default value if the bounceableOptions is simply 'true' without specific options\n enableBounce = bounceableOptions\n bounceableProps = {\n enableBounces: enableBounce,\n singleSidedBounce: 'both',\n alwaysBouncing: true,\n validAnimationVersion: true,\n }\n } else if (typeof bounceableOptions === 'object') {\n enableBounce = bounceableOptions.enableBounces\n bounceableProps = bounceableOptions\n bounceableProps.singleSidedBounce = bounceableOptions.singleSidedBounce\n ?? 'both'\n bounceableProps.alwaysBouncing = bounceableOptions.alwaysBouncing ?? true\n bounceableProps.validAnimationVersion =\n bounceableOptions.validAnimationVersion ?? true\n }\n // The new architecture provides native bounces on every platform. On the\n // legacy architecture, native bounces are only used for iOSBounces.\n const nativeBounces = enableBounce\n && (enableNewArch\n ? bounceableProps.singleSidedBounce !== 'none'\n : bounceableProps.singleSidedBounce === 'iOSBounces')\n\n const shouldEnableNested = () => {\n if (\n SystemInfo.platform === 'iOS' && scrollPropagationBehavior !== 'propagate'\n ) {\n return false\n }\n return true\n }\n\n const renderChildren = (\n children: ReactNode,\n lazyOptions: LazyOptions | undefined,\n ) => {\n if (!Array.isArray(children)) {\n return children\n }\n const lazy = lazyOptions?.enableLazy\n return children.map((item: ReactNode, index: number) => {\n if (lazy && index >= Number(lazyOptions?.firstScreenItemCount)) {\n return (\n <LazyComponent\n key={`${scrollviewId}_lazy_${index}`}\n scene={lazyOptions?.scene}\n pid={`pid_${index}`}\n estimatedStyle={lazyOptions?.estimatedItemStyle}\n top={lazyOptions?.exposureTop}\n bottom={lazyOptions?.exposureBottom}\n left={lazyOptions?.exposureLeft}\n right={lazyOptions?.exposureRight}\n >\n {item}\n </LazyComponent>\n )\n }\n return item\n })\n }\n\n // These props will be spread directly to <scroll-view> element. Make sure it's valid\n type ExtendedScrollViewElementProps = ScrollViewElementProps & {\n 'scroll-x': boolean\n 'scroll-y': boolean\n 'scroll-orientation'?: 'horizontal' | 'vertical'\n 'scroll-view-new-arch'?: boolean\n }\n const elementProps: ExtendedScrollViewElementProps & {\n 'enable-scroll-monitor': boolean\n 'scroll-monitor-tag'?: string\n 'main-thread:gesture'?: GestureKind\n 'enable-new-nested'?: boolean\n 'enable-nested-scroll'?: boolean\n 'temporary-nested-scroll-forward'?: ScrollViewProps[\n 'experimentalNestedScrollForward'\n ]\n 'temporary-nested-scroll-backward'?: ScrollViewProps[\n 'experimentalNestedScrollBackward'\n ]\n 'force-can-scroll'?: boolean\n 'ios-block-gesture-class'?: string\n 'ios-recognized-view-tag'?: number\n 'className'?: string\n 'style'?: CSSProperties\n 'bounces'?: boolean\n } = {\n 'id': scrollviewId,\n 'scroll-x': isHorizontal(),\n 'scroll-y': !isHorizontal(),\n ...(enableNewArch && {\n 'scroll-orientation': isHorizontal() ? 'horizontal' : 'vertical',\n 'scroll-view-new-arch': true,\n }),\n 'enable-scroll-monitor': enableScrollMonitor,\n 'scroll-monitor-tag': scrollMonitorTag,\n 'main-thread:gesture': gesture,\n 'force-can-scroll': scrollPropagationBehavior === 'preventPropagate',\n 'ios-block-gesture-class': scrollPropagationBehavior === 'preventPropagate'\n ? temporaryBlockScrollClass\n : '',\n 'ios-recognized-view-tag': scrollPropagationBehavior === 'preventPropagate'\n ? temporaryBlockScrollTag\n : 0,\n 'enable-nested-scroll': SystemInfo.platform === 'Android'\n ? (temporaryNestedScroll ?? true)\n : shouldEnableNested(),\n 'enable-new-nested': true,\n 'className': className,\n 'style': normalizedStyle,\n 'bounces': nativeBounces,\n 'enable-scroll': enableScroll,\n ...(androidTouchSlop !== undefined\n && { 'android-touch-slop': androidTouchSlop }),\n ...(experimentalNestedScrollForward !== undefined && {\n 'temporary-nested-scroll-forward': experimentalNestedScrollForward,\n }),\n ...(experimentalNestedScrollBackward !== undefined && {\n 'temporary-nested-scroll-backward': experimentalNestedScrollBackward,\n }),\n ...registerEvents,\n }\n\n if (enableNewArch) {\n if (\n nativeBounces\n && (bounceableProps.upperBounceItem\n || bounceableProps.lowerBounceItem\n || bounceableProps.onScrollToBounces)\n ) {\n return (\n <ScrollViewWithBouncesHook\n elementProps={elementProps}\n bounceableOptions={bounceableProps}\n debugLog={debugLog}\n enableRTL={enableRTL}\n nativeBounces={true}\n sticky={sticky}\n >\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewWithBouncesHook>\n )\n }\n return (\n <ScrollViewBasic elementProps={elementProps} sticky={sticky}>\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewBasic>\n )\n } else if (\n enableBounce\n && bounceableProps.singleSidedBounce !== 'iOSBounces'\n && bounceableProps.singleSidedBounce !== 'none'\n ) {\n return (\n <ScrollViewWithBouncesHook\n elementProps={elementProps}\n bounceableOptions={bounceableProps}\n debugLog={debugLog}\n enableRTL={enableRTL}\n sticky={sticky}\n >\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewWithBouncesHook>\n )\n } else {\n return (\n <ScrollViewBasic elementProps={elementProps} sticky={sticky}>\n {renderChildren(children, normalizedLazyOptions)}\n </ScrollViewBasic>\n )\n }\n}\n"],"names":["ScrollView","memo","forwardRef","ScrollViewImpl","ScrollViewEventMapping","props","_ref","scrollviewId","horizontal","style","children","scrollOrientation","lazyOptions","className","debugLog","enableRTL","bounceableOptions","enableScroll","enableScrollMonitor","enableNewArchProp","scrollMonitorTag","sticky","scrollPropagationBehavior","temporaryBlockScrollClass","temporaryBlockScrollTag","temporaryNestedScroll","experimentalNestedScrollForward","experimentalNestedScrollBackward","androidTouchSlop","gesture","enableNewArch","nativeLynxSDKVersionLessThan","scrollViewRegisteredEvents","useRef","ScrollEventsMapping","ExposureEventsMapping","TouchEventsMapping","LayoutEventsMapping","normalizedLazyOptions","undefined","registerEvents","useRegisteredEvents","normalizedStyle","isHorizontal","enableBounce","bounceableProps","nativeBounces","shouldEnableNested","SystemInfo","renderChildren","Array","lazy","item","index","Number","LazyComponent","elementProps","ScrollViewWithBouncesHook","ScrollViewBasic"],"mappings":";;;;;;AAuCO,MAAMA,aAAaC,KACxBC,WAAWC;AAGb,MAAMC,yBAAiD;IACrD,qBAAqB;IACrB,SAAS;AACX;AAuBA,SAASD,eACPE,KAAsB,EACtBC,IAAiC;IAEjC,MAAM,EACJC,eAAe,YAAY,EAC3BC,aAAa,KAAK,EAClBC,KAAK,EACLC,QAAQ,EACRC,iBAAiB,EACjBC,WAAW,EACXC,YAAY,EAAE,EACdC,WAAW,KAAK,EAChBC,YAAY,KAAK,EACjBC,oBAAoB;QAClB,eAAe;QACf,mBAAmB;IACrB,CAAC,EACDC,eAAe,IAAI,EACnBC,sBAAsB,KAAK,EAC3B,eAAeC,iBAAiB,EAChCC,gBAAgB,EAChBC,MAAM,EACNC,4BAA4B,QAAQ,EACpCC,4BAA4B,kBAAkB,EAC9CC,0BAA0B,CAAC,EAC3BC,qBAAqB,EACrBC,+BAA+B,EAC/BC,gCAAgC,EAChCC,gBAAgB,EAChB,uBAAuBC,OAAO,EAC/B,GAAGxB;IACJ,MAAMyB,gBAAgBX,qBACjB,CAACY,6BAA6B;IAEnC,MAAMC,6BAA6BC,OAA+B;QAChE,GAAGC,mBAAmB;QACtB,GAAGC,qBAAqB;QACxB,GAAGC,kBAAkB;QACrB,GAAGC,mBAAmB;QACtB,GAAGjC,sBAAsB;IAC3B;IACA,MAAMkC,wBAAiD1B,cACnD;QAAE,sBAAsB;QAAG,GAAGA,WAAW;IAAC,IAC1C2B;IACJ,MAAMC,iBAAiBC,oBACrBpC,OACA2B,2BAA2B,OAAO;IAEpC,MAAMU,kBAAiC;QACrC,QAAQ;QACR,GAAGjC,KAAK;IACV;IAEA,MAAMkC,eAAe,IACZhC,oBAAoBA,AAA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,UAAU4B,uBAAuB;MACnD,EAAEmB;IAGJ,QACGC,gBAAgB,cAAcF,cAAc,QAAQnC,QAAQ;QAC3D,CAAC4B,eAAevC,UAAU4B,uBAAuB;MACnD,EAAEoB;AAGR"}
|
|
@@ -2,7 +2,7 @@ import type { ReactElement, ReactNode } from '@lynx-js/react';
|
|
|
2
2
|
import type { BaseGesture } from '@lynx-js/gesture-runtime';
|
|
3
3
|
import type { BaseScrollEvents, BaseUIExposureEvents, BaseUIExposureProps, BaseUILayoutEvents, BaseUITouchEvents, ComponentBasicProps, LazyOptions } from '@lynx-js/lynx-ui-common';
|
|
4
4
|
import type { CSSProperties, CommonEvent } from '@lynx-js/types';
|
|
5
|
-
export type
|
|
5
|
+
export type { BounceHandlers } from '../hooks/useBounce.js';
|
|
6
6
|
type ScrollPropagationBehaviorOption = 'native' | 'propagate' | 'preventPropagate';
|
|
7
7
|
export interface ScrollViewRef {
|
|
8
8
|
}
|
|
@@ -288,7 +288,7 @@ export interface ScrollViewProps extends BaseUITouchEvents, BaseScrollEvents, Ba
|
|
|
288
288
|
*/
|
|
289
289
|
onWheel?: (e: CommonEvent) => void;
|
|
290
290
|
}
|
|
291
|
-
export interface
|
|
291
|
+
export interface ScrollToBouncesInfo {
|
|
292
292
|
direction: 'upper' | 'lower';
|
|
293
293
|
}
|
|
294
294
|
export interface BounceableBasicProps {
|
|
@@ -395,8 +395,7 @@ export interface BounceableBasicProps {
|
|
|
395
395
|
* @Android
|
|
396
396
|
* @Harmony
|
|
397
397
|
*/
|
|
398
|
-
onScrollToBounces?: (e:
|
|
398
|
+
onScrollToBounces?: (e: ScrollToBouncesInfo) => void;
|
|
399
399
|
}
|
|
400
400
|
export declare const ScrollEventMapping: Record<string, string>;
|
|
401
|
-
export {};
|
|
402
401
|
//# sourceMappingURL=index.docs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings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AAG,YAAY,GAAG,MAAM,CAAA;IACtE;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,CAAC,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACrD;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAErD,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types/index.docs.jsx","sources":["../../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, CommonEvent } 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 * Enable the native `<scroll-view>` new architecture. When enabled, `bounceableOptions` uses native bounces on Android, iOS, and Harmony. Defaults to `true` on Lynx SDK 4.3 and newer, and `false` on earlier versions.\n * @zh 启用原生 `<scroll-view>` 新架构。启用后,`bounceableOptions` 会在 Android、iOS 和 Harmony 上使用原生回弹。Lynx SDK 4.3 及以上版本默认为 `true`,更早版本默认为 `false`。\n * @defaultValue `true on Lynx SDK >= 4.3; false otherwise`\n * @Android\n * @iOS\n * @Harmony\n */\n enableNewArch?: 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 * Whether horizontal bounce direction should be mirrored in RTL mode.\n * @zh 是否在 RTL 模式下镜像水平回弹方向。\n * @defaultValue false\n * @Android\n * @iOS\n * @Harmony\n */\n enableRTL?: boolean\n /**\n * Display debug logs for bounce interactions.\n * @zh 显示回弹交互的调试日志。\n * @defaultValue false\n * @Android\n * @iOS\n * @Harmony\n */\n debugLog?: boolean\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 * Adapts Harmony nested scroll behavior. 'selfOnly' scrolls only this component. 'selfFirst' scrolls this component first, then the parent after this component reaches a scroll boundary. 'parentFirst' scrolls the parent first, then this component after the parent reaches a scroll boundary. 'parallel' scrolls this component and the parent at the same time.\n * @zh 适配 Harmony 的嵌套滚动行为。'selfOnly' 表示只自身滚动,不与父组件联动。'selfFirst' 表示自身先滚动,自身滚动到边界以后父组件滚动。'parentFirst' 表示父组件先滚动,父组件滚动到边界以后自身滚动。'parallel' 表示自身和父组件同时滚动。\n * @Harmony\n */\n experimentalNestedScrollForward?:\n | 'selfOnly'\n | 'selfFirst'\n | 'parentFirst'\n | 'parallel'\n\n /**\n * Adapts Harmony nested scroll behavior. 'selfOnly' scrolls only this component. 'selfFirst' scrolls this component first, then the parent after this component reaches a scroll boundary. 'parentFirst' scrolls the parent first, then this component after the parent reaches a scroll boundary. 'parallel' scrolls this component and the parent at the same time.\n * @zh 适配 Harmony 的嵌套滚动行为。'selfOnly' 表示只自身滚动,不与父组件联动。'selfFirst' 表示自身先滚动,自身滚动到边界以后父组件滚动。'parentFirst' 表示父组件先滚动,父组件滚动到边界以后自身滚动。'parallel' 表示自身和父组件同时滚动。\n * @Harmony\n */\n experimentalNestedScrollBackward?:\n | 'selfOnly'\n | 'selfFirst'\n | 'parentFirst'\n | 'parallel'\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 * Send when a wheel event is triggered on the scroll-view.\n * @zh 当 scroll-view 触发滚轮事件时发送。\n * @eventProperty\n * @PC\n * @Web\n */\n onWheel?: (e: CommonEvent) => 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 * 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":"AA0bO,MAAMA,qBAA6C;IACxD,qBAAqB;AACvB"}
|
|
1
|
+
{"version":3,"file":"types/index.docs.jsx","sources":["../../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, CommonEvent } from '@lynx-js/types'\n\nexport type { BounceHandlers } from '../hooks/useBounce'\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// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- expected empty interface\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 * Enable the native `<scroll-view>` new architecture. When enabled, `bounceableOptions` uses native bounces on Android, iOS, and Harmony. Defaults to `true` on Lynx SDK 4.3 and newer, and `false` on earlier versions.\n * @zh 启用原生 `<scroll-view>` 新架构。启用后,`bounceableOptions` 会在 Android、iOS 和 Harmony 上使用原生回弹。Lynx SDK 4.3 及以上版本默认为 `true`,更早版本默认为 `false`。\n * @defaultValue `true on Lynx SDK >= 4.3; false otherwise`\n * @Android\n * @iOS\n * @Harmony\n */\n enableNewArch?: 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 * Whether horizontal bounce direction should be mirrored in RTL mode.\n * @zh 是否在 RTL 模式下镜像水平回弹方向。\n * @defaultValue false\n * @Android\n * @iOS\n * @Harmony\n */\n enableRTL?: boolean\n /**\n * Display debug logs for bounce interactions.\n * @zh 显示回弹交互的调试日志。\n * @defaultValue false\n * @Android\n * @iOS\n * @Harmony\n */\n debugLog?: boolean\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 * Adapts Harmony nested scroll behavior. 'selfOnly' scrolls only this component. 'selfFirst' scrolls this component first, then the parent after this component reaches a scroll boundary. 'parentFirst' scrolls the parent first, then this component after the parent reaches a scroll boundary. 'parallel' scrolls this component and the parent at the same time.\n * @zh 适配 Harmony 的嵌套滚动行为。'selfOnly' 表示只自身滚动,不与父组件联动。'selfFirst' 表示自身先滚动,自身滚动到边界以后父组件滚动。'parentFirst' 表示父组件先滚动,父组件滚动到边界以后自身滚动。'parallel' 表示自身和父组件同时滚动。\n * @Harmony\n */\n experimentalNestedScrollForward?:\n | 'selfOnly'\n | 'selfFirst'\n | 'parentFirst'\n | 'parallel'\n\n /**\n * Adapts Harmony nested scroll behavior. 'selfOnly' scrolls only this component. 'selfFirst' scrolls this component first, then the parent after this component reaches a scroll boundary. 'parentFirst' scrolls the parent first, then this component after the parent reaches a scroll boundary. 'parallel' scrolls this component and the parent at the same time.\n * @zh 适配 Harmony 的嵌套滚动行为。'selfOnly' 表示只自身滚动,不与父组件联动。'selfFirst' 表示自身先滚动,自身滚动到边界以后父组件滚动。'parentFirst' 表示父组件先滚动,父组件滚动到边界以后自身滚动。'parallel' 表示自身和父组件同时滚动。\n * @Harmony\n */\n experimentalNestedScrollBackward?:\n | 'selfOnly'\n | 'selfFirst'\n | 'parentFirst'\n | 'parallel'\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 * Send when a wheel event is triggered on the scroll-view.\n * @zh 当 scroll-view 触发滚轮事件时发送。\n * @eventProperty\n * @PC\n * @Web\n */\n onWheel?: (e: CommonEvent) => 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic value\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic value\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 * 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":"AA0bO,MAAMA,qBAA6C;IACxD,qBAAqB;AACvB"}
|
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.140.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@lynx-js/gesture-runtime": "2.1.1",
|
|
29
|
-
"@lynx-js/lynx-ui-common": "3.
|
|
30
|
-
"@lynx-js/lynx-ui-lazy-component": "3.
|
|
29
|
+
"@lynx-js/lynx-ui-common": "3.139.0",
|
|
30
|
+
"@lynx-js/lynx-ui-lazy-component": "3.140.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@lynx-js/react": "0.123.1",
|
package/src/hooks/useBounce.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { runOnBackground, useMainThreadRef } from '@lynx-js/react'
|
|
|
7
7
|
import { log, mtsLog, selectorMT } from '@lynx-js/lynx-ui-common'
|
|
8
8
|
import type { CommonEvent, MainThread, ScrollEvent } from '@lynx-js/types'
|
|
9
9
|
|
|
10
|
-
export interface
|
|
10
|
+
export interface ScrollToBouncesInfo {
|
|
11
11
|
direction: 'upper' | 'lower'
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -16,16 +16,16 @@ export interface BounceableBasicProps {
|
|
|
16
16
|
enableBounceEventInFling?: boolean
|
|
17
17
|
startBounceTriggerDistance?: number
|
|
18
18
|
endBounceTriggerDistance?: number
|
|
19
|
-
//
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic callback
|
|
20
20
|
upperBounceItem?: any
|
|
21
|
-
//
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic callback
|
|
22
22
|
lowerBounceItem?: any
|
|
23
23
|
alwaysBouncing?: boolean
|
|
24
24
|
singleSidedBounce?: 'upper' | 'lower' | 'both' | 'iOSBounces' | 'none'
|
|
25
25
|
estimatedHeight?: number
|
|
26
26
|
estimatedWidth?: number
|
|
27
27
|
validAnimationVersion?: boolean
|
|
28
|
-
onScrollToBounces?: (e:
|
|
28
|
+
onScrollToBounces?: (e: ScrollToBouncesInfo) => void
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface useBounceOptions {
|
|
@@ -42,7 +42,7 @@ export interface useBounceOptions {
|
|
|
42
42
|
scrollOrientation: 'vertical' | 'horizontal'
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export interface
|
|
45
|
+
export interface BounceHandlers {
|
|
46
46
|
'main-thread:bindtouchstart': (event: MainThread.TouchEvent) => void
|
|
47
47
|
'main-thread:bindtouchend': () => void
|
|
48
48
|
'main-thread:bindtouchmove': (event: MainThread.TouchEvent) => void
|
|
@@ -54,7 +54,10 @@ export interface bounceHandlers {
|
|
|
54
54
|
onLowerDisexposure: (_event: CommonEvent) => void
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
/** @deprecated Use `BounceHandlers` instead. */
|
|
58
|
+
export type bounceHandlers = BounceHandlers
|
|
59
|
+
|
|
60
|
+
export function useBounce(options: useBounceOptions): BounceHandlers {
|
|
58
61
|
// Control the damping coefficient during rubber effect. The smaller it is, the harder the spring effect.
|
|
59
62
|
const rubberC = useMainThreadRef(0.55)
|
|
60
63
|
// Control the fling deceleration coefficient during dropdown. The smaller it is, the faster it stops.
|
|
@@ -278,7 +281,7 @@ export function useBounce(options: useBounceOptions): bounceHandlers {
|
|
|
278
281
|
// Use translate to implement real bouncing effect
|
|
279
282
|
function bouncingSetStyle(offset: number) {
|
|
280
283
|
'main thread'
|
|
281
|
-
if (isNaN(Number(offset))) {
|
|
284
|
+
if (Number.isNaN(Number(offset))) {
|
|
282
285
|
mtsLog(
|
|
283
286
|
true,
|
|
284
287
|
'[lynx-ui-scroll-view][useBounce] ERROR! bouncingOffset is NaN',
|
|
@@ -351,7 +354,7 @@ export function useBounce(options: useBounceOptions): bounceHandlers {
|
|
|
351
354
|
}
|
|
352
355
|
}
|
|
353
356
|
|
|
354
|
-
function onScrollToBouncesJS(info:
|
|
357
|
+
function onScrollToBouncesJS(info: ScrollToBouncesInfo) {
|
|
355
358
|
if (enableBounces && onScrollToBounces) {
|
|
356
359
|
onScrollToBounces(info)
|
|
357
360
|
}
|
|
@@ -367,7 +370,7 @@ export function useBounce(options: useBounceOptions): bounceHandlers {
|
|
|
367
370
|
}`,
|
|
368
371
|
)
|
|
369
372
|
|
|
370
|
-
const info:
|
|
373
|
+
const info: ScrollToBouncesInfo = {
|
|
371
374
|
direction: isUpper ? 'upper' : 'lower',
|
|
372
375
|
}
|
|
373
376
|
runOnBackground(onScrollToBouncesJS)(info)
|
|
@@ -7,7 +7,7 @@ import { runOnBackground, useMainThreadRef } from '@lynx-js/react'
|
|
|
7
7
|
import { mtsLog, selectorMT } from '@lynx-js/lynx-ui-common'
|
|
8
8
|
import type { CommonEvent, ScrollEvent } from '@lynx-js/types'
|
|
9
9
|
|
|
10
|
-
import type { BounceableBasicProps,
|
|
10
|
+
import type { BounceableBasicProps, ScrollToBouncesInfo } from '../types'
|
|
11
11
|
import { getNativeBounceMetricsMT } from './nativeBounceUtils'
|
|
12
12
|
|
|
13
13
|
interface UseNativeBounceOptions {
|
|
@@ -74,7 +74,7 @@ export function useNativeBounce(
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
function onScrollToBouncesJS(info:
|
|
77
|
+
function onScrollToBouncesJS(info: ScrollToBouncesInfo) {
|
|
78
78
|
options.bounceableOptions.onScrollToBounces?.(info)
|
|
79
79
|
}
|
|
80
80
|
|
package/src/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// LICENSE file in the root directory of this source tree.
|
|
4
4
|
|
|
5
5
|
import { forwardRef, memo, useRef } from '@lynx-js/react'
|
|
6
|
-
import type { ForwardedRef, ReactNode } from '@lynx-js/react'
|
|
6
|
+
import type { ForwardedRef, ReactElement, ReactNode } from '@lynx-js/react'
|
|
7
7
|
|
|
8
8
|
import '@lynx-js/gesture-runtime'
|
|
9
9
|
import type { GestureKind } from '@lynx-js/gesture-runtime'
|
|
@@ -28,15 +28,18 @@ import type {
|
|
|
28
28
|
BounceableBasicProps,
|
|
29
29
|
ScrollViewProps,
|
|
30
30
|
ScrollViewRef,
|
|
31
|
-
ScrollView as ScrollViewType,
|
|
32
31
|
} from './types'
|
|
33
32
|
|
|
34
33
|
export type { ScrollViewProps, ScrollViewRef }
|
|
35
34
|
export { useBounce } from './hooks/useBounce'
|
|
36
|
-
export type { bounceHandlers } from './hooks/useBounce'
|
|
35
|
+
export type { BounceHandlers, bounceHandlers } from './hooks/useBounce'
|
|
37
36
|
export type { BounceableBasicProps } from './types'
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
type ScrollViewComponent = (props: ScrollViewProps) => ReactElement
|
|
39
|
+
|
|
40
|
+
export const ScrollView = memo(
|
|
41
|
+
forwardRef(ScrollViewImpl),
|
|
42
|
+
) as ScrollViewComponent
|
|
40
43
|
|
|
41
44
|
const ScrollViewEventMapping: Record<string, string> = {
|
|
42
45
|
onContentSizeChange: 'bindcontentsizechanged',
|
package/src/types/index.docs.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type {
|
|
|
16
16
|
} from '@lynx-js/lynx-ui-common'
|
|
17
17
|
import type { CSSProperties, CommonEvent } from '@lynx-js/types'
|
|
18
18
|
|
|
19
|
-
export type
|
|
19
|
+
export type { BounceHandlers } from '../hooks/useBounce'
|
|
20
20
|
|
|
21
21
|
type ScrollPropagationBehaviorOption =
|
|
22
22
|
| 'native' // Follows platform default behavior
|
|
@@ -24,7 +24,7 @@ type ScrollPropagationBehaviorOption =
|
|
|
24
24
|
// | 'propagateAtEdge' // @todo Child scrolls first; parent scrolls on next touch at edge
|
|
25
25
|
| 'preventPropagate' // Never allow scroll propagation
|
|
26
26
|
|
|
27
|
-
//
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- expected empty interface
|
|
28
28
|
export interface ScrollViewRef {}
|
|
29
29
|
|
|
30
30
|
export interface ScrollViewProps
|
|
@@ -327,7 +327,7 @@ export interface ScrollViewProps
|
|
|
327
327
|
onWheel?: (e: CommonEvent) => void
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
export interface
|
|
330
|
+
export interface ScrollToBouncesInfo {
|
|
331
331
|
direction: 'upper' | 'lower'
|
|
332
332
|
}
|
|
333
333
|
|
|
@@ -374,7 +374,7 @@ export interface BounceableBasicProps {
|
|
|
374
374
|
* @Android
|
|
375
375
|
* @Harmony
|
|
376
376
|
*/
|
|
377
|
-
//
|
|
377
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic value
|
|
378
378
|
upperBounceItem?: any
|
|
379
379
|
/**
|
|
380
380
|
* Content of lower bounces view, which will be displayed during the lower bouncing effect.
|
|
@@ -383,7 +383,7 @@ export interface BounceableBasicProps {
|
|
|
383
383
|
* @Android
|
|
384
384
|
* @Harmony
|
|
385
385
|
*/
|
|
386
|
-
//
|
|
386
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- expected dynamic value
|
|
387
387
|
lowerBounceItem?: any
|
|
388
388
|
/**
|
|
389
389
|
* Whether the scrollable container can bounce when the content area of the scrollable container is smaller than the viewport area.
|
|
@@ -437,7 +437,7 @@ export interface BounceableBasicProps {
|
|
|
437
437
|
* @Android
|
|
438
438
|
* @Harmony
|
|
439
439
|
*/
|
|
440
|
-
onScrollToBounces?: (e:
|
|
440
|
+
onScrollToBounces?: (e: ScrollToBouncesInfo) => void
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
export const ScrollEventMapping: Record<string, string> = {
|