@lynx-js/lynx-ui-scroll-view 3.140.1 → 3.142.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-scroll-view
|
|
2
2
|
|
|
3
|
+
## 3.142.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Accept React 18 and newer types. ReactLynx still defines the compatible versions for each app. ([#383](https://github.com/lynx-family/lynx-ui/pull/383))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`49cb3c5`](https://github.com/lynx-family/lynx-ui/commit/49cb3c5b20d9346ff0f8b314367b4c8e354d195d)]:
|
|
10
|
+
- @lynx-js/lynx-ui-common@3.142.0
|
|
11
|
+
- @lynx-js/lynx-ui-lazy-component@3.142.0
|
|
12
|
+
|
|
3
13
|
## 3.140.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -16,7 +16,7 @@ export interface BounceableBasicProps {
|
|
|
16
16
|
validAnimationVersion?: boolean;
|
|
17
17
|
onScrollToBounces?: (e: ScrollToBouncesInfo) => void;
|
|
18
18
|
}
|
|
19
|
-
export interface
|
|
19
|
+
export interface UseBounceOptions {
|
|
20
20
|
bounceableOptions: BounceableBasicProps;
|
|
21
21
|
debugLog?: boolean;
|
|
22
22
|
enableRTL?: boolean;
|
|
@@ -42,5 +42,5 @@ export interface BounceHandlers {
|
|
|
42
42
|
}
|
|
43
43
|
/** @deprecated Use `BounceHandlers` instead. */
|
|
44
44
|
export type bounceHandlers = BounceHandlers;
|
|
45
|
-
export declare function useBounce(options:
|
|
45
|
+
export declare function useBounce(options: UseBounceOptions): BounceHandlers;
|
|
46
46
|
//# sourceMappingURL=useBounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBounce.d.ts","sourceRoot":"","sources":["../../src/hooks/useB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AAC,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,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,KAAK,IAAI,CAAA;IACpE,0BAA0B,EAAE,MAAM,IAAI,CAAA;IACtC,2BAA2B,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,KAAK,IAAI,CAAA;IACnE,8BAA8B,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IAC5D,wBAAwB,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACtD,eAAe,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IAC9C,kBAAkB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IACjD,eAAe,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IAC9C,kBAAkB,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;CAClD;AAED,gDAAgD;AAEhD,MAAM,MAAM,cAAc,GAAG,cAAc,CAAA;AAE3C,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,cAAc,CA0yBnE"}
|
|
@@ -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 // 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,iB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B,oBAAoB9D,aAAa;wBAC5ChB,+BAA+B,OAAO,GAAG;wBACzC4B,OACE9C,iBACA;wBAEF8C,OACE9C,iBACA;wBAEFmF;oBACF,OAAO;wBAEL,MAAMe,WAAYF,kBACbrB,CAAAA,KAAK,GAAG,CACT7E,sBAAsB,OAAO,EAC7B+D,KAAK,GAAG,KAAKwB,aAEX,KACFV,KAAK,GAAG,CAAC7E,sBAAsB,OAAO;wBAC1C4D,iBAAiB,CAACwC;wBAClB,IAAI,CAACS,4BAA4B3B,yBAAyB;4BACxDb,4BAEE7D,qBAAqB,OAAO,EAAE,iBAAiB;4BAEjDqG,2BAA2B;wBAC7B;wBACAX,kBAAkBO,WACd5B,KAAK,GAAG,CAAC7E,sBAAsB,OAAO,EAAE+D,KAAK,GAAG,KAAKwB;wBACzD,IAAInE,gCACF6B,4BAA4B6D;oBAEhC;gBACF;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
|
+
{"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. */\n// eslint-disable-next-line @typescript-eslint/naming-convention -- Preserve the deprecated public alias for compatibility.\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":";;AA4DO,SAASA,UAAUC,OAAyB;IAEjD,MAAMC,UAAUC,iBAAiB;IAEjC,MAAMC,wBAA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roll-view",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.142.0",
|
|
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.142.0",
|
|
30
|
+
"@lynx-js/lynx-ui-lazy-component": "3.142.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@lynx-js/react": "0.123.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"@lynx-js/react": ">=0.100.0",
|
|
41
41
|
"@lynx-js/types": "*",
|
|
42
|
-
"@types/react": "
|
|
42
|
+
"@types/react": ">=18"
|
|
43
43
|
},
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
package/src/hooks/useBounce.tsx
CHANGED
|
@@ -28,7 +28,7 @@ export interface BounceableBasicProps {
|
|
|
28
28
|
onScrollToBounces?: (e: ScrollToBouncesInfo) => void
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export interface
|
|
31
|
+
export interface UseBounceOptions {
|
|
32
32
|
bounceableOptions: BounceableBasicProps
|
|
33
33
|
debugLog?: boolean
|
|
34
34
|
enableRTL?: boolean
|
|
@@ -55,9 +55,10 @@ export interface BounceHandlers {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** @deprecated Use `BounceHandlers` instead. */
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention -- Preserve the deprecated public alias for compatibility.
|
|
58
59
|
export type bounceHandlers = BounceHandlers
|
|
59
60
|
|
|
60
|
-
export function useBounce(options:
|
|
61
|
+
export function useBounce(options: UseBounceOptions): BounceHandlers {
|
|
61
62
|
// Control the damping coefficient during rubber effect. The smaller it is, the harder the spring effect.
|
|
62
63
|
const rubberC = useMainThreadRef(0.55)
|
|
63
64
|
// Control the fling deceleration coefficient during dropdown. The smaller it is, the faster it stops.
|