@lynx-js/lynx-ui-swiper 3.135.1 → 3.135.4

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/Swiper/index.jsx.map +1 -1
  3. package/dist/Swiper/styles.css.map +1 -1
  4. package/dist/SwiperItem/index.jsx.map +1 -1
  5. package/dist/const/index.jsx.map +1 -1
  6. package/dist/hooks/useAnimate.jsx.map +1 -1
  7. package/dist/hooks/useAutoPlay.jsx.map +1 -1
  8. package/dist/hooks/useAxisLock.jsx.map +1 -1
  9. package/dist/hooks/useBounceConfig.jsx.map +1 -1
  10. package/dist/hooks/useBounceView.jsx.map +1 -1
  11. package/dist/hooks/useChange.jsx.map +1 -1
  12. package/dist/hooks/useDirection.jsx.map +1 -1
  13. package/dist/hooks/useFirstScreenStyle.jsx +2 -1
  14. package/dist/hooks/useFirstScreenStyle.jsx.map +1 -1
  15. package/dist/hooks/useModeConfig.jsx.map +1 -1
  16. package/dist/hooks/useOffset.d.ts.map +1 -1
  17. package/dist/hooks/useOffset.jsx +6 -16
  18. package/dist/hooks/useOffset.jsx.map +1 -1
  19. package/dist/hooks/useOffsetLimit.jsx.map +1 -1
  20. package/dist/hooks/useReset.jsx.map +1 -1
  21. package/dist/hooks/useSwipeCallback.jsx.map +1 -1
  22. package/dist/hooks/useVelocity.jsx.map +1 -1
  23. package/dist/hooks/useVelocity_experiment.jsx.map +1 -1
  24. package/dist/index.jsx +2 -3
  25. package/dist/store/index.jsx.map +1 -1
  26. package/dist/types/index.docs.jsx +1 -0
  27. package/dist/types/index.jsx.map +1 -1
  28. package/dist/utils/animate.jsx.map +1 -1
  29. package/dist/utils/compareProps.jsx.map +1 -1
  30. package/dist/utils/customRound.jsx.map +1 -1
  31. package/dist/utils/index.d.ts +6 -1
  32. package/dist/utils/index.d.ts.map +1 -1
  33. package/dist/utils/index.jsx +20 -1
  34. package/dist/utils/index.jsx.map +1 -1
  35. package/package.json +7 -7
  36. package/src/hooks/useOffset.ts +9 -18
  37. package/src/utils/index.ts +37 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @lynx-js/lynx-ui-swiper
2
2
 
3
+ ## 3.135.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Upgrade the Lynx and Rsbuild toolchain dependencies used to build lynx-ui packages. ([#233](https://github.com/lynx-family/lynx-ui/pull/233))
8
+
9
+ - Updated dependencies [[`753556b`](https://github.com/lynx-family/lynx-ui/commit/753556bc1acb77e05567aba3b8b5ab057b9f670b)]:
10
+ - @lynx-js/lynx-ui-common@3.135.4
11
+
12
+ ## 3.135.3
13
+
14
+ ### Patch Changes
15
+
16
+ - Update `@lynx-js/react-use` to 0.2.2. ([#228](https://github.com/lynx-family/lynx-ui/pull/228))
17
+
18
+ - Prevent a looped swiper from exposing blank space or settling outside the rendered items after a long drag. ([#230](https://github.com/lynx-family/lynx-ui/pull/230))
19
+
20
+ - Updated dependencies [[`44c1de6`](https://github.com/lynx-family/lynx-ui/commit/44c1de68cf47e03c5136431a9efea7cbee69e752)]:
21
+ - @lynx-js/lynx-ui-common@3.135.3
22
+
3
23
  ## 3.135.1
4
24
 
5
25
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"Swiper/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/Swiper/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 {\n forwardRef,\n memo,\n useImperativeHandle,\n useMainThreadRef,\n useMemo,\n} from '@lynx-js/react'\nimport type { ForwardedRef } from '@lynx-js/react'\n\nimport { useTouchEmulation } from '@lynx-js/react-use'\nimport type { MainThread } from '@lynx-js/types'\n\nimport { LOOP_COUNT } from '../const'\nimport { useBounceConfig } from '../hooks/useBounceConfig'\nimport { useBounceView } from '../hooks/useBounceView'\nimport { useChange } from '../hooks/useChange'\nimport useFirstScreenStyle, {\n getInnerContainerWidthMT,\n} from '../hooks/useFirstScreenStyle'\nimport { useModeConfig } from '../hooks/useModeConfig'\nimport { useOffset } from '../hooks/useOffset'\nimport { useOffsetLimit } from '../hooks/useOffsetLimit'\nimport { useReset } from '../hooks/useReset'\nimport { SwiperContext, SwiperItemContext } from '../store'\nimport type {\n SwipeDirection,\n SwiperProps,\n SwiperRef,\n UpdateSwiperInnerContainerOptions,\n} from '../types'\nimport { easeOut } from '../utils'\nimport { comparePropsWithObject } from '../utils/compareProps'\n\nimport './styles.css'\n\n/**\n * Swiper Component\n */\nconst Swiper = forwardRef(\n <T,>(\n {\n data = [],\n itemWidth,\n containerWidth = lynx.__globalProps.screenWidth\n ?? SystemInfo.pixelWidth / SystemInfo.pixelRatio,\n loop = false,\n mode,\n autoPlay = false,\n autoPlayInterval = 2000,\n duration = 500,\n itemHeight = 'auto',\n initialIndex = 0,\n onChange,\n onSwipeStart,\n onSwipeStop,\n modeConfig: _modeConfig,\n offsetLimit: _offsetLimit,\n bounceConfig,\n children,\n 'main-thread:easing': easing = easeOut,\n 'main-thread:customAnimation': customAnimation,\n 'main-thread:onOffsetChange': onOffsetChange,\n customAnimationFirstScreen,\n swiperKey,\n resetOnReuse,\n trackStyle = {},\n style = {},\n loopDuplicateCount: rawLoopDuplicateCount = LOOP_COUNT,\n experimentalHorizontalSwipeOnly = false,\n consumeSlideEvent = [\n [-180, -135],\n [-45, 45],\n [135, 180],\n ],\n blockNativeEvent = false,\n RTL = false,\n }: SwiperProps<T> & { experimentalHorizontalSwipeOnly?: boolean },\n ref: ForwardedRef<SwiperRef>,\n ) => {\n const dataCount = data.length\n\n const loopDuplicateCount = Math.min(rawLoopDuplicateCount, dataCount)\n\n const containerRef = useMainThreadRef<MainThread.Element>(null)\n const childrenMapRef = useMainThreadRef<Record<number, MainThread.Element>>(\n {},\n )\n const { modeConfig, spaceBetween } = useModeConfig({\n mode,\n modeConfig: _modeConfig,\n })\n const offsetLimit = useOffsetLimit({\n offsetLimit: _offsetLimit,\n loop,\n itemWidth,\n containerWidth,\n modeConfig,\n dataCount,\n spaceBetween,\n })\n\n const {\n enableBounce,\n startBounceItem,\n endBounceItem,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n } = useBounceConfig(bounceConfig)\n\n function setChildrenRef(refI: MainThread.Element, key: number) {\n 'main thread'\n childrenMapRef.current[key] = refI\n }\n\n const contextValue = useMemo(\n () => ({\n loop,\n itemWidth,\n itemHeight,\n setChildrenRef,\n modeConfig,\n initialIndex,\n customAnimationFirstScreen,\n spaceBetween,\n RTL,\n }),\n [loop, itemWidth, itemHeight, spaceBetween, RTL],\n )\n\n const { setChangeOffset, setChangeSwipeStartMT, setChangeSwipeStopMT } =\n useChange({\n onChange,\n size: itemWidth,\n spaceBetween,\n containerWidth,\n dataCount,\n modeConfig,\n offsetLimit,\n onSwipeStart,\n onSwipeStop,\n 'main-thread:onOffsetChange': onOffsetChange,\n })\n\n function setOffset(offset: number) {\n 'main thread'\n const container = containerRef.current\n if (container) {\n container.setStyleProperties({\n transform: `translate(${offset}px, 0)`,\n transition: 'none',\n })\n }\n }\n\n function updateSwiperInnerContainerSizeMT(\n updateOptions: UpdateSwiperInnerContainerOptions,\n ) {\n 'main thread'\n const container = containerRef.current\n if (container) {\n const width = getInnerContainerWidthMT(updateOptions)\n // These values should get from function params, instead of closure, to make it is updated\n const {\n loop: _loop,\n loopDuplicateCount: _loopDuplicateCount,\n itemWidth: _itemWidth,\n spaceBetween: _spaceBetween,\n itemHeight: _itemHeight,\n } = updateOptions\n\n if (updateOptions.mode === 'custom') {\n // @ts-expect-error CSS types accepting number\n container.setStyleProperties({\n ...trackStyle,\n height: `${_itemHeight}px`,\n })\n } else {\n const insetInlineStartKey = RTL ? 'inset-inline-start' : 'left'\n // @ts-expect-error CSS types accepting number\n container.setStyleProperties({\n ...trackStyle,\n [insetInlineStartKey]: _loop\n ? `${-_loopDuplicateCount * (_itemWidth + _spaceBetween)}px`\n : '0px',\n width,\n height: `${_itemHeight}px`,\n })\n }\n }\n }\n\n function onChildrenOffsetUpdate(offset: number) {\n 'main thread'\n const startCount = loop ? -loopDuplicateCount : 0\n const endCount = loop ? dataCount + loopDuplicateCount : dataCount\n for (let i = startCount; i < endCount; i++) {\n const child = childrenMapRef.current[i]\n const childOffset = offset + i * (itemWidth + spaceBetween)\n if (!customAnimation || !child) {\n return\n }\n const childStyles =\n customAnimation(childOffset / (itemWidth + spaceBetween), i)\n || {}\n child.setStyleProperties(childStyles as Record<string, string>)\n }\n }\n\n function onOffsetUpdate(offset: number, direction: SwipeDirection) {\n 'main thread'\n if (modeConfig.mode === 'normal') {\n let effectiveOffset = offset\n if (modeConfig.align === 'center') {\n effectiveOffset = offset + (containerWidth - itemWidth) / 2\n } else if (modeConfig.align === 'end') {\n effectiveOffset = offset + containerWidth - itemWidth\n }\n setOffset(RTL ? -effectiveOffset : effectiveOffset)\n onChildrenOffsetUpdate(offset)\n } else {\n onChildrenOffsetUpdate(offset)\n }\n setChangeOffset(offset, direction)\n }\n\n function onSwipeStartMT() {\n 'main thread'\n setChangeSwipeStartMT()\n }\n\n function onSwipeStopMT() {\n 'main thread'\n setChangeSwipeStopMT()\n }\n\n // `containerStyle` is only used at firstScreen\n // After that, we use MTS to update styles imperatively\n const { containerStyle } = useFirstScreenStyle({\n itemWidth,\n containerWidth,\n loop,\n initialIndex,\n dataCount,\n modeConfig,\n itemHeight,\n offsetLimit,\n loopDuplicateCount,\n RTL,\n spaceBetween,\n swiperKey,\n trackStyle,\n })\n\n const {\n handleTouchMove,\n handleTouchStart,\n handleTouchEnd,\n swipeNext,\n swipePrev,\n swipeTo,\n resetOffsetMT,\n cancelAnimationJS,\n startAutoPlayMT,\n } = useOffset(\n {\n autoPlay,\n autoPlayInterval,\n loop,\n size: itemWidth,\n spaceBetween,\n dataCount,\n duration,\n easing,\n offsetLimit,\n initialIndex,\n modeConfig,\n containerWidth,\n enableBounce,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n experimentalHorizontalSwipeOnly,\n onSwipeStartMT,\n onSwipeStopMT,\n consumeSlideEvent,\n RTL,\n },\n onOffsetUpdate,\n )\n\n const { setContainerRef } = useReset({\n swiperKey,\n itemHeight,\n itemWidth,\n containerWidth,\n loop,\n dataCount,\n modeConfig,\n resetOffsetMT,\n resetOnReuse,\n initialIndex,\n loopDuplicateCount,\n updateSwiperInnerContainerSizeMT,\n startAutoPlayMT,\n spaceBetween,\n })\n\n const touchHandlers = useTouchEmulation({\n onTouchCancelMT: handleTouchEnd,\n onTouchEndMT: handleTouchEnd,\n onTouchMoveMT: handleTouchMove,\n onTouchStartMT: handleTouchStart,\n })\n\n useImperativeHandle(ref, () => ({\n swipeNext,\n swipePrev,\n swipeTo,\n cancelAnimation: cancelAnimationJS,\n }))\n\n function renderSwiperItem(props: {\n item: T\n index: number\n realIndex: number\n }) {\n return (\n <SwiperItemContext.Provider\n key={props.realIndex}\n value={{\n index: props.index,\n realIndex: props.realIndex,\n }}\n >\n {children(props)}\n </SwiperItemContext.Provider>\n )\n }\n\n const { bounceStartView, bounceEndView } = useBounceView({\n startBounceItem,\n endBounceItem,\n loop,\n mode: modeConfig.mode,\n itemWidth,\n count: dataCount,\n RTL,\n containerWidth,\n })\n\n return (\n <SwiperContext.Provider value={contextValue}>\n <view\n class='swiper-root'\n style={{\n ...style,\n width: `${containerWidth}px`,\n height: `${itemHeight}px`,\n direction: RTL === 'lynx-rtl' ? 'lynx-rtl' : (RTL ? 'rtl' : 'ltr'),\n }}\n {...touchHandlers}\n consume-slide-event={consumeSlideEvent}\n block-native-event={blockNativeEvent}\n >\n <view\n class='swiper-track'\n style={containerStyle}\n ref={setContainerRef}\n main-thread:ref={containerRef}\n implicit-animation='false'\n >\n {bounceStartView}\n {loop\n ? (\n <>\n {Array.from(\n { length: loopDuplicateCount },\n (_, i) => loopDuplicateCount - i - 1,\n ).map((i) =>\n renderSwiperItem({\n index: data.length - i - 1,\n item: data[data.length - i - 1],\n realIndex: -i - 1,\n })\n )}\n </>\n )\n : null}\n {data.map((item: T, index: number) =>\n renderSwiperItem({\n index,\n item,\n realIndex: index,\n })\n )}\n {loop\n ? (\n <>\n {Array.from({ length: loopDuplicateCount }, (_, i) => i).map((\n i,\n ) =>\n renderSwiperItem({\n index: i,\n item: data[i],\n realIndex: data.length + i,\n })\n )}\n </>\n )\n : null}\n {bounceEndView}\n </view>\n </view>\n </SwiperContext.Provider>\n )\n },\n)\n\nconst MemoizedSwiper = memo(\n Swiper,\n (prevProps, nextProps) =>\n comparePropsWithObject(prevProps, nextProps, ['modeConfig', 'bounces']),\n) as typeof Swiper\n\nexport { MemoizedSwiper as Swiper }\n"],"names":["Swiper","forwardRef","data","itemWidth","containerWidth","lynx","SystemInfo","loop","mode","autoPlay","autoPlayInterval","duration","itemHeight","initialIndex","onChange","onSwipeStart","onSwipeStop","_modeConfig","_offsetLimit","bounceConfig","children","easing","easeOut","customAnimation","onOffsetChange","customAnimationFirstScreen","swiperKey","resetOnReuse","trackStyle","style","rawLoopDuplicateCount","LOOP_COUNT","experimentalHorizontalSwipeOnly","consumeSlideEvent","blockNativeEvent","RTL","ref","dataCount","loopDuplicateCount","Math","containerRef","useMainThreadRef","childrenMapRef","modeConfig","spaceBetween","useModeConfig","offsetLimit","useOffsetLimit","enableBounce","startBounceItem","endBounceItem","startBounceItemWidth","endBounceItemWidth","onStartBounceItemBounce","onEndBounceItemBounce","useBounceConfig","setChildrenRef","refI","key","contextValue","useMemo","setChangeOffset","setChangeSwipeStartMT","setChangeSwipeStopMT","useChange","setOffset","offset","container","updateSwiperInnerContainerSizeMT","updateOptions","width","getInnerContainerWidthMT","_loop","_loopDuplicateCount","_itemWidth","_spaceBetween","_itemHeight","insetInlineStartKey","onChildrenOffsetUpdate","startCount","endCount","i","child","childOffset","childStyles","onOffsetUpdate","direction","effectiveOffset","onSwipeStartMT","onSwipeStopMT","containerStyle","useFirstScreenStyle","handleTouchMove","handleTouchStart","handleTouchEnd","swipeNext","swipePrev","swipeTo","resetOffsetMT","cancelAnimationJS","startAutoPlayMT","useOffset","setContainerRef","useReset","touchHandlers","useTouchEmulation","useImperativeHandle","renderSwiperItem","props","SwiperItemContext","bounceStartView","bounceEndView","useBounceView","SwiperContext","view","Array","_","item","index","MemoizedSwiper","memo","prevProps","nextProps","comparePropsWithObject"],"mappings":";;;;;;;;;;;;;;;AA0CA,MAAMA,SAASC,WACb,CACE,EACEC,OAAO,EAAE,EACTC,SAAS,EACTC,iBAAiBC,KAAK,aAAa,CAAC,WAAW,IAC1CC,WAAW,UAAU,GAAGA,WAAW,UAAU,EAClDC,OAAO,KAAK,EACZC,IAAI,EACJC,WAAW,KAAK,EAChBC,mBAAmB,IAAI,EACvBC,WAAW,GAAG,EACdC,aAAa,MAAM,EACnBC,eAAe,CAAC,EAChBC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACX,YAAYC,WAAW,EACvB,aAAaC,YAAY,EACzBC,YAAY,EACZC,QAAQ,EACR,sBAAsBC,SAASC,OAAO,EACtC,+BAA+BC,eAAe,EAC9C,8BAA8BC,cAAc,EAC5CC,0BAA0B,EAC1BC,SAAS,EACTC,YAAY,EACZC,aAAa,CAAC,CAAC,EACfC,QAAQ,CAAC,CAAC,EACV,oBAAoBC,wBAAwBC,UAAU,EACtDC,kCAAkC,KAAK,EACvCC,oBAAoB;IAClB;QAAC;QAAM;KAAK;IACZ;QAAC;QAAK;KAAG;IACT;QAAC;QAAK;KAAI;CACX,EACDC,mBAAmB,KAAK,EACxBC,MAAM,KAAK,EACoD,EACjEC;IAEA,MAAMC,YAAYnC,KAAK,MAAM;IAE7B,MAAMoC,qBAAqBC,KAAK,GAAG,CAACT,uBAAuBO;IAE3D,MAAMG,eAAeC,iBAAqC;IAC1D,MAAMC,iBAAiBD,iBACrB,CAAC;IAEH,MAAM,EAAEE,UAAU,EAAEC,YAAY,EAAE,GAAGC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AAC;QACzB,WAAWuB,AAAQ,eAARA,MAAqB,aAAcA,MAAM,QAAQ;IAC9D,IACC,GAAGqE,aAAa,EACjB,qBAAqBvE,mBACrB,oBAAoBC,kBACrB;UACC,CAACgF,KACC,MAAM,eACN,OAAOxB,gBACP,KAAKY,iBACL,YAAY,KAAK9D,cACjB,mBAAmB,QACpB;YACC,CAACsE,gBAAgB;YACjB,CAACvG,SAEK;kBACA,CAAC4G,MAAM,IAAI,CACT;QAAE,QAAQ7E;IAAmB,GAC7B,CAAC8E,GAAGnC,IAAM3C,qBAAqB2C,IAAI,GACnC,GAAG,CAAC,CAACA,IACL0B,iBAAiB;YACf,OAAOzG,KAAK,MAAM,GAAG+E,IAAI;YACzB,MAAM/E,IAAI,CAACA,KAAK,MAAM,GAAG+E,IAAI,EAAE;YAC/B,WAAW,CAACA,IAAI;QAClB,IACA;gBACJ,MAEA,KAAK;YACT,CAAC/E,KAAK,GAAG,CAAC,CAACmH,MAASC,QAClBX,iBAAiB;YACfW;YACAD;YACA,WAAWC;QACb,IACA;YACF,CAAC/G,SAEK;kBACA,CAAC4G,MAAM,IAAI,CAAC;QAAE,QAAQ7E;IAAmB,GAAG,CAAC8E,GAAGnC,IAAMA,GAAG,GAAG,CAAC,CAC3DA,IAEA0B,iBAAiB;YACf,OAAO1B;YACP,MAAM/E,IAAI,CAAC+E,EAAE;YACb,WAAW/E,KAAK,MAAM,GAAG+E;QAC3B,IACA;gBACJ,MAEA,KAAK;YACT,CAAC8B,cAAc;UACjB,EAAEG,KAAK;QACT,EAAEA,KAAK;MACT,EAAED,cAAc;AAEpB;AAGF,MAAMM,iBAAiBC,KACrBxH,QACA,CAACyH,WAAWC,YACVC,uBAAuBF,WAAWC,WAAW;QAAC;QAAc;KAAU"}
1
+ {"version":3,"file":"Swiper/index.jsx","sources":["../../src/Swiper/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 {\n forwardRef,\n memo,\n useImperativeHandle,\n useMainThreadRef,\n useMemo,\n} from '@lynx-js/react'\nimport type { ForwardedRef } from '@lynx-js/react'\n\nimport { useTouchEmulation } from '@lynx-js/react-use'\nimport type { MainThread } from '@lynx-js/types'\n\nimport { LOOP_COUNT } from '../const'\nimport { useBounceConfig } from '../hooks/useBounceConfig'\nimport { useBounceView } from '../hooks/useBounceView'\nimport { useChange } from '../hooks/useChange'\nimport useFirstScreenStyle, {\n getInnerContainerWidthMT,\n} from '../hooks/useFirstScreenStyle'\nimport { useModeConfig } from '../hooks/useModeConfig'\nimport { useOffset } from '../hooks/useOffset'\nimport { useOffsetLimit } from '../hooks/useOffsetLimit'\nimport { useReset } from '../hooks/useReset'\nimport { SwiperContext, SwiperItemContext } from '../store'\nimport type {\n SwipeDirection,\n SwiperProps,\n SwiperRef,\n UpdateSwiperInnerContainerOptions,\n} from '../types'\nimport { easeOut } from '../utils'\nimport { comparePropsWithObject } from '../utils/compareProps'\n\nimport './styles.css'\n\n/**\n * Swiper Component\n */\nconst Swiper = forwardRef(\n <T,>(\n {\n data = [],\n itemWidth,\n containerWidth = lynx.__globalProps.screenWidth\n ?? SystemInfo.pixelWidth / SystemInfo.pixelRatio,\n loop = false,\n mode,\n autoPlay = false,\n autoPlayInterval = 2000,\n duration = 500,\n itemHeight = 'auto',\n initialIndex = 0,\n onChange,\n onSwipeStart,\n onSwipeStop,\n modeConfig: _modeConfig,\n offsetLimit: _offsetLimit,\n bounceConfig,\n children,\n 'main-thread:easing': easing = easeOut,\n 'main-thread:customAnimation': customAnimation,\n 'main-thread:onOffsetChange': onOffsetChange,\n customAnimationFirstScreen,\n swiperKey,\n resetOnReuse,\n trackStyle = {},\n style = {},\n loopDuplicateCount: rawLoopDuplicateCount = LOOP_COUNT,\n experimentalHorizontalSwipeOnly = false,\n consumeSlideEvent = [\n [-180, -135],\n [-45, 45],\n [135, 180],\n ],\n blockNativeEvent = false,\n RTL = false,\n }: SwiperProps<T> & { experimentalHorizontalSwipeOnly?: boolean },\n ref: ForwardedRef<SwiperRef>,\n ) => {\n const dataCount = data.length\n\n const loopDuplicateCount = Math.min(rawLoopDuplicateCount, dataCount)\n\n const containerRef = useMainThreadRef<MainThread.Element>(null)\n const childrenMapRef = useMainThreadRef<Record<number, MainThread.Element>>(\n {},\n )\n const { modeConfig, spaceBetween } = useModeConfig({\n mode,\n modeConfig: _modeConfig,\n })\n const offsetLimit = useOffsetLimit({\n offsetLimit: _offsetLimit,\n loop,\n itemWidth,\n containerWidth,\n modeConfig,\n dataCount,\n spaceBetween,\n })\n\n const {\n enableBounce,\n startBounceItem,\n endBounceItem,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n } = useBounceConfig(bounceConfig)\n\n function setChildrenRef(refI: MainThread.Element, key: number) {\n 'main thread'\n childrenMapRef.current[key] = refI\n }\n\n const contextValue = useMemo(\n () => ({\n loop,\n itemWidth,\n itemHeight,\n setChildrenRef,\n modeConfig,\n initialIndex,\n customAnimationFirstScreen,\n spaceBetween,\n RTL,\n }),\n [loop, itemWidth, itemHeight, spaceBetween, RTL],\n )\n\n const { setChangeOffset, setChangeSwipeStartMT, setChangeSwipeStopMT } =\n useChange({\n onChange,\n size: itemWidth,\n spaceBetween,\n containerWidth,\n dataCount,\n modeConfig,\n offsetLimit,\n onSwipeStart,\n onSwipeStop,\n 'main-thread:onOffsetChange': onOffsetChange,\n })\n\n function setOffset(offset: number) {\n 'main thread'\n const container = containerRef.current\n if (container) {\n container.setStyleProperties({\n transform: `translate(${offset}px, 0)`,\n transition: 'none',\n })\n }\n }\n\n function updateSwiperInnerContainerSizeMT(\n updateOptions: UpdateSwiperInnerContainerOptions,\n ) {\n 'main thread'\n const container = containerRef.current\n if (container) {\n const width = getInnerContainerWidthMT(updateOptions)\n // These values should get from function params, instead of closure, to make it is updated\n const {\n loop: _loop,\n loopDuplicateCount: _loopDuplicateCount,\n itemWidth: _itemWidth,\n spaceBetween: _spaceBetween,\n itemHeight: _itemHeight,\n } = updateOptions\n\n if (updateOptions.mode === 'custom') {\n // @ts-expect-error CSS types accepting number\n container.setStyleProperties({\n ...trackStyle,\n height: `${_itemHeight}px`,\n })\n } else {\n const insetInlineStartKey = RTL ? 'inset-inline-start' : 'left'\n // @ts-expect-error CSS types accepting number\n container.setStyleProperties({\n ...trackStyle,\n [insetInlineStartKey]: _loop\n ? `${-_loopDuplicateCount * (_itemWidth + _spaceBetween)}px`\n : '0px',\n width,\n height: `${_itemHeight}px`,\n })\n }\n }\n }\n\n function onChildrenOffsetUpdate(offset: number) {\n 'main thread'\n const startCount = loop ? -loopDuplicateCount : 0\n const endCount = loop ? dataCount + loopDuplicateCount : dataCount\n for (let i = startCount; i < endCount; i++) {\n const child = childrenMapRef.current[i]\n const childOffset = offset + i * (itemWidth + spaceBetween)\n if (!customAnimation || !child) {\n return\n }\n const childStyles =\n customAnimation(childOffset / (itemWidth + spaceBetween), i)\n || {}\n child.setStyleProperties(childStyles as Record<string, string>)\n }\n }\n\n function onOffsetUpdate(offset: number, direction: SwipeDirection) {\n 'main thread'\n if (modeConfig.mode === 'normal') {\n let effectiveOffset = offset\n if (modeConfig.align === 'center') {\n effectiveOffset = offset + (containerWidth - itemWidth) / 2\n } else if (modeConfig.align === 'end') {\n effectiveOffset = offset + containerWidth - itemWidth\n }\n setOffset(RTL ? -effectiveOffset : effectiveOffset)\n onChildrenOffsetUpdate(offset)\n } else {\n onChildrenOffsetUpdate(offset)\n }\n setChangeOffset(offset, direction)\n }\n\n function onSwipeStartMT() {\n 'main thread'\n setChangeSwipeStartMT()\n }\n\n function onSwipeStopMT() {\n 'main thread'\n setChangeSwipeStopMT()\n }\n\n // `containerStyle` is only used at firstScreen\n // After that, we use MTS to update styles imperatively\n const { containerStyle } = useFirstScreenStyle({\n itemWidth,\n containerWidth,\n loop,\n initialIndex,\n dataCount,\n modeConfig,\n itemHeight,\n offsetLimit,\n loopDuplicateCount,\n RTL,\n spaceBetween,\n swiperKey,\n trackStyle,\n })\n\n const {\n handleTouchMove,\n handleTouchStart,\n handleTouchEnd,\n swipeNext,\n swipePrev,\n swipeTo,\n resetOffsetMT,\n cancelAnimationJS,\n startAutoPlayMT,\n } = useOffset(\n {\n autoPlay,\n autoPlayInterval,\n loop,\n size: itemWidth,\n spaceBetween,\n dataCount,\n duration,\n easing,\n offsetLimit,\n initialIndex,\n modeConfig,\n containerWidth,\n enableBounce,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n experimentalHorizontalSwipeOnly,\n onSwipeStartMT,\n onSwipeStopMT,\n consumeSlideEvent,\n RTL,\n },\n onOffsetUpdate,\n )\n\n const { setContainerRef } = useReset({\n swiperKey,\n itemHeight,\n itemWidth,\n containerWidth,\n loop,\n dataCount,\n modeConfig,\n resetOffsetMT,\n resetOnReuse,\n initialIndex,\n loopDuplicateCount,\n updateSwiperInnerContainerSizeMT,\n startAutoPlayMT,\n spaceBetween,\n })\n\n const touchHandlers = useTouchEmulation({\n onTouchCancelMT: handleTouchEnd,\n onTouchEndMT: handleTouchEnd,\n onTouchMoveMT: handleTouchMove,\n onTouchStartMT: handleTouchStart,\n })\n\n useImperativeHandle(ref, () => ({\n swipeNext,\n swipePrev,\n swipeTo,\n cancelAnimation: cancelAnimationJS,\n }))\n\n function renderSwiperItem(props: {\n item: T\n index: number\n realIndex: number\n }) {\n return (\n <SwiperItemContext.Provider\n key={props.realIndex}\n value={{\n index: props.index,\n realIndex: props.realIndex,\n }}\n >\n {children(props)}\n </SwiperItemContext.Provider>\n )\n }\n\n const { bounceStartView, bounceEndView } = useBounceView({\n startBounceItem,\n endBounceItem,\n loop,\n mode: modeConfig.mode,\n itemWidth,\n count: dataCount,\n RTL,\n containerWidth,\n })\n\n return (\n <SwiperContext.Provider value={contextValue}>\n <view\n class='swiper-root'\n style={{\n ...style,\n width: `${containerWidth}px`,\n height: `${itemHeight}px`,\n direction: RTL === 'lynx-rtl' ? 'lynx-rtl' : (RTL ? 'rtl' : 'ltr'),\n }}\n {...touchHandlers}\n consume-slide-event={consumeSlideEvent}\n block-native-event={blockNativeEvent}\n >\n <view\n class='swiper-track'\n style={containerStyle}\n ref={setContainerRef}\n main-thread:ref={containerRef}\n implicit-animation='false'\n >\n {bounceStartView}\n {loop\n ? (\n <>\n {Array.from(\n { length: loopDuplicateCount },\n (_, i) => loopDuplicateCount - i - 1,\n ).map((i) =>\n renderSwiperItem({\n index: data.length - i - 1,\n item: data[data.length - i - 1],\n realIndex: -i - 1,\n })\n )}\n </>\n )\n : null}\n {data.map((item: T, index: number) =>\n renderSwiperItem({\n index,\n item,\n realIndex: index,\n })\n )}\n {loop\n ? (\n <>\n {Array.from({ length: loopDuplicateCount }, (_, i) => i).map((\n i,\n ) =>\n renderSwiperItem({\n index: i,\n item: data[i],\n realIndex: data.length + i,\n })\n )}\n </>\n )\n : null}\n {bounceEndView}\n </view>\n </view>\n </SwiperContext.Provider>\n )\n },\n)\n\nconst MemoizedSwiper = memo(\n Swiper,\n (prevProps, nextProps) =>\n comparePropsWithObject(prevProps, nextProps, ['modeConfig', 'bounces']),\n) as typeof Swiper\n\nexport { MemoizedSwiper as Swiper }\n"],"names":["Swiper","forwardRef","data","itemWidth","containerWidth","lynx","SystemInfo","loop","mode","autoPlay","autoPlayInterval","duration","itemHeight","initialIndex","onChange","onSwipeStart","onSwipeStop","_modeConfig","_offsetLimit","bounceConfig","children","easing","easeOut","customAnimation","onOffsetChange","customAnimationFirstScreen","swiperKey","resetOnReuse","trackStyle","style","rawLoopDuplicateCount","LOOP_COUNT","experimentalHorizontalSwipeOnly","consumeSlideEvent","blockNativeEvent","RTL","ref","dataCount","loopDuplicateCount","Math","containerRef","useMainThreadRef","childrenMapRef","modeConfig","spaceBetween","useModeConfig","offsetLimit","useOffsetLimit","enableBounce","startBounceItem","endBounceItem","startBounceItemWidth","endBounceItemWidth","onStartBounceItemBounce","onEndBounceItemBounce","useBounceConfig","setChildrenRef","refI","key","contextValue","useMemo","setChangeOffset","setChangeSwipeStartMT","setChangeSwipeStopMT","useChange","setOffset","offset","container","updateSwiperInnerContainerSizeMT","updateOptions","width","getInnerContainerWidthMT","_loop","_loopDuplicateCount","_itemWidth","_spaceBetween","_itemHeight","insetInlineStartKey","onChildrenOffsetUpdate","startCount","endCount","i","child","childOffset","childStyles","onOffsetUpdate","direction","effectiveOffset","onSwipeStartMT","onSwipeStopMT","containerStyle","useFirstScreenStyle","handleTouchMove","handleTouchStart","handleTouchEnd","swipeNext","swipePrev","swipeTo","resetOffsetMT","cancelAnimationJS","startAutoPlayMT","useOffset","setContainerRef","useReset","touchHandlers","useTouchEmulation","useImperativeHandle","renderSwiperItem","props","SwiperItemContext","bounceStartView","bounceEndView","useBounceView","SwiperContext","view","Array","_","item","index","MemoizedSwiper","memo","prevProps","nextProps","comparePropsWithObject"],"mappings":";;;;;;;;;;;;;;;AA0CA,MAAMA,SAASC,WACb,CACE,EACEC,OAAO,EAAE,EACTC,SAAS,EACTC,iBAAiBC,KAAK,aAAa,CAAC,WAAW,IAC1CC,WAAW,UAAU,GAAGA,WAAW,UAAU,EAClDC,OAAO,KAAK,EACZC,IAAI,EACJC,WAAW,KAAK,EAChBC,mBAAmB,IAAI,EACvBC,WAAW,GAAG,EACdC,aAAa,MAAM,EACnBC,eAAe,CAAC,EAChBC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACX,YAAYC,WAAW,EACvB,aAAaC,YAAY,EACzBC,YAAY,EACZC,QAAQ,EACR,sBAAsBC,SAASC,OAAO,EACtC,+BAA+BC,eAAe,EAC9C,8BAA8BC,cAAc,EAC5CC,0BAA0B,EAC1BC,SAAS,EACTC,YAAY,EACZC,aAAa,CAAC,CAAC,EACfC,QAAQ,CAAC,CAAC,EACV,oBAAoBC,wBAAwBC,UAAU,EACtDC,kCAAkC,KAAK,EACvCC,oBAAoB;IAClB;QAAC;QAAM;KAAK;IACZ;QAAC;QAAK;KAAG;IACT;QAAC;QA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AAK;MACT,EAAED,cAAc;AAEpB;AAGF,MAAMM,iBAAiBC,KACrBxH,QACA,CAACyH,WAAWC,YACVC,uBAAuBF,WAAWC,WAAW;QAAC;QAAc;KAAU"}
@@ -1 +1 @@
1
- {"version":3,"sources":["webpack://./src/Swiper/styles.css"],"names":[],"mappings":"AADA;EAEE,eAAe;EACf,8BAA8B;EAC9B,WAAW;EACX,YAAY;EACZ,gBAAgB;AAClB;;AAEA;EACE,eAAe;EACf,8BAA8B;EAC9B,WAAW;EACX,YAAY;AACd;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,OAAO;EACP,2BAA2B;AAC7B;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,qBAAqB;EACrB,0BAA0B;AAC5B;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,UAAU;AACZ;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,wBAAwB;AAC1B","sourcesContent":[".swiper-root {\n display: linear;\n linear-orientation: horizontal;\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.swiper-track {\n display: linear;\n linear-orientation: horizontal;\n width: 100%;\n height: 100%;\n}\n\n.bounce-start-item {\n position: absolute;\n left: 0;\n transform: translate(-100%);\n height: 100%;\n width: max-content;\n}\n\n.bounce-start-item-RTL {\n position: absolute;\n inset-inline-start: 0;\n transform: translate(100%);\n height: 100%;\n width: max-content;\n}\n\n.bounce-end-item {\n position: absolute;\n left: 100%;\n height: 100%;\n width: max-content;\n}\n\n.bounce-end-item-RTL {\n position: absolute;\n inset-inline-start: 100%;\n height: 100%;\n width: max-content;\n}\n"],"sourceRoot":""}
1
+ {"version":3,"sources":["webpack://./src/Swiper/styles.css"],"names":[],"mappings":"AAAA;EACE,eAAe;EACf,8BAA8B;EAC9B,WAAW;EACX,YAAY;EACZ,gBAAgB;AAClB;;AAEA;EACE,eAAe;EACf,8BAA8B;EAC9B,WAAW;EACX,YAAY;AACd;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,OAAO;EACP,2BAA2B;AAC7B;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,qBAAqB;EACrB,0BAA0B;AAC5B;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,UAAU;AACZ;;AAEA;EACE,kBAAkB;EAClB,YAAY;EACZ,kBAAkB;EAClB,wBAAwB;AAC1B","sourcesContent":[".swiper-root {\n display: linear;\n linear-orientation: horizontal;\n width: 100%;\n height: 100%;\n overflow: hidden;\n}\n\n.swiper-track {\n display: linear;\n linear-orientation: horizontal;\n width: 100%;\n height: 100%;\n}\n\n.bounce-start-item {\n position: absolute;\n left: 0;\n transform: translate(-100%);\n height: 100%;\n width: max-content;\n}\n\n.bounce-start-item-RTL {\n position: absolute;\n inset-inline-start: 0;\n transform: translate(100%);\n height: 100%;\n width: max-content;\n}\n\n.bounce-end-item {\n position: absolute;\n left: 100%;\n height: 100%;\n width: max-content;\n}\n\n.bounce-end-item-RTL {\n position: absolute;\n inset-inline-start: 100%;\n height: 100%;\n width: max-content;\n}\n"],"sourceRoot":""}
@@ -1 +1 @@
1
- {"version":3,"file":"SwiperItem/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/SwiperItem/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 {\n memo,\n runOnMainThread,\n useContext,\n useEffect,\n useMainThreadRef,\n useMemo,\n} from '@lynx-js/react'\nimport type { ReactElement, RefObject } from '@lynx-js/react'\n\nimport type { CSSProperties, MainThread } from '@lynx-js/types'\n\nimport { SwiperContext, SwiperItemContext } from '../store'\nimport type { CompoundModeConfig, SwiperContextProps } from '../types'\n\nexport interface SwiperItemProps {\n /**\n * Index of current SwiperItem, out of Swiper's data.\n * @Android\n * @iOS\n * @Harmony\n */\n index?: number\n /**\n * Children of SwiperItem\n * @Android\n * @iOS\n * @Harmony\n */\n children: ReactElement | ReactElement[]\n /**\n * Style of SwiperItem\n * @Android\n * @iOS\n * @Harmony\n */\n style?: CSSProperties\n /**\n * Physical index of current SwiperItem.\n * Kept for compatibility with existing manual usage. This is resolved\n * automatically when SwiperItem is rendered inside Swiper's children function.\n * @Android\n * @iOS\n * @Harmony\n */\n realIndex?: number\n /**\n * `overlap` attribute passed to SwiperItem's direct child.\n * This property is used only when opacity has issues.\n * Refer to {@link https://lynxjs.org/en/api/css/properties/opacity#opacity}\n * @Android\n * @iOS\n * @Harmony\n */\n overlap?: boolean\n}\n\ninterface IFirstScreenStyle extends\n Pick<\n SwiperContextProps,\n | 'itemWidth'\n | 'itemHeight'\n | 'initialIndex'\n | 'customAnimationFirstScreen'\n | 'RTL'\n >\n{\n itemRef: RefObject<MainThread.Element | undefined>\n spaceBetween: number\n realIndex: number\n modeConfig: CompoundModeConfig\n}\n\nfunction useFirstScreenStyle(props: IFirstScreenStyle) {\n const {\n itemWidth,\n spaceBetween,\n itemHeight,\n itemRef,\n customAnimationFirstScreen,\n realIndex,\n modeConfig,\n initialIndex,\n RTL,\n } = props\n\n const containerStyle = useMemo(() => {\n if (modeConfig.mode === 'normal') {\n let style: CSSProperties = {\n width: `${itemWidth}px`,\n height: `${itemHeight}px`,\n [RTL === true ? 'marginLeft' : 'marginRight']: `${spaceBetween}px`,\n }\n if (customAnimationFirstScreen) {\n const customStyle = customAnimationFirstScreen(\n -initialIndex + realIndex,\n realIndex,\n )\n style = {\n ...style,\n ...customStyle,\n }\n }\n\n return style\n } else if (modeConfig.mode === 'custom') {\n let style: CSSProperties = {\n width: `${itemWidth}px`,\n height: `${itemHeight}px`,\n position: 'absolute',\n }\n if (customAnimationFirstScreen) {\n const customStyle = customAnimationFirstScreen(\n -initialIndex + realIndex,\n realIndex,\n )\n style = {\n ...style,\n ...customStyle,\n }\n }\n\n return style\n }\n }, [])\n\n function updateMainThreadR(propsFromJS: {\n itemWidth: number\n itemHeight: SwiperContextProps['itemHeight']\n spaceBetween: number\n }) {\n 'main thread'\n if (itemRef.current) {\n itemRef.current.setStyleProperties({\n width: `${propsFromJS.itemWidth}px`,\n height: `${propsFromJS.itemHeight}px`,\n marginInlineEnd: `${propsFromJS.spaceBetween}px`,\n })\n }\n }\n\n useEffect(() => {\n runOnMainThread(updateMainThreadR)({\n itemWidth,\n itemHeight,\n spaceBetween,\n })\n }, [itemWidth, itemHeight, spaceBetween])\n\n return {\n containerStyle,\n }\n}\n\nconst SwiperItem = (\n { index, realIndex, children, overlap }: SwiperItemProps,\n) => {\n const {\n itemWidth,\n itemHeight,\n setChildrenRef,\n modeConfig,\n customAnimationFirstScreen,\n initialIndex = 0,\n spaceBetween,\n RTL,\n } = useContext(SwiperContext)\n const itemContext = useContext(SwiperItemContext)\n const resolvedIndex = index ?? itemContext?.index\n const resolvedRealIndex = realIndex ?? itemContext?.realIndex ?? resolvedIndex\n const hasResolvedIndex = resolvedIndex !== undefined\n const effectiveRealIndex = resolvedRealIndex ?? 0\n const swiperItemRef = useMainThreadRef<MainThread.Element>()\n\n const { containerStyle } = useFirstScreenStyle({\n itemWidth,\n itemHeight,\n spaceBetween,\n itemRef: swiperItemRef,\n modeConfig,\n realIndex: effectiveRealIndex,\n initialIndex,\n customAnimationFirstScreen,\n RTL,\n })\n\n if (!hasResolvedIndex) {\n throw new Error(\n 'SwiperItem must be rendered inside Swiper children or receive an index prop.',\n )\n }\n\n function setRef(ref: MainThread.Element) {\n 'main thread'\n swiperItemRef.current = ref\n setChildrenRef(ref, effectiveRealIndex)\n }\n\n return (\n <view\n class='swiper-item'\n style={containerStyle}\n main-thread:ref={setRef}\n overlap={overlap}\n >\n {children}\n </view>\n )\n}\n\nconst MemoSwiperItem = memo(SwiperItem) as typeof SwiperItem\n\nexport { MemoSwiperItem as SwiperItem }\n"],"names":["useFirstScreenStyle","props","itemWidth","spaceBetween","itemHeight","itemRef","customAnimationFirstScreen","realIndex","modeConfig","initialIndex","RTL","containerStyle","useMemo","style","customStyle","updateMainThreadR","propsFromJS","useEffect","runOnMainThread","SwiperItem","index","children","overlap","setChildrenRef","useContext","SwiperContext","itemContext","SwiperItemContext","resolvedIndex","resolvedRealIndex","hasResolvedIndex","undefined","effectiveRealIndex","swiperItemRef","useMainThreadRef","Error","setRef","ref","view","MemoSwiperItem","memo"],"mappings":";;AA6EA,SAASA,oBAAoBC,KAAwB;IACnD,MAAM,EACJC,SAAS,EACTC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,0BAA0B,EAC1BC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,GAAG,EACJ,GAAGT;IAEJ,MAAMU,iBAAiBC,QAAQ;QAC7B,IAAIJ,AAAoB,aAApBA,WAAW,IAAI,EAAe;YAChC,IAAIK,QAAuB;gBACzB,OAAO,GAAGX,UAAU,EAAE,CAAC;gBACvB,QAAQ,GAAGE,WAAW,EAAE,CAAC;gBACzB,CAACM,AAAQ,SAARA,MAAe,eAAe,cAAc,EAAE,GAAGP,aAAa,EAAE,CAAC;YACpE;YACA,IAAIG,4BAA4B;gBAC9B,MAAMQ,cAAcR,2BAClB,CAACG,eAAeF,WAChBA;gBAEFM,QAAQ;oBACN,GAAGA,KAAK;oBACR,GAAGC,WAAW;gBAChB;YACF;YAEA,OAAOD;QACT;QAAO,IAAIL,AAAoB,aAApBA,WAAW,IAAI,EAAe;YACvC,IAAIK,QAAuB;gBACzB,OAAO,GAAGX,UAAU,EAAE,CAAC;gBACvB,QAAQ,GAAGE,WAAW,EAAE,CAAC;gBACzB,UAAU;YACZ;YACA,IAAIE,4BAA4B;gBAC9B,MAAMQ,cAAcR,2BAClB,CAACG,eAAeF,WAChBA;gBAEFM,QAAQ;oBACN,GAAGA,KAAK;oBACR,GAAGC,WAAW;gBAChB;YACF;YAEA,OAAOD;QACT;IACF,GAAG,EAAE;IAEL,SAASE,kBAAkBC,WAI1B;QACC;QACA,IAA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em/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 {\n memo,\n runOnMainThread,\n useContext,\n useEffect,\n useMainThreadRef,\n useMemo,\n} from '@lynx-js/react'\nimport type { ReactElement, RefObject } from '@lynx-js/react'\n\nimport type { CSSProperties, MainThread } from '@lynx-js/types'\n\nimport { SwiperContext, SwiperItemContext } from '../store'\nimport type { CompoundModeConfig, SwiperContextProps } from '../types'\n\nexport interface SwiperItemProps {\n /**\n * Index of current SwiperItem, out of Swiper's data.\n * @Android\n * @iOS\n * @Harmony\n */\n index?: number\n /**\n * Children of SwiperItem\n * @Android\n * @iOS\n * @Harmony\n */\n children: ReactElement | ReactElement[]\n /**\n * Style of SwiperItem\n * @Android\n * @iOS\n * @Harmony\n */\n style?: CSSProperties\n /**\n * Physical index of current SwiperItem.\n * Kept for compatibility with existing manual usage. This is resolved\n * automatically when SwiperItem is rendered inside Swiper's children function.\n * @Android\n * @iOS\n * @Harmony\n */\n realIndex?: number\n /**\n * `overlap` attribute passed to SwiperItem's direct child.\n * This property is used only when opacity has issues.\n * Refer to {@link https://lynxjs.org/en/api/css/properties/opacity#opacity}\n * @Android\n * @iOS\n * @Harmony\n */\n overlap?: boolean\n}\n\ninterface IFirstScreenStyle extends\n Pick<\n SwiperContextProps,\n | 'itemWidth'\n | 'itemHeight'\n | 'initialIndex'\n | 'customAnimationFirstScreen'\n | 'RTL'\n >\n{\n itemRef: RefObject<MainThread.Element | undefined>\n spaceBetween: number\n realIndex: number\n modeConfig: CompoundModeConfig\n}\n\nfunction useFirstScreenStyle(props: IFirstScreenStyle) {\n const {\n itemWidth,\n spaceBetween,\n itemHeight,\n itemRef,\n customAnimationFirstScreen,\n realIndex,\n modeConfig,\n initialIndex,\n RTL,\n } = props\n\n const containerStyle = useMemo(() => {\n if (modeConfig.mode === 'normal') {\n let style: CSSProperties = {\n width: `${itemWidth}px`,\n height: `${itemHeight}px`,\n [RTL === true ? 'marginLeft' : 'marginRight']: `${spaceBetween}px`,\n }\n if (customAnimationFirstScreen) {\n const customStyle = customAnimationFirstScreen(\n -initialIndex + realIndex,\n realIndex,\n )\n style = {\n ...style,\n ...customStyle,\n }\n }\n\n return style\n } else if (modeConfig.mode === 'custom') {\n let style: CSSProperties = {\n width: `${itemWidth}px`,\n height: `${itemHeight}px`,\n position: 'absolute',\n }\n if (customAnimationFirstScreen) {\n const customStyle = customAnimationFirstScreen(\n -initialIndex + realIndex,\n realIndex,\n )\n style = {\n ...style,\n ...customStyle,\n }\n }\n\n return style\n }\n }, [])\n\n function updateMainThreadR(propsFromJS: {\n itemWidth: number\n itemHeight: SwiperContextProps['itemHeight']\n spaceBetween: number\n }) {\n 'main thread'\n if (itemRef.current) {\n itemRef.current.setStyleProperties({\n width: `${propsFromJS.itemWidth}px`,\n height: `${propsFromJS.itemHeight}px`,\n marginInlineEnd: `${propsFromJS.spaceBetween}px`,\n })\n }\n }\n\n useEffect(() => {\n runOnMainThread(updateMainThreadR)({\n itemWidth,\n itemHeight,\n spaceBetween,\n })\n }, [itemWidth, itemHeight, spaceBetween])\n\n return {\n containerStyle,\n }\n}\n\nconst SwiperItem = (\n { index, realIndex, children, overlap }: SwiperItemProps,\n) => {\n const {\n itemWidth,\n itemHeight,\n setChildrenRef,\n modeConfig,\n customAnimationFirstScreen,\n initialIndex = 0,\n spaceBetween,\n RTL,\n } = useContext(SwiperContext)\n const itemContext = useContext(SwiperItemContext)\n const resolvedIndex = index ?? itemContext?.index\n const resolvedRealIndex = realIndex ?? itemContext?.realIndex ?? resolvedIndex\n const hasResolvedIndex = resolvedIndex !== undefined\n const effectiveRealIndex = resolvedRealIndex ?? 0\n const swiperItemRef = useMainThreadRef<MainThread.Element>()\n\n const { containerStyle } = useFirstScreenStyle({\n itemWidth,\n itemHeight,\n spaceBetween,\n itemRef: swiperItemRef,\n modeConfig,\n realIndex: effectiveRealIndex,\n initialIndex,\n customAnimationFirstScreen,\n RTL,\n })\n\n if (!hasResolvedIndex) {\n throw new Error(\n 'SwiperItem must be rendered inside Swiper children or receive an index prop.',\n )\n }\n\n function setRef(ref: MainThread.Element) {\n 'main thread'\n swiperItemRef.current = ref\n setChildrenRef(ref, effectiveRealIndex)\n }\n\n return (\n <view\n class='swiper-item'\n style={containerStyle}\n main-thread:ref={setRef}\n overlap={overlap}\n >\n {children}\n </view>\n )\n}\n\nconst MemoSwiperItem = memo(SwiperItem) as typeof SwiperItem\n\nexport { MemoSwiperItem as SwiperItem }\n"],"names":["useFirstScreenStyle","props","itemWidth","spaceBetween","itemHeight","itemRef","customAnimationFirstScreen","realIndex","modeConfig","initialIndex","RTL","containerStyle","useMemo","style","customStyle","updateMainThreadR","propsFromJS","useEffect","runOnMainThread","SwiperItem","index","children","overlap","setChildrenRef","useContext","SwiperContext","itemContext","SwiperItemContext","resolvedIndex","resolvedRealIndex","hasResolvedIndex","undefined","effectiveRealIndex","swiperItemRef","useMainThreadRef","Error","setRef","ref","view","MemoSwiperItem","memo"],"mappings":";;AA6EA,SAASA,oBAAoBC,KAAwB;IACnD,MAAM,EACJC,SAAS,EACTC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,0BAA0B,EAC1BC,SAAS,EACTC,UAAU,EACVC,YAAY,EACZC,GAAG,EACJ,GAAGT;IAEJ,MAAMU,iBAAiBC,QAAQ;QAC7B,IAAIJ,AAAoB,aAApBA,WAAW,IAAI,EAAe;YAChC,IAAIK,QAAuB;gBACzB,OAAO,GAAGX,UAAU,EAAE,CAAC;gBACvB,QAAQ,GAAGE,WAAW,EAAE,CAAC;gBACzB,CAACM,AAAQ,SAARA,MAAe,eAAe,cAAc,EAAE,GAAGP,aAAa,EAAE,CAAC;YACpE;YACA,IAAIG,4BAA4B;gBAC9B,MAAMQ,cAAcR,2BAClB,CAACG,eAAeF,WAChBA;gBAEFM,QAAQ;oBACN,GAAGA,KAAK;oBACR,GAAGC,WAAW;gBAChB;YACF;YAEA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QACAE;QACAD;QACA,SAAS8B;QACTzB;QACA,WAAWwB;QACXvB;QACAH;QACAI;IACF;IAEA,IAAI,CAACoB,kBACH,MAAM,IAAIK,MACR;IAIJ,SAASC,OAAOC,GAAuB;QACrC;QACAJ,cAAc,OAAO,GAAGI;QACxBd,eAAec,KAAKL;IACtB;IAEA,QACGM,KACC,MAAM,cACN,OAAO3B,gBACP,YAAY,KAAKyB,QACjB,SAASd,SACV;MACC,CAACD,SAAS;IACZ,EAAEiB;AAEN;AAEA,MAAMC,iBAAiBC,KAAKrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"const/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/const/index.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\nexport const LOOP_COUNT = 2\n\nexport const TAP_THRESHOLD = 8\n\nexport const CROSS_AXIS_THRESHOLD = 20\n\nexport const GESTURE_THRESHOLD = 8 // Slop area in pixels\n"],"names":["LOOP_COUNT","TAP_THRESHOLD","CROSS_AXIS_THRESHOLD","GESTURE_THRESHOLD"],"mappings":"AAIO,MAAMA,aAAa;AAEnB,MAAMC,gBAAgB;AAEtB,MAAMC,uBAAuB;AAE7B,MAAMC,oBAAoB"}
1
+ {"version":3,"file":"const/index.jsx","sources":["../../src/const/index.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\nexport const LOOP_COUNT = 2\n\nexport const TAP_THRESHOLD = 8\n\nexport const CROSS_AXIS_THRESHOLD = 20\n\nexport const GESTURE_THRESHOLD = 8 // Slop area in pixels\n"],"names":["LOOP_COUNT","TAP_THRESHOLD","CROSS_AXIS_THRESHOLD","GESTURE_THRESHOLD"],"mappings":"AAIO,MAAMA,aAAa;AAEnB,MAAMC,gBAAgB;AAEtB,MAAMC,uBAAuB;AAE7B,MAAMC,oBAAoB"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useAnimate.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useAnimate.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 { useMainThreadRef } from '@lynx-js/react'\n\nfunction animateInner(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n) {\n 'main thread'\n let startTs = 0\n let rafId = 0\n\n function tick(ts: number) {\n const progress = Math.max(\n Math.min(((ts - startTs) * 100) / duration, 100),\n 0,\n )\n\n onUpdate(progress)\n }\n\n function updateRafId(id: number) {\n rafId = id\n }\n\n function step(ts: number) {\n if (!startTs) {\n startTs = Number(ts)\n }\n // make sure progress can reach 100%\n if (ts - startTs <= duration + 100) {\n tick(ts)\n updateRafId(requestAnimationFrame(step))\n } else {\n onFinished?.()\n }\n }\n\n updateRafId(requestAnimationFrame(step))\n\n function cancel() {\n cancelAnimationFrame(rafId)\n }\n\n return {\n cancel,\n }\n}\n\nexport function useAnimate() {\n const lastCancelRef = useMainThreadRef<() => void>()\n\n function cancel() {\n 'main thread'\n lastCancelRef.current?.()\n }\n\n function animate(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n ) {\n 'main thread'\n cancel()\n const { cancel: innerCancel } = animateInner(\n duration,\n onUpdate,\n onFinished,\n )\n lastCancelRef.current = innerCancel\n }\n\n return {\n cancel,\n animate,\n }\n}\n"],"names":["animateInner","duration","onUpdate","onFinished","startTs","rafId","tick","ts","progress","Math","updateRafId","id","step","Number","requestAnimationFrame","cancel","cancelAnimationFrame","useAnimate","lastCancelRef","useMainThreadRef","animate","innerCancel"],"mappings":";AAMA,SAASA,aACPC,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;IAEvB;IACA,IAAIC,UAAU;IACd,IAAIC,QAAQ;IAEZ,SAASC,KAAKC,EAAU;QACtB,MAAMC,WAAWC,KAAK,GAAG,CACvBA,KAAK,GAAG,CAAGF,AAAAA,CAAAA,KAAKH,OAAM,IAAK,MAAOH,UAAU,MAC5C;QAGFC,SAASM;IACX;IAEA,SAASE,YAAYC,EAAU;QAC7BN,QAAQM;IACV;IAEA,SAASC,KAAKL,EAAU;QACtB,IAAI,CAACH,SACHA,UAAUS,OAAON;QAGnB,IAAIA,KAAKH,WAAWH,WAAW,KAAK;YAClCK,KAAKC;YACLG,YAAYI,sBAAsBF;QACpC,OACET;IAEJ;IAEAO,YAAYI,sBAAsBF;IAElC,SAASG;QACPC,qBAAqBX;IACvB;IAEA,OAAO;QACLU;IACF;AACF;AAEO,SAASE;IACd,MAAMC,gBAAgBC;IAEtB,SAASJ;QACP;QACAG,cAAc,OAAO;IACvB;IAEA,SAASE,QACPnB,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;QAEvB;QACAY;QACA,MAAM,EAAE,QAAQM,WAAW,EAAE,GAAGrB,aAC9BC,UACAC,UACAC;QAEFe,cAAc,OAAO,GAAGG;IAC1B;IAEA,OAAO;QACLN;QACAK;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useAnimate.jsx","sources":["../../src/hooks/useAnimate.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 { useMainThreadRef } from '@lynx-js/react'\n\nfunction animateInner(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n) {\n 'main thread'\n let startTs = 0\n let rafId = 0\n\n function tick(ts: number) {\n const progress = Math.max(\n Math.min(((ts - startTs) * 100) / duration, 100),\n 0,\n )\n\n onUpdate(progress)\n }\n\n function updateRafId(id: number) {\n rafId = id\n }\n\n function step(ts: number) {\n if (!startTs) {\n startTs = Number(ts)\n }\n // make sure progress can reach 100%\n if (ts - startTs <= duration + 100) {\n tick(ts)\n updateRafId(requestAnimationFrame(step))\n } else {\n onFinished?.()\n }\n }\n\n updateRafId(requestAnimationFrame(step))\n\n function cancel() {\n cancelAnimationFrame(rafId)\n }\n\n return {\n cancel,\n }\n}\n\nexport function useAnimate() {\n const lastCancelRef = useMainThreadRef<() => void>()\n\n function cancel() {\n 'main thread'\n lastCancelRef.current?.()\n }\n\n function animate(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n ) {\n 'main thread'\n cancel()\n const { cancel: innerCancel } = animateInner(\n duration,\n onUpdate,\n onFinished,\n )\n lastCancelRef.current = innerCancel\n }\n\n return {\n cancel,\n animate,\n }\n}\n"],"names":["animateInner","duration","onUpdate","onFinished","startTs","rafId","tick","ts","progress","Math","updateRafId","id","step","Number","requestAnimationFrame","cancel","cancelAnimationFrame","useAnimate","lastCancelRef","useMainThreadRef","animate","innerCancel"],"mappings":";AAMA,SAASA,aACPC,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;IAEvB;IACA,IAAIC,UAAU;IACd,IAAIC,QAAQ;IAEZ,SAASC,KAAKC,EAAU;QACtB,MAAMC,WAAWC,KAAK,GAAG,CACvBA,KAAK,GAAG,CAAGF,AAAAA,CAAAA,KAAKH,OAAM,IAAK,MAAOH,UAAU,MAC5C;QAGFC,SAASM;IACX;IAEA,SAASE,YAAYC,EAAU;QAC7BN,QAAQM;IACV;IAEA,SAASC,KAAKL,EAAU;QACtB,IAAI,CAACH,SACHA,UAAUS,OAAON;QAGnB,IAAIA,KAAKH,WAAWH,WAAW,KAAK;YAClCK,KAAKC;YACLG,YAAYI,sBAAsBF;QACpC,OACET;IAEJ;IAEAO,YAAYI,sBAAsBF;IAElC,SAASG;QACPC,qBAAqBX;IACvB;IAEA,OAAO;QACLU;IACF;AACF;AAEO,SAASE;IACd,MAAMC,gBAAgBC;IAEtB,SAASJ;QACP;QACAG,cAAc,OAAO;IACvB;IAEA,SAASE,QACPnB,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;QAEvB;QACAY;QACA,MAAM,EAAE,QAAQM,WAAW,EAAE,GAAGrB,aAC9BC,UACAC,UACAC;QAEFe,cAAc,OAAO,GAAGG;IAC1B;IAEA,OAAO;QACLN;QACAK;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useAutoPlay.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useAutoPlay.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 {\n runOnMainThread,\n useEffect,\n useMainThreadRef,\n useRef,\n} from '@lynx-js/react'\n\nimport { useMemoizedFn } from '@lynx-js/lynx-ui-common'\n\ninterface IAutoPlay {\n autoPlay: boolean\n duration: number\n dataCount: number\n autoPlayInterval: number\n prevMT: () => void\n nextMT: () => void\n}\n\nexport function useAutoplay({\n autoPlay,\n autoPlayInterval,\n nextMT,\n duration,\n}: IAutoPlay) {\n const stoppedRef = useRef<boolean>(false)\n const timerMTRef = useMainThreadRef<number>(0)\n const stoppedMTRef = useMainThreadRef<boolean>(false)\n const autoPlayMTRef = useMainThreadRef<boolean>(autoPlay)\n\n function playMT() {\n 'main thread'\n if (stoppedRef.current || !autoPlayMTRef.current) {\n return\n }\n\n timerMTRef.current && clearTimeout(timerMTRef.current)\n timerMTRef.current = setTimeout(() => {\n nextMT()\n playMT()\n }, autoPlayInterval + duration)\n }\n\n function pauseMT() {\n 'main thread'\n if (!autoPlayMTRef.current) {\n return\n }\n timerMTRef.current && clearTimeout(timerMTRef.current)\n stoppedMTRef.current = true\n }\n\n function startMT() {\n 'main thread'\n if (!autoPlayMTRef.current) {\n return\n }\n stoppedMTRef.current = false\n playMT()\n }\n\n function setAutoPlayRef(autoPlayValue: boolean) {\n 'main thread'\n autoPlayMTRef.current = autoPlayValue\n }\n\n const start = useMemoizedFn(() => {\n runOnMainThread(startMT)()\n })\n\n const pause = useMemoizedFn(() => {\n runOnMainThread(pauseMT)()\n })\n\n useEffect(() => {\n runOnMainThread(setAutoPlayRef)(autoPlay)\n if (autoPlay) {\n start()\n } else {\n pause()\n }\n\n return pause\n }, [start, pause, autoPlay])\n\n return {\n pause,\n start,\n pauseMT,\n startMT,\n }\n}\n"],"names":["useAutoplay","autoPlay","autoPlayInterval","nextMT","duration","stoppedRef","useRef","timerMTRef","useMainThreadRef","stoppedMTRef","autoPlayMTRef","playMT","clearTimeout","setTimeout","pauseMT","startMT","setAutoPlayRef","autoPlayValue","start","useMemoizedFn","runOnMainThread","pause","useEffect"],"mappings":";;AAsBO,SAASA,YAAY,EAC1BC,QAAQ,EACRC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACE;IACV,MAAMC,aAAaC,OAAgB;IACnC,MAAMC,aAAaC,iBAAyB;IAC5C,MAAMC,eAAeD,iBAA0B;IAC/C,MAAME,gBAAgBF,iBAA0BP;IAEhD,SAASU;QACP;QACA,IAAIN,WAAW,OAAO,IAAI,CAACK,cAAc,OAAO,EAC9C;QAGFH,WAAW,OAAO,IAAIK,aAAaL,WAAW,OAAO;QACrDA,WAAW,OAAO,GAAGM,WAAW;YAC9BV;YACAQ;QACF,GAAGT,mBAAmBE;IACxB;IAEA,SAASU;QACP;QACA,IAAI,CAACJ,cAAc,OAAO,EACxB;QAEFH,WAAW,OAAO,IAAIK,aAAaL,WAAW,OAAO;QACrDE,aAAa,OAAO,GAAG;IACzB;IAEA,SAASM;QACP;QACA,IAAI,CAACL,cAAc,OAAO,EACxB;QAEFD,aAAa,OAAO,GAAG;QACvBE;IACF;IAEA,SAASK,eAAeC,aAAsB;QAC5C;QACAP,cAAc,OAAO,GAAGO;IAC1B;IAEA,MAAMC,QAAQC,cAAc;QAC1BC,gBAAgBL;IAClB;IAEA,MAAMM,QAAQF,cAAc;QAC1BC,gBAAgBN;IAClB;IAEAQ,UAAU;QACRF,gBAAgBJ,gBAAgBf;QAChC,IAAIA,UACFiB;aAEAG;QAGF,OAAOA;IACT,GAAG;QAACH;QAAOG;QAAOpB;KAAS;IAE3B,OAAO;QACLoB;QACAH;QACAJ;QACAC;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useAutoPlay.jsx","sources":["../../src/hooks/useAutoPlay.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 {\n runOnMainThread,\n useEffect,\n useMainThreadRef,\n useRef,\n} from '@lynx-js/react'\n\nimport { useMemoizedFn } from '@lynx-js/lynx-ui-common'\n\ninterface IAutoPlay {\n autoPlay: boolean\n duration: number\n dataCount: number\n autoPlayInterval: number\n prevMT: () => void\n nextMT: () => void\n}\n\nexport function useAutoplay({\n autoPlay,\n autoPlayInterval,\n nextMT,\n duration,\n}: IAutoPlay) {\n const stoppedRef = useRef<boolean>(false)\n const timerMTRef = useMainThreadRef<number>(0)\n const stoppedMTRef = useMainThreadRef<boolean>(false)\n const autoPlayMTRef = useMainThreadRef<boolean>(autoPlay)\n\n function playMT() {\n 'main thread'\n if (stoppedRef.current || !autoPlayMTRef.current) {\n return\n }\n\n timerMTRef.current && clearTimeout(timerMTRef.current)\n timerMTRef.current = setTimeout(() => {\n nextMT()\n playMT()\n }, autoPlayInterval + duration)\n }\n\n function pauseMT() {\n 'main thread'\n if (!autoPlayMTRef.current) {\n return\n }\n timerMTRef.current && clearTimeout(timerMTRef.current)\n stoppedMTRef.current = true\n }\n\n function startMT() {\n 'main thread'\n if (!autoPlayMTRef.current) {\n return\n }\n stoppedMTRef.current = false\n playMT()\n }\n\n function setAutoPlayRef(autoPlayValue: boolean) {\n 'main thread'\n autoPlayMTRef.current = autoPlayValue\n }\n\n const start = useMemoizedFn(() => {\n runOnMainThread(startMT)()\n })\n\n const pause = useMemoizedFn(() => {\n runOnMainThread(pauseMT)()\n })\n\n useEffect(() => {\n runOnMainThread(setAutoPlayRef)(autoPlay)\n if (autoPlay) {\n start()\n } else {\n pause()\n }\n\n return pause\n }, [start, pause, autoPlay])\n\n return {\n pause,\n start,\n pauseMT,\n startMT,\n }\n}\n"],"names":["useAutoplay","autoPlay","autoPlayInterval","nextMT","duration","stoppedRef","useRef","timerMTRef","useMainThreadRef","stoppedMTRef","autoPlayMTRef","playMT","clearTimeout","setTimeout","pauseMT","startMT","setAutoPlayRef","autoPlayValue","start","useMemoizedFn","runOnMainThread","pause","useEffect"],"mappings":";;AAsBO,SAASA,YAAY,EAC1BC,QAAQ,EACRC,gBAAgB,EAChBC,MAAM,EACNC,QAAQ,EACE;IACV,MAAMC,aAAaC,OAAgB;IACnC,MAAMC,aAAaC,iBAAyB;IAC5C,MAAMC,eAAeD,iBAA0B;IAC/C,MAAME,gBAAgBF,iBAA0BP;IAEhD,SAASU;QACP;QACA,IAAIN,WAAW,OAAO,IAAI,CAACK,cAAc,OAAO,EAC9C;QAGFH,WAAW,OAAO,IAAIK,aAAaL,WAAW,OAAO;QACrDA,WAAW,OAAO,GAAGM,WAAW;YAC9BV;YACAQ;QACF,GAAGT,mBAAmBE;IACxB;IAEA,SAASU;QACP;QACA,IAAI,CAACJ,cAAc,OAAO,EACxB;QAEFH,WAAW,OAAO,IAAIK,aAAaL,WAAW,OAAO;QACrDE,aAAa,OAAO,GAAG;IACzB;IAEA,SAASM;QACP;QACA,IAAI,CAACL,cAAc,OAAO,EACxB;QAEFD,aAAa,OAAO,GAAG;QACvBE;IACF;IAEA,SAASK,eAAeC,aAAsB;QAC5C;QACAP,cAAc,OAAO,GAAGO;IAC1B;IAEA,MAAMC,QAAQC,cAAc;QAC1BC,gBAAgBL;IAClB;IAEA,MAAMM,QAAQF,cAAc;QAC1BC,gBAAgBN;IAClB;IAEAQ,UAAU;QACRF,gBAAgBJ,gBAAgBf;QAChC,IAAIA,UACFiB;aAEAG;QAGF,OAAOA;IACT,GAAG;QAACH;QAAOG;QAAOpB;KAAS;IAE3B,OAAO;QACLoB;QACAH;QACAJ;QACAC;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useAxisLock.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useAxisLock.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nimport { GESTURE_THRESHOLD } from '../const'\nimport type { SwiperProps } from '../types'\n\nfunction isAngleInRanges(angle: number, ranges: [number, number][]) {\n 'main thread'\n return ranges.some(([start, end]) => {\n if (start <= end) {\n return angle >= start && angle <= end\n } else {\n return angle >= start || angle <= end // Handles wrap-around cases like [-180, -135] or [135, 180]\n }\n })\n}\n\nexport function useAxisLock({\n consumeSlideEvent,\n experimentalHorizontalSwipeOnly,\n}: {\n consumeSlideEvent: NonNullable<SwiperProps<unknown>['consumeSlideEvent']>\n experimentalHorizontalSwipeOnly: boolean\n}) {\n const gestureLockedRef = useMainThreadRef<boolean>(false)\n const isMainAxisLockedRef = useMainThreadRef<boolean>(false)\n const touchStartRef = useMainThreadRef<number>(0)\n const touchStartCrossAxisRef = useMainThreadRef<number>(0)\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n touchStartRef.current = event.detail.x\n\n touchStartCrossAxisRef.current = event.detail.y\n\n gestureLockedRef.current = false\n isMainAxisLockedRef.current = false\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (!experimentalHorizontalSwipeOnly) {\n return false\n }\n\n const deltaX = event.detail.x - touchStartRef.current\n\n const deltaY = event.detail.y - touchStartCrossAxisRef.current\n\n // Calculate total displacement (distance)\n const displacement = Math.sqrt(deltaX * deltaX + deltaY * deltaY)\n\n if (!gestureLockedRef.current && displacement > GESTURE_THRESHOLD) {\n const angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI\n\n if (isAngleInRanges(angle, consumeSlideEvent)) {\n gestureLockedRef.current = true\n isMainAxisLockedRef.current = false\n } else {\n gestureLockedRef.current = true\n isMainAxisLockedRef.current = true\n }\n }\n\n return isMainAxisLockedRef.current\n }\n\n function handleVelocity() {\n 'main thread'\n return isMainAxisLockedRef.current\n }\n\n function handleTouchEnd() {\n 'main thread'\n gestureLockedRef.current = false\n isMainAxisLockedRef.current = false\n }\n\n return {\n handleTouchStart,\n handleTouchMove,\n handleTouchEnd,\n handleVelocity,\n }\n}\n"],"names":["isAngleInRanges","angle","ranges","start","end","useAxisLock","consumeSlideEvent","experimentalHorizontalSwipeOnly","gestureLockedRef","useMainThreadRef","isMainAxisLockedRef","touchStartRef","touchStartCrossAxisRef","handleTouchStart","event","handleTouchMove","deltaX","deltaY","displacement","Math","GESTURE_THRESHOLD","handleVelocity","handleTouchEnd"],"mappings":";;AAWA,SAASA,gBAAgBC,KAAa,EAAEC,MAA0B;IAChE;IACA,OAAOA,OAAO,IAAI,CAAC,CAAC,CAACC,OAAOC,IAAI;QAC9B,IAAID,SAASC,KACX,OAAOH,SAASE,SAASF,SAASG;QAElC,OAAOH,SAASE,SAASF,SAASG;IAEtC;AACF;AAEO,SAASC,YAAY,EAC1BC,iBAAiB,EACjBC,+BAA+B,EAIhC;IACC,MAAMC,mBAAmBC,iBAA0B;IACnD,MAAMC,sBAAsBD,iBAA0B;IACtD,MAAME,gBAAgBF,iBAAyB;IAC/C,MAAMG,yBAAyBH,iBAAyB;IAExD,SAASI,iBAAiBC,KAA4B;QACpD;QAEAH,cAAc,OAAO,GAAGG,MAAM,MAAM,CAAC,CAAC;QAEtCF,uBAAuB,OAAO,GAAGE,MAAM,MAAM,CAAC,CAAC;QAE/CN,iBAAiB,OAAO,GAAG;QAC3BE,oBAAoB,OAAO,GAAG;IAChC;IAEA,SAASK,gBAAgBD,KAA4B;QACnD;QAEA,IAAI,CAACP,iCACH,OAAO;QAGT,MAAMS,SAASF,MAAM,MAAM,CAAC,CAAC,GAAGH,cAAc,OAAO;QAErD,MAAMM,SAASH,MAAM,MAAM,CAAC,CAAC,GAAGF,uBAAuB,OAAO;QAG9D,MAAMM,eAAeC,KAAK,IAAI,CAACH,SAASA,SAASC,SAASA;QAE1D,IAAI,CAACT,iBAAiB,OAAO,IAAIU,eAAeE,mBAAmB;YACjE,MAAMnB,QAAQkB,AAA6B,MAA7BA,KAAK,KAAK,CAACF,QAAQD,UAAgBG,KAAK,EAAE;YAExD,IAAInB,gBAAgBC,OAAOK,oBAAoB;gBAC7CE,iBAAiB,OAAO,GAAG;gBAC3BE,oBAAoB,OAAO,GAAG;YAChC,OAAO;gBACLF,iBAAiB,OAAO,GAAG;gBAC3BE,oBAAoB,OAAO,GAAG;YAChC;QACF;QAEA,OAAOA,oBAAoB,OAAO;IACpC;IAEA,SAASW;QACP;QACA,OAAOX,oBAAoB,OAAO;IACpC;IAEA,SAASY;QACP;QACAd,iBAAiB,OAAO,GAAG;QAC3BE,oBAAoB,OAAO,GAAG;IAChC;IAEA,OAAO;QACLG;QACAE;QACAO;QACAD;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useAxisLock.jsx","sources":["../../src/hooks/useAxisLock.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nimport { GESTURE_THRESHOLD } from '../const'\nimport type { SwiperProps } from '../types'\n\nfunction isAngleInRanges(angle: number, ranges: [number, number][]) {\n 'main thread'\n return ranges.some(([start, end]) => {\n if (start <= end) {\n return angle >= start && angle <= end\n } else {\n return angle >= start || angle <= end // Handles wrap-around cases like [-180, -135] or [135, 180]\n }\n })\n}\n\nexport function useAxisLock({\n consumeSlideEvent,\n experimentalHorizontalSwipeOnly,\n}: {\n consumeSlideEvent: NonNullable<SwiperProps<unknown>['consumeSlideEvent']>\n experimentalHorizontalSwipeOnly: boolean\n}) {\n const gestureLockedRef = useMainThreadRef<boolean>(false)\n const isMainAxisLockedRef = useMainThreadRef<boolean>(false)\n const touchStartRef = useMainThreadRef<number>(0)\n const touchStartCrossAxisRef = useMainThreadRef<number>(0)\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n touchStartRef.current = event.detail.x\n\n touchStartCrossAxisRef.current = event.detail.y\n\n gestureLockedRef.current = false\n isMainAxisLockedRef.current = false\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (!experimentalHorizontalSwipeOnly) {\n return false\n }\n\n const deltaX = event.detail.x - touchStartRef.current\n\n const deltaY = event.detail.y - touchStartCrossAxisRef.current\n\n // Calculate total displacement (distance)\n const displacement = Math.sqrt(deltaX * deltaX + deltaY * deltaY)\n\n if (!gestureLockedRef.current && displacement > GESTURE_THRESHOLD) {\n const angle = Math.atan2(deltaY, deltaX) * 180 / Math.PI\n\n if (isAngleInRanges(angle, consumeSlideEvent)) {\n gestureLockedRef.current = true\n isMainAxisLockedRef.current = false\n } else {\n gestureLockedRef.current = true\n isMainAxisLockedRef.current = true\n }\n }\n\n return isMainAxisLockedRef.current\n }\n\n function handleVelocity() {\n 'main thread'\n return isMainAxisLockedRef.current\n }\n\n function handleTouchEnd() {\n 'main thread'\n gestureLockedRef.current = false\n isMainAxisLockedRef.current = false\n }\n\n return {\n handleTouchStart,\n handleTouchMove,\n handleTouchEnd,\n handleVelocity,\n }\n}\n"],"names":["isAngleInRanges","angle","ranges","start","end","useAxisLock","consumeSlideEvent","experimentalHorizontalSwipeOnly","gestureLockedRef","useMainThreadRef","isMainAxisLockedRef","touchStartRef","touchStartCrossAxisRef","handleTouchStart","event","handleTouchMove","deltaX","deltaY","displacement","Math","GESTURE_THRESHOLD","handleVelocity","handleTouchEnd"],"mappings":";;AAWA,SAASA,gBAAgBC,KAAa,EAAEC,MAA0B;IAChE;IACA,OAAOA,OAAO,IAAI,CAAC,CAAC,CAACC,OAAOC,IAAI;QAC9B,IAAID,SAASC,KACX,OAAOH,SAASE,SAASF,SAASG;QAElC,OAAOH,SAASE,SA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sx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useBounceConfig.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 { BounceConfig } from '../types'\n\nfunction useBounceConfig(bounceConfig?: BounceConfig) {\n const {\n startBounceItem,\n endBounceItem,\n enable = false,\n startBounceItemWidth = 50,\n endBounceItemWidth = 50,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n } = bounceConfig ?? {}\n\n return {\n enableBounce: enable,\n startBounceItem,\n endBounceItem,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n }\n}\n\nexport { useBounceConfig }\n"],"names":["useBounceConfig","bounceConfig","startBounceItem","endBounceItem","enable","startBounceItemWidth","endBounceItemWidth","onStartBounceItemBounce","onEndBounceItemBounce"],"mappings":"AAMA,SAASA,gBAAgBC,YAA2B;IAClD,MAAM,EACJC,eAAe,EACfC,aAAa,EACbC,SAAS,KAAK,EACdC,uBAAuB,EAAE,EACzBC,qBAAqB,EAAE,EACvBC,uBAAuB,EACvBC,qBAAqB,EACtB,GAAGP,gBAAgB,CAAC;IAErB,OAAO;QACL,cAAcG;QACdF;QACAC;QACAE;QACAC;QACAC;QACAC;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useBounceConfig.jsx","sources":["../../src/hooks/useBounceConfig.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 { BounceConfig } from '../types'\n\nfunction useBounceConfig(bounceConfig?: BounceConfig) {\n const {\n startBounceItem,\n endBounceItem,\n enable = false,\n startBounceItemWidth = 50,\n endBounceItemWidth = 50,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n } = bounceConfig ?? {}\n\n return {\n enableBounce: enable,\n startBounceItem,\n endBounceItem,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n }\n}\n\nexport { useBounceConfig }\n"],"names":["useBounceConfig","bounceConfig","startBounceItem","endBounceItem","enable","startBounceItemWidth","endBounceItemWidth","onStartBounceItemBounce","onEndBounceItemBounce"],"mappings":"AAMA,SAASA,gBAAgBC,YAA2B;IAClD,MAAM,EACJC,eAAe,EACfC,aAAa,EACbC,SAAS,KAAK,EACdC,uBAAuB,EAAE,EACzBC,qBAAqB,EAAE,EACvBC,uBAAuB,EACvBC,qBAAqB,EACtB,GAAGP,gBAAgB,CAAC;IAErB,OAAO;QACL,cAAcG;QACdF;QACAC;QACAE;QACAC;QACAC;QACAC;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useBounceView.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useBounceView.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 type { ReactElement } from '@lynx-js/react'\n\nimport type { CompoundModeConfig, SwiperProps } from '../types'\n\nfunction useBounceView({\n startBounceItem,\n endBounceItem,\n RTL,\n itemWidth,\n count,\n containerWidth,\n mode,\n loop,\n}: {\n startBounceItem?: ReactElement\n endBounceItem?: ReactElement\n RTL: SwiperProps<unknown>['RTL']\n itemWidth: number\n containerWidth: number\n count: number\n mode: CompoundModeConfig['mode']\n loop: boolean\n}) {\n const bounceStartView = startBounceItem\n ? (\n <view class={RTL ? 'bounce-start-item-RTL' : 'bounce-start-item'}>\n {startBounceItem}\n </view>\n )\n : null\n\n const shouldShowEndBounce = mode === 'normal' && loop === false\n && count * itemWidth >= containerWidth\n\n const bounceEndView = endBounceItem && shouldShowEndBounce\n ? (\n <view class={RTL ? 'bounce-end-item-RTL' : 'bounce-end-item'}>\n {endBounceItem}\n </view>\n )\n : null\n\n return { bounceStartView, bounceEndView }\n}\n\nexport { useBounceView }\n"],"names":["useBounceView","startBounceItem","endBounceItem","RTL","itemWidth","count","containerWidth","mode","loop","bounceStartView","view","shouldShowEndBounce","bounceEndView"],"mappings":"AAQA,SAASA,cAAc,EACrBC,eAAe,EACfC,aAAa,EACbC,GAAG,EACHC,SAAS,EACTC,KAAK,EACLC,cAAc,EACdC,IAAI,EACJC,IAAI,EAUL;IACC,MAAMC,kBAAkBR,mBAEnBS,KAAK,OAAOP,MAAM,0BAA0B,qBAAqB;QAChE,CAACF,gBAAgB;MACnB,EAAES,QAEF;IAEJ,MAAMC,sBAAsBJ,AAAS,aAATA,QAAqBC,AAAS,UAATA,QAC5CH,QAAQD,aAAaE;IAE1B,MAAMM,gBAAgBV,iBAAiBS,uBAElCD,KAAK,OAAOP,MAAM,wBAAwB,mBAAmB;QAC5D,CAACD,cAAc;MACjB,EAAEQ,QAEF;IAEJ,OAAO;QAAED;QAAiBG;IAAc;AAC1C"}
1
+ {"version":3,"file":"hooks/useBounceView.jsx","sources":["../../src/hooks/useBounceView.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 type { ReactElement } from '@lynx-js/react'\n\nimport type { CompoundModeConfig, SwiperProps } from '../types'\n\nfunction useBounceView({\n startBounceItem,\n endBounceItem,\n RTL,\n itemWidth,\n count,\n containerWidth,\n mode,\n loop,\n}: {\n startBounceItem?: ReactElement\n endBounceItem?: ReactElement\n RTL: SwiperProps<unknown>['RTL']\n itemWidth: number\n containerWidth: number\n count: number\n mode: CompoundModeConfig['mode']\n loop: boolean\n}) {\n const bounceStartView = startBounceItem\n ? (\n <view class={RTL ? 'bounce-start-item-RTL' : 'bounce-start-item'}>\n {startBounceItem}\n </view>\n )\n : null\n\n const shouldShowEndBounce = mode === 'normal' && loop === false\n && count * itemWidth >= containerWidth\n\n const bounceEndView = endBounceItem && shouldShowEndBounce\n ? (\n <view class={RTL ? 'bounce-end-item-RTL' : 'bounce-end-item'}>\n {endBounceItem}\n </view>\n )\n : null\n\n return { bounceStartView, bounceEndView }\n}\n\nexport { useBounceView }\n"],"names":["useBounceView","startBounceItem","endBounceItem","RTL","itemWidth","count","containerWidth","mode","loop","bounceStartView","view","shouldShowEndBounce","bounceEndView"],"mappings":"AAQA,SAASA,cAAc,EACrBC,eAAe,EACfC,aAAa,EACbC,GAAG,EACHC,SAAS,EACTC,KAAK,EACLC,cAAc,EACdC,IAAI,EACJC,IAAI,EAUL;IACC,MAAMC,kBAAkBR,mBAEnBS,KAAK,OAAOP,MAAM,0BAA0B,qBAAqB;QAChE,CAACF,gBAAgB;MACnB,EAAES,QAEF;IAEJ,MAAMC,sBAAsBJ,AAAS,aAATA,QAAqBC,AAAS,UAATA,QAC5CH,QAAQD,aAAaE;IAE1B,MAAMM,gBAAgBV,iBAAiBS,uBAElCD,KAAK,OAAOP,MAAM,wBAAwB,mBAAmB;QAC5D,CAACD,cAAc;MACjB,EAAEQ,QAEF;IAEJ,OAAO;QAAED;QAAiBG;IAAc;AAC1C"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useChange.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useChange.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 { runOnBackground, useMainThreadRef } from '@lynx-js/react'\n\nimport { SwipeDirection } from '../types'\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\nimport { eqOrGtMT, eqOrLtMT, fixPrecisionMT, safeEqualMT } from '../utils'\n\ninterface UseChangeOpts extends\n Pick<\n SwiperProps<unknown>,\n 'containerWidth' | 'onSwipeStart' | 'onSwipeStop'\n >\n{\n onChange?: (offset: number) => void\n size: number\n spaceBetween: number\n dataCount: number\n offsetLimit: OffsetLimitResult\n 'main-thread:onOffsetChange'?: (offset: number) => void\n modeConfig: CompoundModeConfig\n}\n\n/**\n * This hook handles change related things\n * Including `onChange` and `main-thread:onOffsetChange`\n */\nexport function useChange({\n onChange,\n size: _size,\n spaceBetween,\n dataCount,\n onSwipeStart,\n onSwipeStop,\n offsetLimit,\n 'main-thread:onOffsetChange': onOffsetChange,\n}: UseChangeOpts) {\n const prevIndexMTRef = useMainThreadRef<number>(0)\n const prevOffsetMTRef = useMainThreadRef<number>(0)\n const currentIndexMTRef = useMainThreadRef<number>(0)\n\n const size = _size + spaceBetween\n\n function callOnChange(currentIndex: number) {\n if (onChange) {\n onChange(currentIndex)\n }\n }\n\n function callOnSwipeStart(currentIndex: number) {\n if (onSwipeStart) {\n onSwipeStart(currentIndex)\n }\n }\n function callOnSwipeStop(currentIndex: number) {\n if (onSwipeStop) {\n onSwipeStop(currentIndex)\n }\n }\n\n function setChangeSwipeStopMT() {\n 'main thread'\n runOnBackground(callOnSwipeStop)(currentIndexMTRef.current)\n }\n\n function setChangeSwipeStartMT() {\n 'main thread'\n runOnBackground(callOnSwipeStart)(currentIndexMTRef.current)\n }\n\n function setChangeOffset(offset: number, direction: SwipeDirection) {\n 'main thread'\n\n function mod(n: number, m: number) {\n return ((n % m) + m) % m\n }\n\n // Calculate raw index with proper sign handling\n const rawIndex = fixPrecisionMT(-offset / size)\n let currentIndex: number\n\n if (direction === SwipeDirection.NORMAL) {\n currentIndex = Math.floor(rawIndex)\n } else if (direction === SwipeDirection.REVERT) {\n currentIndex = Math.ceil(rawIndex)\n } else {\n currentIndex = currentIndexMTRef.current\n }\n\n currentIndex = mod(currentIndex, dataCount || Number.MAX_SAFE_INTEGER)\n\n // If offsetLimit is applied, swiper could not scroll to the end.\n // In this case, when it can no longer scroll, set index to 0 or max\n // offsetLimit is always 0 in loop mode, so code below will only work when loop is false\n if (\n !safeEqualMT(offsetLimit.startLimit, 0)\n && eqOrGtMT(offset, -offsetLimit.startLimit)\n ) {\n currentIndex = 0\n } else if (\n !safeEqualMT(offsetLimit.endLimit, 0)\n && eqOrLtMT(offset, -size * (dataCount - 1) + offsetLimit.endLimit)\n ) {\n currentIndex = dataCount - 1\n }\n\n currentIndexMTRef.current = currentIndex\n if (onOffsetChange && !safeEqualMT(offset, prevOffsetMTRef.current)) {\n onOffsetChange(offset)\n }\n\n if (!safeEqualMT(prevIndexMTRef.current, currentIndex)) {\n runOnBackground(callOnChange)(currentIndex)\n prevIndexMTRef.current = currentIndex\n }\n\n prevOffsetMTRef.current = offset\n }\n\n return {\n setChangeOffset,\n setChangeSwipeStartMT,\n setChangeSwipeStopMT,\n }\n}\n"],"names":["useChange","onChange","_size","spaceBetween","dataCount","onSwipeStart","onSwipeStop","offsetLimit","onOffsetChange","prevIndexMTRef","useMainThreadRef","prevOffsetMTRef","currentIndexMTRef","size","callOnChange","currentIndex","callOnSwipeStart","callOnSwipeStop","setChangeSwipeStopMT","runOnBackground","setChangeSwipeStartMT","setChangeOffset","offset","direction","mod","n","m","rawIndex","fixPrecisionMT","SwipeDirection","Math","Number","safeEqualMT","eqOrGtMT","eqOrLtMT"],"mappings":";;;AAiCO,SAASA,UAAU,EACxBC,QAAQ,EACR,MAAMC,KAAK,EACXC,YAAY,EACZC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,WAAW,EACX,8BAA8BC,cAAc,EAC9B;IACd,MAAMC,iBAAiBC,iBAAyB;IAChD,MAAMC,kBAAkBD,iBAAyB;IACjD,MAAME,oBAAoBF,iBAAyB;IAEnD,MAAMG,OAAOX,QAAQC;IAErB,SAASW,aAAaC,YAAoB;QACxC,IAAId,UACFA,SAASc;IAEb;IAEA,SAASC,iBAAiBD,YAAoB;QAC5C,IAAIV,cACFA,aAAaU;IAEjB;IACA,SAASE,gBAAgBF,YAAoB;QAC3C,IAAIT,aACFA,YAAYS;IAEhB;IAEA,SAASG;QACP;QACAC,gBAAgBF,iBAAiBL,kBAAkB,OAAO;IAC5D;IAEA,SAASQ;QACP;QACAD,gBAAgBH,kBAAkBJ,kBAAkB,OAAO;IAC7D;IAEA,SAASS,gBAAgBC,MAAc,EAAEC,SAAyB;QAChE;QAEA,SAASC,IAAIC,CAAS,EAAEC,CAAS;YAC/B,OAAQ,AAACD,CAAAA,IAAIC,IAAKA,CAAAA,IAAKA;QACzB;QAGA,MAAMC,WAAWC,eAAe,CAACN,SAAST;QAC1C,IAAIE;QAGFA,eADEQ,cAAcM,eAAe,MAAM,GACtBC,KAAK,KAAK,CAACH,YACjBJ,cAAcM,eAAe,MAAM,GAC7BC,KAAK,IAAI,CAACH,YAEVf,kBAAkB,OAAO;QAG1CG,eAAeS,IAAIT,cAAcX,aAAa2B,OAAO,gBAAgB;QAKrE,IACE,CAACC,YAAYzB,YAAY,UAAU,EAAE,MAClC0B,SAASX,QAAQ,CAACf,YAAY,UAAU,GAE3CQ,eAAe;aACV,IACL,CAACiB,YAAYzB,YAAY,QAAQ,EAAE,MAChC2B,SAASZ,QAAQ,CAACT,OAAQT,CAAAA,YAAY,KAAKG,YAAY,QAAQ,GAElEQ,eAAeX,YAAY;QAG7BQ,kBAAkB,OAAO,GAAGG;QAC5B,IAAIP,kBAAkB,CAACwB,YAAYV,QAAQX,gBAAgB,OAAO,GAChEH,eAAec;QAGjB,IAAI,CAACU,YAAYvB,eAAe,OAAO,EAAEM,eAAe;YACtDI,gBAAgBL,cAAcC;YAC9BN,eAAe,OAAO,GAAGM;QAC3B;QAEAJ,gBAAgB,OAAO,GAAGW;IAC5B;IAEA,OAAO;QACLD;QACAD;QACAF;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useChange.jsx","sources":["../../src/hooks/useChange.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 { runOnBackground, useMainThreadRef } from '@lynx-js/react'\n\nimport { SwipeDirection } from '../types'\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\nimport { eqOrGtMT, eqOrLtMT, fixPrecisionMT, safeEqualMT } from '../utils'\n\ninterface UseChangeOpts extends\n Pick<\n SwiperProps<unknown>,\n 'containerWidth' | 'onSwipeStart' | 'onSwipeStop'\n >\n{\n onChange?: (offset: number) => void\n size: number\n spaceBetween: number\n dataCount: number\n offsetLimit: OffsetLimitResult\n 'main-thread:onOffsetChange'?: (offset: number) => void\n modeConfig: CompoundModeConfig\n}\n\n/**\n * This hook handles change related things\n * Including `onChange` and `main-thread:onOffsetChange`\n */\nexport function useChange({\n onChange,\n size: _size,\n spaceBetween,\n dataCount,\n onSwipeStart,\n onSwipeStop,\n offsetLimit,\n 'main-thread:onOffsetChange': onOffsetChange,\n}: UseChangeOpts) {\n const prevIndexMTRef = useMainThreadRef<number>(0)\n const prevOffsetMTRef = useMainThreadRef<number>(0)\n const currentIndexMTRef = useMainThreadRef<number>(0)\n\n const size = _size + spaceBetween\n\n function callOnChange(currentIndex: number) {\n if (onChange) {\n onChange(currentIndex)\n }\n }\n\n function callOnSwipeStart(currentIndex: number) {\n if (onSwipeStart) {\n onSwipeStart(currentIndex)\n }\n }\n function callOnSwipeStop(currentIndex: number) {\n if (onSwipeStop) {\n onSwipeStop(currentIndex)\n }\n }\n\n function setChangeSwipeStopMT() {\n 'main thread'\n runOnBackground(callOnSwipeStop)(currentIndexMTRef.current)\n }\n\n function setChangeSwipeStartMT() {\n 'main thread'\n runOnBackground(callOnSwipeStart)(currentIndexMTRef.current)\n }\n\n function setChangeOffset(offset: number, direction: SwipeDirection) {\n 'main thread'\n\n function mod(n: number, m: number) {\n return ((n % m) + m) % m\n }\n\n // Calculate raw index with proper sign handling\n const rawIndex = fixPrecisionMT(-offset / size)\n let currentIndex: number\n\n if (direction === SwipeDirection.NORMAL) {\n currentIndex = Math.floor(rawIndex)\n } else if (direction === SwipeDirection.REVERT) {\n currentIndex = Math.ceil(rawIndex)\n } else {\n currentIndex = currentIndexMTRef.current\n }\n\n currentIndex = mod(currentIndex, dataCount || Number.MAX_SAFE_INTEGER)\n\n // If offsetLimit is applied, swiper could not scroll to the end.\n // In this case, when it can no longer scroll, set index to 0 or max\n // offsetLimit is always 0 in loop mode, so code below will only work when loop is false\n if (\n !safeEqualMT(offsetLimit.startLimit, 0)\n && eqOrGtMT(offset, -offsetLimit.startLimit)\n ) {\n currentIndex = 0\n } else if (\n !safeEqualMT(offsetLimit.endLimit, 0)\n && eqOrLtMT(offset, -size * (dataCount - 1) + offsetLimit.endLimit)\n ) {\n currentIndex = dataCount - 1\n }\n\n currentIndexMTRef.current = currentIndex\n if (onOffsetChange && !safeEqualMT(offset, prevOffsetMTRef.current)) {\n onOffsetChange(offset)\n }\n\n if (!safeEqualMT(prevIndexMTRef.current, currentIndex)) {\n runOnBackground(callOnChange)(currentIndex)\n prevIndexMTRef.current = currentIndex\n }\n\n prevOffsetMTRef.current = offset\n }\n\n return {\n setChangeOffset,\n setChangeSwipeStartMT,\n setChangeSwipeStopMT,\n }\n}\n"],"names":["useChange","onChange","_size","spaceBetween","dataCount","onSwipeStart","onSwipeStop","offsetLimit","onOffsetChange","prevIndexMTRef","useMainThreadRef","prevOffsetMTRef","currentIndexMTRef","size","callOnChange","currentIndex","callOnSwipeStart","callOnSwipeStop","setChangeSwipeStopMT","runOnBackground","setChangeSwipeStartMT","setChangeOffset","offset","direction","mod","n","m","rawIndex","fixPrecisionMT","SwipeDirection","Math","Number","safeEqualMT","eqOrGtMT","eqOrLtMT"],"mappings":";;;AAiCO,SAASA,UAAU,EACxBC,QAAQ,EACR,MAAMC,KAAK,EACXC,YAAY,EACZC,SAAS,EACTC,YAAY,EACZC,WAAW,EACXC,WAAW,EACX,8BAA8BC,cAAc,EAC9B;IACd,MAAMC,iBAAiBC,iBAAyB;IAChD,MAAMC,kBAAkBD,iBAAyB;IACjD,MAAME,oBAAoBF,iBAAyB;IAEnD,MAAMG,OAAOX,QAAQC;IAErB,SAASW,aAAaC,YAAoB;QACxC,IAAId,UACFA,SAASc;IAEb;IAEA,SAASC,iBAAiBD,YAAoB;QAC5C,IAAIV,cACFA,aAAaU;IAEjB;IACA,SAASE,gBAAgBF,YAAoB;QAC3C,IAAIT,aACFA,YAAYS;IAEhB;IAEA,SAASG;QACP;QACAC,gBAAgBF,iBAAiBL,kBAAkB,OAAO;IAC5D;IAEA,SAASQ;QACP;QACAD,gBAAgBH,kBAAkBJ,kBAAkB,OAAO;IAC7D;IAEA,SAASS,gBAAgBC,MAAc,EAAEC,SAAyB;QAChE;QAEA,SAASC,IAAIC,CAAS,EAAEC,CAAS;YAC/B,OAAQ,AAACD,CAAAA,IAAIC,IAAKA,CAAAA,IAAKA;QACzB;QAGA,MAAMC,WAAWC,eAAe,CAACN,SAAST;QAC1C,IAAIE;QAGFA,eADEQ,cAAcM,eAAe,MAAM,GACtBC,KAAK,KAAK,CAACH,YACjBJ,cAAcM,eAAe,MAAM,GAC7BC,KAAK,IAAI,CAACH,YAEVf,kBAAkB,OAAO;QAG1CG,eAAeS,IAAIT,cAAcX,aAAa2B,OAAO,gBAAgB;QAKrE,IACE,CAACC,YAAYzB,YAAY,UAAU,EAAE,MAClC0B,SAASX,QAAQ,CAACf,YAAY,UAAU,GAE3CQ,eAAe;aACV,IACL,CAACiB,YAAYzB,YAAY,QAAQ,EAAE,MAChC2B,SAASZ,QAAQ,CAACT,OAAQT,CAAAA,YAAY,KAAKG,YAAY,QAAQ,GAElEQ,eAAeX,YAAY;QAG7BQ,kBAAkB,OAAO,GAAGG;QAC5B,IAAIP,kBAAkB,CAACwB,YAAYV,QAAQX,gBAAgB,OAAO,GAChEH,eAAec;QAGjB,IAAI,CAACU,YAAYvB,eAAe,OAAO,EAAEM,eAAe;YACtDI,gBAAgBL,cAAcC;YAC9BN,eAAe,OAAO,GAAGM;QAC3B;QAEAJ,gBAAgB,OAAO,GAAGW;IAC5B;IAEA,OAAO;QACLD;QACAD;QACAF;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useDirection.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useDirection.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nimport { SwipeDirection } from '../types'\nimport type { SwiperProps } from '../types'\n\nexport function useDirection({ RTL }: { RTL: SwiperProps<unknown>['RTL'] }) {\n const startXRef = useMainThreadRef<number>(0)\n const directionRef = useMainThreadRef<SwipeDirection>(SwipeDirection.NONE)\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n startXRef.current = event.detail.x\n directionRef.current = SwipeDirection.NONE\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (event.detail.x < startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.REVERT : SwipeDirection.NORMAL\n } else if (event.detail.x > startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.NORMAL : SwipeDirection.REVERT\n } else {\n directionRef.current = SwipeDirection.NONE\n }\n }\n\n function handleTouchEnd(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (event.detail.x < startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.REVERT : SwipeDirection.NORMAL\n } else if (event.detail.x > startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.NORMAL : SwipeDirection.REVERT\n } else {\n directionRef.current = SwipeDirection.NONE\n }\n }\n\n function overrideDirection(direction: SwipeDirection) {\n 'main thread'\n directionRef.current = direction\n }\n\n return {\n handleTouchStart,\n handleTouchEnd,\n handleTouchMove,\n overrideDirection,\n directionRef,\n }\n}\n"],"names":["useDirection","RTL","startXRef","useMainThreadRef","directionRef","SwipeDirection","handleTouchStart","event","handleTouchMove","handleTouchEnd","overrideDirection","direction"],"mappings":";;AAWO,SAASA,aAAa,EAAEC,GAAG,EAAwC;IACxE,MAAMC,YAAYC,iBAAyB;IAC3C,MAAMC,eAAeD,iBAAiCE,eAAe,IAAI;IAEzE,SAASC,iBAAiBC,KAA4B;QACpD;QAEAL,UAAU,OAAO,GAAGK,MAAM,MAAM,CAAC,CAAC;QAClCH,aAAa,OAAO,GAAGC,eAAe,IAAI;IAC5C;IAEA,SAASG,gBAAgBD,KAA4B;QACnD;QAEA,IAAIA,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EACpCE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aACrE,IAAIE,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EAC3CE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aAE1ED,aAAa,OAAO,GAAGC,eAAe,IAAI;IAE9C;IAEA,SAASI,eAAeF,KAA4B;QAClD;QAEA,IAAIA,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EACpCE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aACrE,IAAIE,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EAC3CE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aAE1ED,aAAa,OAAO,GAAGC,eAAe,IAAI;IAE9C;IAEA,SAASK,kBAAkBC,SAAyB;QAClD;QACAP,aAAa,OAAO,GAAGO;IACzB;IAEA,OAAO;QACLL;QACAG;QACAD;QACAE;QACAN;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useDirection.jsx","sources":["../../src/hooks/useDirection.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nimport { SwipeDirection } from '../types'\nimport type { SwiperProps } from '../types'\n\nexport function useDirection({ RTL }: { RTL: SwiperProps<unknown>['RTL'] }) {\n const startXRef = useMainThreadRef<number>(0)\n const directionRef = useMainThreadRef<SwipeDirection>(SwipeDirection.NONE)\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n startXRef.current = event.detail.x\n directionRef.current = SwipeDirection.NONE\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (event.detail.x < startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.REVERT : SwipeDirection.NORMAL\n } else if (event.detail.x > startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.NORMAL : SwipeDirection.REVERT\n } else {\n directionRef.current = SwipeDirection.NONE\n }\n }\n\n function handleTouchEnd(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (event.detail.x < startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.REVERT : SwipeDirection.NORMAL\n } else if (event.detail.x > startXRef.current) {\n directionRef.current = RTL ? SwipeDirection.NORMAL : SwipeDirection.REVERT\n } else {\n directionRef.current = SwipeDirection.NONE\n }\n }\n\n function overrideDirection(direction: SwipeDirection) {\n 'main thread'\n directionRef.current = direction\n }\n\n return {\n handleTouchStart,\n handleTouchEnd,\n handleTouchMove,\n overrideDirection,\n directionRef,\n }\n}\n"],"names":["useDirection","RTL","startXRef","useMainThreadRef","directionRef","SwipeDirection","handleTouchStart","event","handleTouchMove","handleTouchEnd","overrideDirection","direction"],"mappings":";;AAWO,SAASA,aAAa,EAAEC,GAAG,EAAwC;IACxE,MAAMC,YAAYC,iBAAyB;IAC3C,MAAMC,eAAeD,iBAAiCE,eAAe,IAAI;IAEzE,SAASC,iBAAiBC,KAA4B;QACpD;QAEAL,UAAU,OAAO,GAAGK,MAAM,MAAM,CAAC,CAAC;QAClCH,aAAa,OAAO,GAAGC,eAAe,IAAI;IAC5C;IAEA,SAASG,gBAAgBD,KAA4B;QACnD;QAEA,IAAIA,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EACpCE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aACrE,IAAIE,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EAC3CE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aAE1ED,aAAa,OAAO,GAAGC,eAAe,IAAI;IAE9C;IAEA,SAASI,eAAeF,KAA4B;QAClD;QAEA,IAAIA,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EACpCE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aACrE,IAAIE,MAAM,MAAM,CAAC,CAAC,GAAGL,UAAU,OAAO,EAC3CE,aAAa,OAAO,GAAGH,MAAMI,eAAe,MAAM,GAAGA,eAAe,MAAM;aAE1ED,aAAa,OAAO,GAAGC,eAAe,IAAI;IAE9C;IAEA,SAASK,kBAAkBC,SAAyB;QAClD;QACAP,aAAa,OAAO,GAAGO;IACzB;IAEA,OAAO;QACLL;QACAG;QACAD;QACAE;QACAN;IACF;AACF"}
@@ -58,6 +58,7 @@ function useFirstScreenStyle(props) {
58
58
  };
59
59
  }
60
60
  const hooks_useFirstScreenStyle = useFirstScreenStyle;
61
- export { hooks_useFirstScreenStyle as default, getInnerContainerWidth, getInnerContainerWidthMT };
61
+ export default hooks_useFirstScreenStyle;
62
+ export { getInnerContainerWidth, getInnerContainerWidthMT };
62
63
 
63
64
  //# sourceMappingURL=useFirstScreenStyle.jsx.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useFirstScreenStyle.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useFirstScreenStyle.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 { useMemo } from '@lynx-js/react'\n\nimport type { CSSProperties } from '@lynx-js/types'\n\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\nimport { limiterForFirstScreen } from '../utils'\n\ninterface LayoutSwiperPropsType extends\n Pick<\n SwiperProps<unknown>,\n 'itemWidth' | 'initialIndex' | 'itemHeight' | 'trackStyle'\n >,\n Required<\n Pick<\n SwiperProps<unknown>,\n | 'containerWidth'\n | 'loop'\n | 'loopDuplicateCount'\n | 'RTL'\n | 'swiperKey'\n >\n >\n{\n spaceBetween: number\n dataCount: number\n modeConfig: CompoundModeConfig\n offsetLimit: OffsetLimitResult\n}\n\ninterface EscapeProps\n extends\n Pick<SwiperProps<unknown>, 'itemWidth' | 'initialIndex'>,\n Required<\n Pick<\n SwiperProps<unknown>,\n 'containerWidth' | 'loop' | 'RTL'\n >\n >\n{\n spaceBetween: number\n dataCount: number\n modeConfig: CompoundModeConfig\n offsetLimit: OffsetLimitResult\n}\n\nfunction getOffset(props: EscapeProps) {\n const {\n modeConfig,\n itemWidth,\n initialIndex = 0,\n loop,\n dataCount,\n containerWidth,\n offsetLimit,\n RTL,\n spaceBetween,\n } = props\n let alignOffset = 0\n if (modeConfig.mode === 'normal') {\n if (modeConfig.align === 'center') {\n alignOffset = (containerWidth - itemWidth) / 2\n } else if (modeConfig.align === 'end') {\n alignOffset = containerWidth - itemWidth\n } else {\n alignOffset = 0\n }\n }\n\n const finalOffset = limiterForFirstScreen(\n -(itemWidth + spaceBetween) * initialIndex + alignOffset,\n dataCount,\n itemWidth,\n spaceBetween,\n loop,\n offsetLimit,\n alignOffset,\n )\n\n return RTL ? -finalOffset : finalOffset\n}\n\nexport function getInnerContainerWidth(props: {\n itemWidth: number\n loopDuplicateCount?: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n}) {\n const {\n itemWidth,\n loopDuplicateCount = 0,\n loop,\n dataCount,\n spaceBetween,\n } = props\n const width = loop\n ? `${(dataCount + loopDuplicateCount * 2) * (itemWidth + spaceBetween)}px`\n : `${dataCount * (itemWidth + spaceBetween) - spaceBetween}px`\n return width\n}\n\nexport function getInnerContainerWidthMT(props: {\n itemWidth: number\n loopDuplicateCount?: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n}) {\n 'main thread'\n const {\n itemWidth,\n loopDuplicateCount = 0,\n loop,\n dataCount,\n spaceBetween,\n } = props\n const width = loop\n ? `${(dataCount + loopDuplicateCount * 2) * (itemWidth + spaceBetween)}px`\n : `${dataCount * (itemWidth + spaceBetween) - spaceBetween}px`\n\n return width\n}\n\n/**\n * MTS does not support first screen mutation.\n * We use `useMemo` hack to make firstScreen style correct.\n * When MTS is not ready, we use `useMemo` to get the style, and set it to view. Since there's no\n * dependency in `useMemo`, the view will only be set on firstScreen.\n * After that, all the updated are handled by MTS via `setStyleProperties`\n */\nfunction useFirstScreenStyle(props: LayoutSwiperPropsType): {\n containerStyle: CSSProperties | undefined\n} {\n const {\n itemWidth,\n spaceBetween,\n containerWidth,\n loop,\n initialIndex,\n dataCount,\n itemHeight,\n modeConfig,\n offsetLimit,\n loopDuplicateCount,\n RTL,\n swiperKey,\n trackStyle,\n } = props\n const escapeProps = {\n itemWidth,\n containerWidth,\n itemHeight,\n loop,\n initialIndex,\n dataCount,\n modeConfig,\n offsetLimit,\n RTL,\n spaceBetween,\n }\n\n const containerStyle = useMemo(() => {\n const insetInlineStartKey = RTL ? 'inset-inline-start' : 'left'\n if (modeConfig.mode === 'normal') {\n return {\n ...trackStyle,\n width: getInnerContainerWidth({\n itemWidth,\n loopDuplicateCount,\n loop,\n dataCount,\n spaceBetween,\n }),\n [insetInlineStartKey]: loop\n ? `${-loopDuplicateCount * (itemWidth + spaceBetween)}px`\n : '0px',\n transform: `translateX(${getOffset(escapeProps)}px)`,\n height: `${itemHeight}px`,\n }\n } else if (modeConfig.mode === 'custom') {\n return {\n height: `${itemHeight}px`,\n }\n }\n }, [swiperKey])\n\n return {\n containerStyle,\n }\n}\n\nexport default useFirstScreenStyle\n"],"names":["getOffset","props","modeConfig","itemWidth","initialIndex","loop","dataCount","containerWidth","offsetLimit","RTL","spaceBetween","alignOffset","finalOffset","limiterForFirstScreen","getInnerContainerWidth","loopDuplicateCount","width","getInnerContainerWidthMT","useFirstScreenStyle","itemHeight","swiperKey","trackStyle","escapeProps","containerStyle","useMemo","insetInlineStartKey"],"mappings":";;AAqDA,SAASA,UAAUC,KAAkB;IACnC,MAAM,EACJC,UAAU,EACVC,SAAS,EACTC,eAAe,CAAC,EAChBC,IAAI,EACJC,SAAS,EACTC,cAAc,EACdC,WAAW,EACXC,GAAG,EACHC,YAAY,EACb,GAAGT;IACJ,IAAIU,cAAc;IAClB,IAAIT,AAAoB,aAApBA,WAAW,IAAI,EAEfS,cADET,AAAqB,aAArBA,WAAW,KAAK,GACHK,AAAAA,CAAAA,iBAAiBJ,SAAQ,IAAK,IACpCD,AAAqB,UAArBA,WAAW,KAAK,GACXK,iBAAiBJ,YAEjB;IAIlB,MAAMS,cAAcC,sBAClB,CAAEV,CAAAA,YAAYO,YAAW,IAAKN,eAAeO,aAC7CL,WACAH,WACAO,cACAL,MACAG,aACAG;IAGF,OAAOF,MAAM,CAACG,cAAcA;AAC9B;AAEO,SAASE,uBAAuBb,KAMtC;IACC,MAAM,EACJE,SAAS,EACTY,qBAAqB,CAAC,EACtBV,IAAI,EACJC,SAAS,EACTI,YAAY,EACb,GAAGT;IACJ,MAAMe,QAAQX,OACV,GAAIC,AAAAA,CAAAA,YAAYS,AAAqB,IAArBA,kBAAqB,IAAMZ,CAAAA,YAAYO,YAAW,EAAG,EAAE,CAAC,GACxE,GAAGJ,YAAaH,CAAAA,YAAYO,YAAW,IAAKA,aAAa,EAAE,CAAC;IAChE,OAAOM;AACT;AAEO,SAASC,yBAAyBhB,KAMxC;IACC;IACA,MAAM,EACJE,SAAS,EACTY,qBAAqB,CAAC,EACtBV,IAAI,EACJC,SAAS,EACTI,YAAY,EACb,GAAGT;IACJ,MAAMe,QAAQX,OACV,GAAIC,AAAAA,CAAAA,YAAYS,AAAqB,IAArBA,kBAAqB,IAAMZ,CAAAA,YAAYO,YAAW,EAAG,EAAE,CAAC,GACxE,GAAGJ,YAAaH,CAAAA,YAAYO,YAAW,IAAKA,aAAa,EAAE,CAAC;IAEhE,OAAOM;AACT;AASA,SAASE,oBAAoBjB,KAA4B;IAGvD,MAAM,EACJE,SAAS,EACTO,YAAY,EACZH,cAAc,EACdF,IAAI,EACJD,YAAY,EACZE,SAAS,EACTa,UAAU,EACVjB,UAAU,EACVM,WAAW,EACXO,kBAAkB,EAClBN,GAAG,EACHW,SAAS,EACTC,UAAU,EACX,GAAGpB;IACJ,MAAMqB,cAAc;QAClBnB;QACAI;QACAY;QACAd;QACAD;QACAE;QACAJ;QACAM;QACAC;QACAC;IACF;IAEA,MAAMa,iBAAiBC,QAAQ;QAC7B,MAAMC,sBAAsBhB,MAAM,uBAAuB;QACzD,IAAIP,AAAoB,aAApBA,WAAW,IAAI,EACjB,OAAO;YACL,GAAGmB,UAAU;YACb,OAAOP,uBAAuB;gBAC5BX;gBACAY;gBACAV;gBACAC;gBACAI;YACF;YACA,CAACe,oBAAoB,EAAEpB,OACnB,GAAG,CAACU,qBAAsBZ,CAAAA,YAAYO,YAAW,EAAG,EAAE,CAAC,GACvD;YACJ,WAAW,CAAC,WAAW,EAAEV,UAAUsB,aAAa,GAAG,CAAC;YACpD,QAAQ,GAAGH,WAAW,EAAE,CAAC;QAC3B;QACK,IAAIjB,AAAoB,aAApBA,WAAW,IAAI,EACxB,OAAO;YACL,QAAQ,GAAGiB,WAAW,EAAE,CAAC;QAC3B;IAEJ,GAAG;QAACC;KAAU;IAEd,OAAO;QACLG;IACF;AACF;AAEA,kCAAeL"}
1
+ {"version":3,"file":"hooks/useFirstScreenStyle.jsx","sources":["../../src/hooks/useFirstScreenStyle.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 { useMemo } from '@lynx-js/react'\n\nimport type { CSSProperties } from '@lynx-js/types'\n\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\nimport { limiterForFirstScreen } from '../utils'\n\ninterface LayoutSwiperPropsType extends\n Pick<\n SwiperProps<unknown>,\n 'itemWidth' | 'initialIndex' | 'itemHeight' | 'trackStyle'\n >,\n Required<\n Pick<\n SwiperProps<unknown>,\n | 'containerWidth'\n | 'loop'\n | 'loopDuplicateCount'\n | 'RTL'\n | 'swiperKey'\n >\n >\n{\n spaceBetween: number\n dataCount: number\n modeConfig: CompoundModeConfig\n offsetLimit: OffsetLimitResult\n}\n\ninterface EscapeProps\n extends\n Pick<SwiperProps<unknown>, 'itemWidth' | 'initialIndex'>,\n Required<\n Pick<\n SwiperProps<unknown>,\n 'containerWidth' | 'loop' | 'RTL'\n >\n >\n{\n spaceBetween: number\n dataCount: number\n modeConfig: CompoundModeConfig\n offsetLimit: OffsetLimitResult\n}\n\nfunction getOffset(props: EscapeProps) {\n const {\n modeConfig,\n itemWidth,\n initialIndex = 0,\n loop,\n dataCount,\n containerWidth,\n offsetLimit,\n RTL,\n spaceBetween,\n } = props\n let alignOffset = 0\n if (modeConfig.mode === 'normal') {\n if (modeConfig.align === 'center') {\n alignOffset = (containerWidth - itemWidth) / 2\n } else if (modeConfig.align === 'end') {\n alignOffset = containerWidth - itemWidth\n } else {\n alignOffset = 0\n }\n }\n\n const finalOffset = limiterForFirstScreen(\n -(itemWidth + spaceBetween) * initialIndex + alignOffset,\n dataCount,\n itemWidth,\n spaceBetween,\n loop,\n offsetLimit,\n alignOffset,\n )\n\n return RTL ? -finalOffset : finalOffset\n}\n\nexport function getInnerContainerWidth(props: {\n itemWidth: number\n loopDuplicateCount?: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n}) {\n const {\n itemWidth,\n loopDuplicateCount = 0,\n loop,\n dataCount,\n spaceBetween,\n } = props\n const width = loop\n ? `${(dataCount + loopDuplicateCount * 2) * (itemWidth + spaceBetween)}px`\n : `${dataCount * (itemWidth + spaceBetween) - spaceBetween}px`\n return width\n}\n\nexport function getInnerContainerWidthMT(props: {\n itemWidth: number\n loopDuplicateCount?: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n}) {\n 'main thread'\n const {\n itemWidth,\n loopDuplicateCount = 0,\n loop,\n dataCount,\n spaceBetween,\n } = props\n const width = loop\n ? `${(dataCount + loopDuplicateCount * 2) * (itemWidth + spaceBetween)}px`\n : `${dataCount * (itemWidth + spaceBetween) - spaceBetween}px`\n\n return width\n}\n\n/**\n * MTS does not support first screen mutation.\n * We use `useMemo` hack to make firstScreen style correct.\n * When MTS is not ready, we use `useMemo` to get the style, and set it to view. Since there's no\n * dependency in `useMemo`, the view will only be set on firstScreen.\n * After that, all the updated are handled by MTS via `setStyleProperties`\n */\nfunction useFirstScreenStyle(props: LayoutSwiperPropsType): {\n containerStyle: CSSProperties | undefined\n} {\n const {\n itemWidth,\n spaceBetween,\n containerWidth,\n loop,\n initialIndex,\n dataCount,\n itemHeight,\n modeConfig,\n offsetLimit,\n loopDuplicateCount,\n RTL,\n swiperKey,\n trackStyle,\n } = props\n const escapeProps = {\n itemWidth,\n containerWidth,\n itemHeight,\n loop,\n initialIndex,\n dataCount,\n modeConfig,\n offsetLimit,\n RTL,\n spaceBetween,\n }\n\n const containerStyle = useMemo(() => {\n const insetInlineStartKey = RTL ? 'inset-inline-start' : 'left'\n if (modeConfig.mode === 'normal') {\n return {\n ...trackStyle,\n width: getInnerContainerWidth({\n itemWidth,\n loopDuplicateCount,\n loop,\n dataCount,\n spaceBetween,\n }),\n [insetInlineStartKey]: loop\n ? `${-loopDuplicateCount * (itemWidth + spaceBetween)}px`\n : '0px',\n transform: `translateX(${getOffset(escapeProps)}px)`,\n height: `${itemHeight}px`,\n }\n } else if (modeConfig.mode === 'custom') {\n return {\n height: `${itemHeight}px`,\n }\n }\n }, [swiperKey])\n\n return {\n containerStyle,\n }\n}\n\nexport default useFirstScreenStyle\n"],"names":["getOffset","props","modeConfig","itemWidth","initialIndex","loop","dataCount","containerWidth","offsetLimit","RTL","spaceBetween","alignOffset","finalOffset","limiterForFirstScreen","getInnerContainerWidth","loopDuplicateCount","width","getInnerContainerWidthMT","useFirstScreenStyle","itemHeight","swiperKey","trackStyle","escapeProps","containerStyle","useMemo","insetInlineStartKey"],"mappings":";;AAqDA,SAASA,UAAUC,KAAkB;IACnC,MAAM,EACJC,UAAU,EACVC,SAAS,EACTC,eAAe,CAAC,EAChBC,IAAI,EACJC,SAAS,EACTC,cAAc,EACdC,WAAW,EACXC,GAAG,EACHC,YAAY,EACb,GAAGT;IACJ,IAAIU,cAAc;IAClB,IAAIT,AAAoB,aAApBA,WAAW,IAAI,EAEfS,cADET,AAAqB,aAArBA,WAAW,KAAK,GACHK,AAAAA,CAAAA,iBAAiBJ,SAAQ,IAAK,IACpCD,AAAqB,UAArBA,WAAW,KAAK,GACXK,iBAAiBJ,YAEjB;IAIlB,MAAMS,cAAcC,sBAClB,CAAEV,CAAAA,YAAYO,YAAW,IAAKN,eAAeO,aAC7CL,WACAH,WACAO,cACAL,MACAG,aACAG;IAGF,OAAOF,MAAM,CAACG,cAAcA;AAC9B;AAEO,SAASE,uBAAuBb,KAMtC;IACC,MAAM,EACJE,SAAS,EACTY,qBAAqB,CAAC,EACtBV,IAAI,EACJC,SAAS,EACTI,YAAY,EACb,GAAGT;IACJ,MAAMe,QAAQX,OACV,GAAIC,AAAAA,CAAAA,YAAYS,AAAqB,IAArBA,kBAAqB,IAAMZ,CAAAA,YAAYO,YAAW,EAAG,EAAE,CAAC,GACxE,GAAGJ,YAAaH,CAAAA,YAAYO,YAAW,IAAKA,aAAa,EAAE,CAAC;IAChE,OAAOM;AACT;AAEO,SAASC,yBAAyBhB,KAMxC;IACC;IACA,MAAM,EACJE,SAAS,EACTY,qBAAqB,CAAC,EACtBV,IAAI,EACJC,SAAS,EACTI,YAAY,EACb,GAAGT;IACJ,MAAMe,QAAQX,OACV,GAAIC,AAAAA,CAAAA,YAAYS,AAAqB,IAArBA,kBAAqB,IAAMZ,CAAAA,YAAYO,YAAW,EAAG,EAAE,CAAC,GACxE,GAAGJ,YAAaH,CAAAA,YAAYO,YAAW,IAAKA,aAAa,EAAE,CAAC;IAEhE,OAAOM;AACT;AASA,SAASE,oBAAoBjB,KAA4B;IAGvD,MAAM,EACJE,SAAS,EACTO,YAAY,EACZH,cAAc,EACdF,IAAI,EACJD,YAAY,EACZE,SAAS,EACTa,UAAU,EACVjB,UAAU,EACVM,WAAW,EACXO,kBAAkB,EAClBN,GAAG,EACHW,SAAS,EACTC,UAAU,EACX,GAAGpB;IACJ,MAAMqB,cAAc;QAClBnB;QACAI;QACAY;QACAd;QACAD;QACAE;QACAJ;QACAM;QACAC;QACAC;IACF;IAEA,MAAMa,iBAAiBC,QAAQ;QAC7B,MAAMC,sBAAsBhB,MAAM,uBAAuB;QACzD,IAAIP,AAAoB,aAApBA,WAAW,IAAI,EACjB,OAAO;YACL,GAAGmB,UAAU;YACb,OAAOP,uBAAuB;gBAC5BX;gBACAY;gBACAV;gBACAC;gBACAI;YACF;YACA,CAACe,oBAAoB,EAAEpB,OACnB,GAAG,CAACU,qBAAsBZ,CAAAA,YAAYO,YAAW,EAAG,EAAE,CAAC,GACvD;YACJ,WAAW,CAAC,WAAW,EAAEV,UAAUsB,aAAa,GAAG,CAAC;YACpD,QAAQ,GAAGH,WAAW,EAAE,CAAC;QAC3B;QACK,IAAIjB,AAAoB,aAApBA,WAAW,IAAI,EACxB,OAAO;YACL,QAAQ,GAAGiB,WAAW,EAAE,CAAC;QAC3B;IAEJ,GAAG;QAACC;KAAU;IAEd,OAAO;QACLG;IACF;AACF;AAEA,kCAAeL"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useModeConfig.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useModeConfig.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 { useMemo, useRef } from '@lynx-js/react'\n\nimport type {\n CompoundModeConfig,\n CompoundNormalModeConfig,\n SwiperProps,\n} from '../types'\nimport { comparePropsWithObject } from '../utils/compareProps'\n\n/**\n * Handle mode and modeConfig\n * Only update reference when mode or content of modeConfig changes\n * This can prevent usage like this causing reRender every time.\n * ```\n * <Swiper mode=\"normal\" modeConfig={{ align: 'center' }}></Swiper>\n * ```\n */\nexport function useModeConfig({\n mode = 'normal',\n modeConfig = {\n align: 'start',\n spaceBetween: 0,\n },\n}: Pick<SwiperProps<unknown>, 'mode' | 'modeConfig'>) {\n const prevModeConfigRef = useRef<CompoundModeConfig | null>(null)\n\n const normalizedModeConfig = useMemo(() => {\n const newConfig: CompoundModeConfig = mode === 'custom'\n ? { mode, ...(modeConfig ?? {}) }\n : {\n mode,\n ...(modeConfig ?? { align: 'start' }),\n } as CompoundNormalModeConfig\n\n // If previous config exists and is equal to new config, return cached version\n if (\n prevModeConfigRef.current\n && comparePropsWithObject(prevModeConfigRef.current, newConfig)\n ) {\n return prevModeConfigRef.current\n }\n\n // Update cache and return new config\n prevModeConfigRef.current = newConfig\n return newConfig\n }, [mode, modeConfig])\n\n const spaceBetween = (modeConfig.spaceBetween as number) ?? 0\n\n return { modeConfig: normalizedModeConfig, spaceBetween }\n}\n"],"names":["useModeConfig","mode","modeConfig","prevModeConfigRef","useRef","normalizedModeConfig","useMemo","newConfig","comparePropsWithObject","spaceBetween"],"mappings":";;AAqBO,SAASA,cAAc,EAC5BC,OAAO,QAAQ,EACfC,aAAa;IACX,OAAO;IACP,cAAc;AAChB,CAAC,EACiD;IAClD,MAAMC,oBAAoBC,OAAkC;IAE5D,MAAMC,uBAAuBC,QAAQ;QACnC,MAAMC,YAAgCN,AAAS,aAATA,OAClC;YAAEA;YAAM,GAAIC,cAAc,CAAC,CAAC;QAAE,IAC9B;YACAD;YACA,GAAIC,cAAc;gBAAE,OAAO;YAAQ,CAAC;QACtC;QAGF,IACEC,kBAAkB,OAAO,IACtBK,uBAAuBL,kBAAkB,OAAO,EAAEI,YAErD,OAAOJ,kBAAkB,OAAO;QAIlCA,kBAAkB,OAAO,GAAGI;QAC5B,OAAOA;IACT,GAAG;QAACN;QAAMC;KAAW;IAErB,MAAMO,eAAgBP,WAAW,YAAY,IAAe;IAE5D,OAAO;QAAE,YAAYG;QAAsBI;IAAa;AAC1D"}
1
+ {"version":3,"file":"hooks/useModeConfig.jsx","sources":["../../src/hooks/useModeConfig.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 { useMemo, useRef } from '@lynx-js/react'\n\nimport type {\n CompoundModeConfig,\n CompoundNormalModeConfig,\n SwiperProps,\n} from '../types'\nimport { comparePropsWithObject } from '../utils/compareProps'\n\n/**\n * Handle mode and modeConfig\n * Only update reference when mode or content of modeConfig changes\n * This can prevent usage like this causing reRender every time.\n * ```\n * <Swiper mode=\"normal\" modeConfig={{ align: 'center' }}></Swiper>\n * ```\n */\nexport function useModeConfig({\n mode = 'normal',\n modeConfig = {\n align: 'start',\n spaceBetween: 0,\n },\n}: Pick<SwiperProps<unknown>, 'mode' | 'modeConfig'>) {\n const prevModeConfigRef = useRef<CompoundModeConfig | null>(null)\n\n const normalizedModeConfig = useMemo(() => {\n const newConfig: CompoundModeConfig = mode === 'custom'\n ? { mode, ...(modeConfig ?? {}) }\n : {\n mode,\n ...(modeConfig ?? { align: 'start' }),\n } as CompoundNormalModeConfig\n\n // If previous config exists and is equal to new config, return cached version\n if (\n prevModeConfigRef.current\n && comparePropsWithObject(prevModeConfigRef.current, newConfig)\n ) {\n return prevModeConfigRef.current\n }\n\n // Update cache and return new config\n prevModeConfigRef.current = newConfig\n return newConfig\n }, [mode, modeConfig])\n\n const spaceBetween = (modeConfig.spaceBetween as number) ?? 0\n\n return { modeConfig: normalizedModeConfig, spaceBetween }\n}\n"],"names":["useModeConfig","mode","modeConfig","prevModeConfigRef","useRef","normalizedModeConfig","useMemo","newConfig","comparePropsWithObject","spaceBetween"],"mappings":";;AAqBO,SAASA,cAAc,EAC5BC,OAAO,QAAQ,EACfC,aAAa;IACX,OAAO;I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S,EAAE,cAAc,KAAK,IAAI;;;8BA0WlC,UAAU,CAAC,UAAU;6BAgBtB,UAAU,CAAC,UAAU;4BA0BtB,UAAU,CAAC,UAAU;qBA5G5B,MAAM,YAAY,cAAc;0BAJ3B,cAAc;0BAJd,cAAc;kCAiJN,YAAY;;EA0ClD;AAED,OAAO,EAAE,SAAS,EAAE,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { runOnBackground, runOnMainThread, useMainThreadRef } from "@lynx-js/react";
2
2
  import { useTapLock } from "@lynx-js/react-use";
3
- import { limiter } from "../utils/index.jsx";
3
+ import { limiter, normalizeLoopOffset, normalizeLoopTransition } from "../utils/index.jsx";
4
4
  import { useAnimate } from "./useAnimate.jsx";
5
5
  import { useAutoplay } from "./useAutoPlay.jsx";
6
6
  import { useAxisLock } from "./useAxisLock.jsx";
@@ -105,26 +105,15 @@ function useOffset({ loop, duration, size, spaceBetween, easing, dataCount, init
105
105
  }
106
106
  function calcLoop(start, end) {
107
107
  'main thread';
108
- let startOffset = start;
109
- let finalOffset = end;
110
108
  if (0 === dataCount) return {
111
109
  offset: 0,
112
110
  finalOffset: 0
113
111
  };
114
- const totalWidth = fullSize * dataCount;
115
- if (loop) {
116
- if (finalOffset < -totalWidth + fullSize) {
117
- finalOffset += totalWidth;
118
- startOffset += totalWidth;
119
- } else if (finalOffset > 0) {
120
- finalOffset -= totalWidth;
121
- startOffset -= totalWidth;
122
- }
123
- }
124
- return {
125
- offset: startOffset,
126
- finalOffset
112
+ if (!loop) return {
113
+ offset: start,
114
+ finalOffset: end
127
115
  };
116
+ return normalizeLoopTransition(start, end, fullSize * dataCount);
128
117
  }
129
118
  const { handleTouchMove: swipeCallbackTouchMove, handleTouchStart: swipeCallbackTouchStart, setSwipeEndMT, setSwipeStartMT } = useSwipeCallback({
130
119
  onSwipeStartMT,
@@ -298,6 +287,7 @@ function useOffset({ loop, duration, size, spaceBetween, easing, dataCount, init
298
287
  const sign = RTL ? -1 : 1;
299
288
  let offsetInner = sign * (event.detail.x - touchStartRef.current) + lastScrollOffsetRef.current;
300
289
  offsetInner = calcBounceOffsetAndLimit(offsetInner);
290
+ if (loop) offsetInner = normalizeLoopOffset(offsetInner, fullSize * dataCount);
301
291
  setOffset(offsetInner);
302
292
  velocityTouchMove(event);
303
293
  swipeCallbackTouchMove(event);
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useOffset.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useOffset.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 {\n runOnBackground,\n runOnMainThread,\n useMainThreadRef,\n} from '@lynx-js/react'\n\nimport { useTapLock } from '@lynx-js/react-use'\nimport type { MainThread } from '@lynx-js/types'\n\nimport { limiter } from '../utils'\nimport { useAnimate } from './useAnimate'\nimport { useAutoplay } from './useAutoPlay'\nimport { useAxisLock } from './useAxisLock'\nimport { useSwipeCallback } from './useSwipeCallback'\nimport { useVelocity } from './useVelocity'\nimport { SwipeDirection } from '../types'\nimport type {\n BounceConfig,\n CompoundModeConfig,\n OffsetLimitResult,\n ResetOptions,\n SwipeToOptions,\n SwiperProps,\n onBounceParams,\n} from '../types'\nimport { useDirection } from './useDirection'\n\ninterface UseOffsetOpts extends\n Required<\n Pick<\n SwiperProps<unknown>,\n | 'loop'\n | 'duration'\n | 'initialIndex'\n | 'containerWidth'\n | 'autoPlay'\n | 'autoPlayInterval'\n | 'consumeSlideEvent'\n | 'RTL'\n >\n >\n{\n dataCount: number\n size: number\n spaceBetween: number\n easing: NonNullable<SwiperProps<unknown>['main-thread:easing']>\n modeConfig: CompoundModeConfig\n enableBounce: boolean\n startBounceItemWidth: NonNullable<BounceConfig['startBounceItemWidth']>\n endBounceItemWidth: NonNullable<BounceConfig['endBounceItemWidth']>\n onStartBounceItemBounce: BounceConfig['onStartBounceItemBounce']\n onEndBounceItemBounce: BounceConfig['onStartBounceItemBounce']\n experimentalHorizontalSwipeOnly: boolean\n onSwipeStopMT: () => void\n onSwipeStartMT: () => void\n offsetLimit: OffsetLimitResult\n}\n\n// TODO(@wangyang.ryan) Use Function from utils.\n// MTS imported from other files has bug now.\nfunction customRound(num: number, threshold = 0.5) {\n 'main thread'\n const decimal = num - Math.floor(num)\n\n // Check if the decimal part is greater than or equal to 0.9\n if (decimal >= threshold) {\n return Math.ceil(num)\n } else {\n return Math.floor(num)\n }\n}\n\nfunction rubberEffect(rubberDelta: number, bounceWidth: number): number {\n 'main thread'\n\n if (rubberDelta === 0 || bounceWidth === 0) {\n return 0\n }\n\n // Assumes the bounce should max out when the user swipes 2x the bounceWidth.\n const swipeLimit = bounceWidth * 2.0\n const scaleFactor = 1.5 // (2.0 + 1.0) / 2.0\n\n const absDelta = Math.abs(rubberDelta)\n const effectiveDelta = Math.min(absDelta, swipeLimit)\n\n const bounce = effectiveDelta / (effectiveDelta / bounceWidth + 1.0)\n\n return Math.sign(rubberDelta) * bounce * scaleFactor\n}\n\n/**\n * This hook are used to maintain a virtual offset, which does not necessarily reflect the actual\n * location of the swiper\n */\nfunction useOffset(\n {\n loop,\n duration,\n size,\n spaceBetween,\n easing,\n dataCount,\n initialIndex,\n autoPlay,\n autoPlayInterval,\n offsetLimit,\n enableBounce,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n experimentalHorizontalSwipeOnly,\n onSwipeStartMT,\n onSwipeStopMT,\n consumeSlideEvent,\n RTL,\n }: UseOffsetOpts,\n onOffsetUpdate: (offset: number, direction: SwipeDirection) => void,\n) {\n // fullSize contains size and spaceBetween\n const fullSize = size + spaceBetween\n function getInitialOffset() {\n return limiter(\n -fullSize * initialIndex,\n dataCount,\n size,\n spaceBetween,\n loop,\n offsetLimit,\n )\n }\n\n const touchStartRef = useMainThreadRef<number>(0)\n const touchStartCrossAxisRef = useMainThreadRef<number>(0)\n const lastScrollOffsetRef = useMainThreadRef<number>(getInitialOffset())\n const offsetRef = useMainThreadRef<number>(getInitialOffset())\n // To record the previous index before offset change\n const prevIndexRef = useMainThreadRef<number>(initialIndex)\n const { velocityTouchMove, velocityTouchStart, getVelocity } = useVelocity({\n RTL,\n })\n const { cancel: cancelAnimation, animate } = useAnimate()\n\n const reachedBounceRef = useMainThreadRef(false)\n const bounceDeltaRef = useMainThreadRef(0)\n\n const {\n directionRef,\n handleTouchStart: directionTouchStart,\n handleTouchMove: directionTouchMove,\n handleTouchEnd: directionTouchEnd,\n overrideDirection,\n } = useDirection({\n RTL,\n })\n\n function getCurrentIndex() {\n 'main thread'\n // Guard against dataCount=0 to prevent NaN from modulo by zero\n if (dataCount === 0) {\n return 0\n }\n const totalWidth = fullSize * dataCount\n const currentIndex = ((-offsetRef.current + totalWidth) % totalWidth)\n / fullSize\n return currentIndex\n }\n\n // Offset should only be updated by this function.\n function setOffset(offset: number) {\n 'main thread'\n if (isNaN(offset)) {\n throw new Error('calcBounceOffset: invalid offset')\n }\n offsetRef.current = offset\n prevIndexRef.current = getCurrentIndex()\n onOffsetUpdate(offset, directionRef.current)\n }\n\n function calcLimitCompact(offset: number, options?: {\n type: 'prev' | 'next'\n }): {\n offset: number\n reachingLimit: -1 | 0 | 1\n } {\n 'main thread'\n let reachingLimit: -1 | 0 | 1 = 0\n let finalOffset = offset\n if (dataCount === 0) {\n if (options?.type === 'prev') {\n return { offset: 0, reachingLimit: -1 }\n }\n return { offset: 0, reachingLimit: 1 }\n }\n if (!loop) {\n if (offset >= -offsetLimit.startLimit) {\n reachingLimit = -1\n finalOffset = -offsetLimit.startLimit\n } else if (offset <= -fullSize * (dataCount - 1) + offsetLimit.endLimit) {\n reachingLimit = 1\n finalOffset = -fullSize * (dataCount - 1) + offsetLimit.endLimit\n }\n }\n return { offset: finalOffset, reachingLimit }\n }\n\n function calcBounceOffsetAndLimit(offset: number) {\n 'main thread'\n const { offset: limitOffset, reachingLimit } = calcLimitCompact(offset)\n\n if (enableBounce && reachingLimit) {\n const bounceDelta = offset - limitOffset\n const bounceItemWidth = reachingLimit === -1\n ? startBounceItemWidth\n : (offsetLimit.isNotEnoughForScreen ? 0 : endBounceItemWidth)\n reachedBounceRef.current = true\n bounceDeltaRef.current = rubberEffect(bounceDelta, bounceItemWidth)\n return limitOffset + bounceDeltaRef.current\n }\n return limitOffset\n }\n\n // We use rounding as threshold of when will the swiper to apply paging.\n // When rounding is 0.7, then index 1.6 will be paged to 1, and 1.8 will be paged to 2\n function calcPaging(offset: number, rounding = 0.5) {\n 'main thread'\n const { offset: limitOffset, reachingLimit } = calcLimitCompact(offset)\n if (reachingLimit) {\n return limitOffset\n }\n\n return customRound(-offset / fullSize, rounding) * -fullSize\n }\n\n function calcLoop(start: number, end: number) {\n 'main thread'\n let startOffset = start\n let finalOffset = end\n if (dataCount === 0) {\n return { offset: 0, finalOffset: 0 }\n }\n const totalWidth = fullSize * dataCount\n if (loop) {\n if (finalOffset < -totalWidth + fullSize) {\n // If go beyond last item, like n + 1 item, let the destination be 1\n finalOffset = finalOffset + totalWidth\n startOffset = startOffset + totalWidth\n } else if (finalOffset > 0) {\n // If go before first item, like -1 item, let the destination be n - 1\n finalOffset = finalOffset - totalWidth\n startOffset = startOffset - totalWidth\n }\n }\n return {\n offset: startOffset,\n finalOffset,\n }\n }\n\n const {\n handleTouchMove: swipeCallbackTouchMove,\n handleTouchStart: swipeCallbackTouchStart,\n setSwipeEndMT,\n setSwipeStartMT,\n } = useSwipeCallback({\n onSwipeStartMT,\n onSwipeStopMT,\n })\n\n const {\n handleTouchStart: axisLockTouchStart,\n handleTouchMove: axisLockTouchMove,\n handleTouchEnd: axisLockTouchEnd,\n handleVelocity: axisLockVelocity,\n } = useAxisLock({\n consumeSlideEvent,\n experimentalHorizontalSwipeOnly,\n })\n\n const {\n handleTouchStart: tapLockTouchStart,\n handleTouchMove: tapLockTouchMove,\n handleTouchEnd: tapLockTouchEnd,\n } = useTapLock()\n\n function easingTo(start: number, end: number, onFinished?: () => void) {\n 'main thread'\n function onProgress(progress: number) {\n const interpolatedProgress = easing(progress / 100)\n const animeOffset = (end - start) * interpolatedProgress + start\n\n setOffset(animeOffset)\n }\n\n animate(duration, onProgress, onFinished)\n }\n\n function hasNextMTS() {\n 'main thread'\n const offset = offsetRef.current\n const { reachingLimit } = calcLimitCompact(offset)\n\n return reachingLimit !== 1\n }\n\n function hasPrevMTS() {\n 'main thread'\n const offset = offsetRef.current\n const { reachingLimit } = calcLimitCompact(offset)\n\n return reachingLimit !== -1\n }\n\n function swipeToMTS(index: number, options?: SwipeToOptions) {\n 'main thread'\n if (dataCount === 0) {\n setSwipeEndMT()\n return\n }\n\n const finalIndex = Math.max(Math.min(index, dataCount - 1), 0)\n const currentIndex = getCurrentIndex()\n const { offset: finalOffset } = calcLimitCompact(-finalIndex * fullSize)\n setSwipeStartMT()\n\n if (finalIndex > currentIndex) {\n overrideDirection(SwipeDirection.NORMAL)\n } else if (finalIndex < currentIndex) {\n overrideDirection(SwipeDirection.REVERT)\n } else {\n overrideDirection(SwipeDirection.NONE)\n }\n\n if (options?.animate) {\n easingTo(offsetRef.current, finalOffset, () => {\n if (options?.onFinished) {\n options.onFinished()\n }\n setSwipeEndMT()\n })\n } else {\n setOffset(finalOffset)\n setSwipeEndMT()\n }\n }\n\n function swipeNextMTS(options?: SwipeToOptions) {\n 'main thread'\n\n if (!hasNextMTS()) {\n setSwipeEndMT()\n return\n }\n\n setSwipeStartMT()\n let offset = offsetRef.current\n let finalOffset = calcPaging(offset - fullSize, 0.95)\n\n if (loop) {\n const result = calcLoop(offset, finalOffset)\n offset = result.offset\n finalOffset = result.finalOffset\n } else {\n const result = calcLimitCompact(finalOffset)\n finalOffset = result.offset\n }\n\n overrideDirection(SwipeDirection.NORMAL)\n\n if (options?.animate === false) {\n setOffset(finalOffset)\n setSwipeEndMT()\n } else {\n easingTo(offset, finalOffset, () => {\n if (options?.onFinished) {\n options.onFinished()\n }\n setSwipeEndMT()\n })\n }\n }\n\n function swipePrevMTS(options?: SwipeToOptions) {\n 'main thread'\n\n if (!hasPrevMTS()) {\n setSwipeEndMT()\n return\n }\n\n setSwipeStartMT()\n let offset = offsetRef.current\n let finalOffset = calcPaging(offset + fullSize, 0.05)\n if (loop) {\n const result = calcLoop(offset, finalOffset)\n offset = result.offset\n finalOffset = result.finalOffset\n } else {\n const result = calcLimitCompact(finalOffset)\n finalOffset = result.offset\n }\n\n overrideDirection(SwipeDirection.REVERT)\n\n if (options?.animate === false) {\n setOffset(finalOffset)\n setSwipeEndMT()\n } else {\n easingTo(offset, finalOffset, () => {\n if (options?.onFinished) {\n options.onFinished()\n }\n setSwipeEndMT()\n })\n }\n }\n\n function swipePrev(options?: SwipeToOptions) {\n runOnMainThread(swipePrevMTS)(options)\n }\n\n function swipeNext(options?: SwipeToOptions) {\n runOnMainThread(swipeNextMTS)(options)\n }\n\n function swipeTo(index: number, options?: SwipeToOptions) {\n runOnMainThread(swipeToMTS)(index, options)\n }\n\n function handleOnBounce(params: onBounceParams) {\n if (params.type === 'start' && onStartBounceItemBounce) {\n onStartBounceItemBounce(params)\n } else if (params.type === 'end' && onEndBounceItemBounce) {\n onEndBounceItemBounce(params)\n }\n }\n\n function handleBounceCallback(offset: number) {\n 'main thread'\n if (reachedBounceRef.current) {\n runOnBackground(handleOnBounce)({\n type: offset > 0 ? 'start' : 'end',\n offset: Math.abs(bounceDeltaRef.current),\n })\n reachedBounceRef.current = false\n bounceDeltaRef.current = 0\n }\n }\n\n const {\n pauseMT: pauseAutoPlayMT,\n startMT: startAutoPlayMT,\n } = useAutoplay({\n autoPlay,\n autoPlayInterval,\n prevMT: swipePrevMTS,\n nextMT: swipeNextMTS,\n duration,\n dataCount,\n })\n\n function handleVelocity() {\n 'main thread'\n const VELOCITY_THRESHOLD = 300\n\n if (axisLockVelocity()) {\n return false\n }\n\n const { velocity: velocityValue, direction } = getVelocity()\n if (Math.abs(velocityValue) > VELOCITY_THRESHOLD) {\n overrideDirection(direction)\n if (direction === SwipeDirection.NORMAL && hasNextMTS()) {\n swipeNextMTS({\n onFinished: () => {\n startAutoPlayMT()\n },\n })\n return true\n } else if (direction === SwipeDirection.REVERT && hasPrevMTS()) {\n swipePrevMTS({\n onFinished: () => {\n startAutoPlayMT()\n },\n })\n return true\n }\n }\n return false\n }\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n lastScrollOffsetRef.current = offsetRef.current\n\n touchStartRef.current = event.detail.x\n\n touchStartCrossAxisRef.current = event.detail.y\n axisLockTouchStart(event)\n velocityTouchStart()\n tapLockTouchStart(event)\n cancelAnimation()\n swipeCallbackTouchStart(event)\n directionTouchStart(event)\n pauseAutoPlayMT()\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n // Guard against empty data to prevent state corruption\n if (dataCount === 0) {\n return\n }\n\n if (axisLockTouchMove(event) || tapLockTouchMove(event)) {\n return\n }\n\n const sign = RTL ? -1 : 1\n\n let offsetInner = sign * (event.detail.x - touchStartRef.current)\n + lastScrollOffsetRef.current\n offsetInner = calcBounceOffsetAndLimit(offsetInner)\n setOffset(offsetInner)\n velocityTouchMove(event)\n swipeCallbackTouchMove(event)\n directionTouchMove(event)\n }\n\n function handleTouchEnd(event: MainThread.TouchEvent) {\n 'main thread'\n let offset = offsetRef.current\n\n handleBounceCallback(offset)\n\n if (handleVelocity()) {\n return\n }\n axisLockTouchEnd()\n directionTouchEnd(event)\n\n let finalOffset = calcPaging(offset)\n if (loop) {\n const result = calcLoop(offset, finalOffset)\n offset = result.offset\n finalOffset = result.finalOffset\n } else {\n const result = calcLimitCompact(finalOffset)\n finalOffset = result.offset\n }\n\n tapLockTouchEnd(event)\n easingTo(offset, finalOffset, () => {\n setSwipeEndMT()\n startAutoPlayMT()\n })\n }\n\n function resetOffsetMT(resetOptions: ResetOptions) {\n 'main thread'\n cancelAnimation()\n if (dataCount === 0) {\n swipeToMTS(0)\n return\n }\n if (resetOptions.fullReset) {\n swipeToMTS(resetOptions.resetIndex!, {\n animate: false,\n })\n } else {\n const currentIndex = prevIndexRef.current\n // Guard against NaN from previous empty data state\n if (isNaN(currentIndex)) {\n swipeToMTS(0, {\n animate: false,\n })\n } else {\n swipeToMTS(currentIndex, {\n animate: false,\n })\n }\n }\n }\n\n function cancelAnimationJS() {\n runOnMainThread(cancelAnimation)()\n }\n\n return {\n startAutoPlayMT,\n offsetRef,\n handleTouchStart,\n handleTouchMove,\n handleTouchEnd,\n swipeTo,\n swipeNext,\n swipePrev,\n resetOffsetMT,\n cancelAnimationJS,\n }\n}\n\nexport { useOffset }\n"],"names":["customRound","num","threshold","decimal","Math","rubberEffect","rubberDelta","bounceWidth","swipeLimit","scaleFactor","absDelta","effectiveDelta","bounce","useOffset","loop","duration","size","spaceBetween","easing","dataCount","initialIndex","autoPlay","autoPlayInterval","offsetLimit","enableBounce","startBounceItemWidth","endBounceItemWidth","onStartBounceItemBounce","onEndBounceItemBounce","experimentalHorizontalSwipeOnly","onSwipeStartMT","onSwipeStopMT","consumeSlideEvent","RTL","onOffsetUpdate","fullSize","getInitialOffset","limiter","touchStartRef","useMainThreadRef","touchStartCrossAxisRef","lastScrollOffsetRef","offsetRef","prevIndexRef","velocityTouchMove","velocityTouchStart","getVelocity","useVelocity","cancelAnimation","animate","useAnimate","reachedBounceRef","bounceDeltaRef","directionRef","directionTouchStart","directionTouchMove","directionTouchEnd","overrideDirection","useDirection","getCurrentIndex","totalWidth","currentIndex","setOffset","offset","isNaN","Error","calcLimitCompact","options","reachingLimit","finalOffset","calcBounceOffsetAndLimit","limitOffset","bounceDelta","bounceItemWidth","calcPaging","rounding","calcLoop","start","end","startOffset","swipeCallbackTouchMove","swipeCallbackTouchStart","setSwipeEndMT","setSwipeStartMT","useSwipeCallback","axisLockTouchStart","axisLockTouchMove","axisLockTouchEnd","axisLockVelocity","useAxisLock","tapLockTouchStart","tapLockTouchMove","tapLockTouchEnd","useTapLock","easingTo","onFinished","onProgress","progress","interpolatedProgress","animeOffset","hasNextMTS","hasPrevMTS","swipeToMTS","index","finalIndex","SwipeDirection","swipeNextMTS","result","swipePrevMTS","swipePrev","runOnMainThread","swipeNext","swipeTo","handleOnBounce","params","handleBounceCallback","runOnBackground","pauseAutoPlayMT","startAutoPlayMT","useAutoplay","handleVelocity","VELOCITY_THRESHOLD","velocityValue","direction","handleTouchStart","event","handleTouchMove","sign","offsetInner","handleTouchEnd","resetOffsetMT","resetOptions","cancelAnimationJS"],"mappings":";;;;;;;;;;AAgEA,SAASA,YAAYC,GAAW,EAAEC,YAAY,GAAG;IAC/C;IACA,MAAMC,UAAUF,MAAMG,KAAK,KAAK,CAACH;IAGjC,IAAIE,WAAWD,WACb,OAAOE,KAAK,IAAI,CAACH;IAEjB,OAAOG,KAAK,KAAK,CAACH;AAEtB;AAEA,SAASI,aAAaC,WAAmB,EAAEC,WAAmB;IAC5D;IAEA,IAAID,AAAgB,MAAhBA,eAAqBC,AAAgB,MAAhBA,aACvB,OAAO;IAIT,MAAMC,aAAaD,AAAc,MAAdA;IACnB,MAAME,cAAc;IAEpB,MAAMC,WAAWN,KAAK,GAAG,CAACE;IAC1B,MAAMK,iBAAiBP,KAAK,GAAG,CAACM,UAAUF;IAE1C,MAAMI,SAASD,iBAAkBA,CAAAA,iBAAiBJ,cAAc,GAAE;IAElE,OAAOH,KAAK,IAAI,CAACE,eAAeM,SAASH;AAC3C;AAMA,SAASI,UACP,EACEC,IAAI,EACJC,QAAQ,EACRC,IAAI,EACJC,YAAY,EACZC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,QAAQ,EACRC,gBAAgB,EAChBC,WAAW,EACXC,YAAY,EACZC,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB,EACvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,cAAc,EACdC,aAAa,EACbC,iBAAiB,EACjBC,GAAG,EACW,EAChBC,cAAmE;IAGnE,MAAMC,WAAWnB,OAAOC;IACxB,SAASmB;QACP,OAAOC,QACL,CAACF,WAAWf,cACZD,WACAH,MACAC,cACAH,MACAS;I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YACL,MAAMtE,eAAelB,aAAa,OAAO;YAErCqB,MAAMH,gBACRyC,WAAW,GAAG;gBACZ,SAAS;YACX,KAEAA,WAAWzC,cAAc;gBACvB,SAAS;YACX;QAEJ;IACF;IAEA,SAASuE;QACPtB,gBAAgB9D;IAClB;IAEA,OAAO;QACLsE;QACA5E;QACAkF;QACAE;QACAG;QACAjB;QACAD;QACAF;QACAqB;QACAE;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useOffset.jsx","sources":["../../src/hooks/useOffset.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 {\n runOnBackground,\n runOnMainThread,\n useMainThreadRef,\n} from '@lynx-js/react'\n\nimport { useTapLock } from '@lynx-js/react-use'\nimport type { MainThread } from '@lynx-js/types'\n\nimport { limiter, normalizeLoopOffset, normalizeLoopTransition } from '../utils'\nimport { useAnimate } from './useAnimate'\nimport { useAutoplay } from './useAutoPlay'\nimport { useAxisLock } from './useAxisLock'\nimport { useSwipeCallback } from './useSwipeCallback'\nimport { useVelocity } from './useVelocity'\nimport { SwipeDirection } from '../types'\nimport type {\n BounceConfig,\n CompoundModeConfig,\n OffsetLimitResult,\n ResetOptions,\n SwipeToOptions,\n SwiperProps,\n onBounceParams,\n} from '../types'\nimport { useDirection } from './useDirection'\n\ninterface UseOffsetOpts extends\n Required<\n Pick<\n SwiperProps<unknown>,\n | 'loop'\n | 'duration'\n | 'initialIndex'\n | 'containerWidth'\n | 'autoPlay'\n | 'autoPlayInterval'\n | 'consumeSlideEvent'\n | 'RTL'\n >\n >\n{\n dataCount: number\n size: number\n spaceBetween: number\n easing: NonNullable<SwiperProps<unknown>['main-thread:easing']>\n modeConfig: CompoundModeConfig\n enableBounce: boolean\n startBounceItemWidth: NonNullable<BounceConfig['startBounceItemWidth']>\n endBounceItemWidth: NonNullable<BounceConfig['endBounceItemWidth']>\n onStartBounceItemBounce: BounceConfig['onStartBounceItemBounce']\n onEndBounceItemBounce: BounceConfig['onStartBounceItemBounce']\n experimentalHorizontalSwipeOnly: boolean\n onSwipeStopMT: () => void\n onSwipeStartMT: () => void\n offsetLimit: OffsetLimitResult\n}\n\n// TODO(@wangyang.ryan) Use Function from utils.\n// MTS imported from other files has bug now.\nfunction customRound(num: number, threshold = 0.5) {\n 'main thread'\n const decimal = num - Math.floor(num)\n\n // Check if the decimal part is greater than or equal to 0.9\n if (decimal >= threshold) {\n return Math.ceil(num)\n } else {\n return Math.floor(num)\n }\n}\n\nfunction rubberEffect(rubberDelta: number, bounceWidth: number): number {\n 'main thread'\n\n if (rubberDelta === 0 || bounceWidth === 0) {\n return 0\n }\n\n // Assumes the bounce should max out when the user swipes 2x the bounceWidth.\n const swipeLimit = bounceWidth * 2.0\n const scaleFactor = 1.5 // (2.0 + 1.0) / 2.0\n\n const absDelta = Math.abs(rubberDelta)\n const effectiveDelta = Math.min(absDelta, swipeLimit)\n\n const bounce = effectiveDelta / (effectiveDelta / bounceWidth + 1.0)\n\n return Math.sign(rubberDelta) * bounce * scaleFactor\n}\n\n/**\n * This hook are used to maintain a virtual offset, which does not necessarily reflect the actual\n * location of the swiper\n */\nfunction useOffset(\n {\n loop,\n duration,\n size,\n spaceBetween,\n easing,\n dataCount,\n initialIndex,\n autoPlay,\n autoPlayInterval,\n offsetLimit,\n enableBounce,\n startBounceItemWidth,\n endBounceItemWidth,\n onStartBounceItemBounce,\n onEndBounceItemBounce,\n experimentalHorizontalSwipeOnly,\n onSwipeStartMT,\n onSwipeStopMT,\n consumeSlideEvent,\n RTL,\n }: UseOffsetOpts,\n onOffsetUpdate: (offset: number, direction: SwipeDirection) => void,\n) {\n // fullSize contains size and spaceBetween\n const fullSize = size + spaceBetween\n function getInitialOffset() {\n return limiter(\n -fullSize * initialIndex,\n dataCount,\n size,\n spaceBetween,\n loop,\n offsetLimit,\n )\n }\n\n const touchStartRef = useMainThreadRef<number>(0)\n const touchStartCrossAxisRef = useMainThreadRef<number>(0)\n const lastScrollOffsetRef = useMainThreadRef<number>(getInitialOffset())\n const offsetRef = useMainThreadRef<number>(getInitialOffset())\n // To record the previous index before offset change\n const prevIndexRef = useMainThreadRef<number>(initialIndex)\n const { velocityTouchMove, velocityTouchStart, getVelocity } = useVelocity({\n RTL,\n })\n const { cancel: cancelAnimation, animate } = useAnimate()\n\n const reachedBounceRef = useMainThreadRef(false)\n const bounceDeltaRef = useMainThreadRef(0)\n\n const {\n directionRef,\n handleTouchStart: directionTouchStart,\n handleTouchMove: directionTouchMove,\n handleTouchEnd: directionTouchEnd,\n overrideDirection,\n } = useDirection({\n RTL,\n })\n\n function getCurrentIndex() {\n 'main thread'\n // Guard against dataCount=0 to prevent NaN from modulo by zero\n if (dataCount === 0) {\n return 0\n }\n const totalWidth = fullSize * dataCount\n const currentIndex = ((-offsetRef.current + totalWidth) % totalWidth)\n / fullSize\n return currentIndex\n }\n\n // Offset should only be updated by this function.\n function setOffset(offset: number) {\n 'main thread'\n if (isNaN(offset)) {\n throw new Error('calcBounceOffset: invalid offset')\n }\n offsetRef.current = offset\n prevIndexRef.current = getCurrentIndex()\n onOffsetUpdate(offset, directionRef.current)\n }\n\n function calcLimitCompact(offset: number, options?: {\n type: 'prev' | 'next'\n }): {\n offset: number\n reachingLimit: -1 | 0 | 1\n } {\n 'main thread'\n let reachingLimit: -1 | 0 | 1 = 0\n let finalOffset = offset\n if (dataCount === 0) {\n if (options?.type === 'prev') {\n return { offset: 0, reachingLimit: -1 }\n }\n return { offset: 0, reachingLimit: 1 }\n }\n if (!loop) {\n if (offset >= -offsetLimit.startLimit) {\n reachingLimit = -1\n finalOffset = -offsetLimit.startLimit\n } else if (offset <= -fullSize * (dataCount - 1) + offsetLimit.endLimit) {\n reachingLimit = 1\n finalOffset = -fullSize * (dataCount - 1) + offsetLimit.endLimit\n }\n }\n return { offset: finalOffset, reachingLimit }\n }\n\n function calcBounceOffsetAndLimit(offset: number) {\n 'main thread'\n const { offset: limitOffset, reachingLimit } = calcLimitCompact(offset)\n\n if (enableBounce && reachingLimit) {\n const bounceDelta = offset - limitOffset\n const bounceItemWidth = reachingLimit === -1\n ? startBounceItemWidth\n : (offsetLimit.isNotEnoughForScreen ? 0 : endBounceItemWidth)\n reachedBounceRef.current = true\n bounceDeltaRef.current = rubberEffect(bounceDelta, bounceItemWidth)\n return limitOffset + bounceDeltaRef.current\n }\n return limitOffset\n }\n\n // We use rounding as threshold of when will the swiper to apply paging.\n // When rounding is 0.7, then index 1.6 will be paged to 1, and 1.8 will be paged to 2\n function calcPaging(offset: number, rounding = 0.5) {\n 'main thread'\n const { offset: limitOffset, reachingLimit } = calcLimitCompact(offset)\n if (reachingLimit) {\n return limitOffset\n }\n\n return customRound(-offset / fullSize, rounding) * -fullSize\n }\n\n function calcLoop(start: number, end: number) {\n 'main thread'\n if (dataCount === 0) {\n return { offset: 0, finalOffset: 0 }\n }\n\n if (!loop) {\n return { offset: start, finalOffset: end }\n }\n\n return normalizeLoopTransition(start, end, fullSize * dataCount)\n }\n\n const {\n handleTouchMove: swipeCallbackTouchMove,\n handleTouchStart: swipeCallbackTouchStart,\n setSwipeEndMT,\n setSwipeStartMT,\n } = useSwipeCallback({\n onSwipeStartMT,\n onSwipeStopMT,\n })\n\n const {\n handleTouchStart: axisLockTouchStart,\n handleTouchMove: axisLockTouchMove,\n handleTouchEnd: axisLockTouchEnd,\n handleVelocity: axisLockVelocity,\n } = useAxisLock({\n consumeSlideEvent,\n experimentalHorizontalSwipeOnly,\n })\n\n const {\n handleTouchStart: tapLockTouchStart,\n handleTouchMove: tapLockTouchMove,\n handleTouchEnd: tapLockTouchEnd,\n } = useTapLock()\n\n function easingTo(start: number, end: number, onFinished?: () => void) {\n 'main thread'\n function onProgress(progress: number) {\n const interpolatedProgress = easing(progress / 100)\n const animeOffset = (end - start) * interpolatedProgress + start\n\n setOffset(animeOffset)\n }\n\n animate(duration, onProgress, onFinished)\n }\n\n function hasNextMTS() {\n 'main thread'\n const offset = offsetRef.current\n const { reachingLimit } = calcLimitCompact(offset)\n\n return reachingLimit !== 1\n }\n\n function hasPrevMTS() {\n 'main thread'\n const offset = offsetRef.current\n const { reachingLimit } = calcLimitCompact(offset)\n\n return reachingLimit !== -1\n }\n\n function swipeToMTS(index: number, options?: SwipeToOptions) {\n 'main thread'\n if (dataCount === 0) {\n setSwipeEndMT()\n return\n }\n\n const finalIndex = Math.max(Math.min(index, dataCount - 1), 0)\n const currentIndex = getCurrentIndex()\n const { offset: finalOffset } = calcLimitCompact(-finalIndex * fullSize)\n setSwipeStartMT()\n\n if (finalIndex > currentIndex) {\n overrideDirection(SwipeDirection.NORMAL)\n } else if (finalIndex < currentIndex) {\n overrideDirection(SwipeDirection.REVERT)\n } else {\n overrideDirection(SwipeDirection.NONE)\n }\n\n if (options?.animate) {\n easingTo(offsetRef.current, finalOffset, () => {\n if (options?.onFinished) {\n options.onFinished()\n }\n setSwipeEndMT()\n })\n } else {\n setOffset(finalOffset)\n setSwipeEndMT()\n }\n }\n\n function swipeNextMTS(options?: SwipeToOptions) {\n 'main thread'\n\n if (!hasNextMTS()) {\n setSwipeEndMT()\n return\n }\n\n setSwipeStartMT()\n let offset = offsetRef.current\n let finalOffset = calcPaging(offset - fullSize, 0.95)\n\n if (loop) {\n const result = calcLoop(offset, finalOffset)\n offset = result.offset\n finalOffset = result.finalOffset\n } else {\n const result = calcLimitCompact(finalOffset)\n finalOffset = result.offset\n }\n\n overrideDirection(SwipeDirection.NORMAL)\n\n if (options?.animate === false) {\n setOffset(finalOffset)\n setSwipeEndMT()\n } else {\n easingTo(offset, finalOffset, () => {\n if (options?.onFinished) {\n options.onFinished()\n }\n setSwipeEndMT()\n })\n }\n }\n\n function swipePrevMTS(options?: SwipeToOptions) {\n 'main thread'\n\n if (!hasPrevMTS()) {\n setSwipeEndMT()\n return\n }\n\n setSwipeStartMT()\n let offset = offsetRef.current\n let finalOffset = calcPaging(offset + fullSize, 0.05)\n if (loop) {\n const result = calcLoop(offset, finalOffset)\n offset = result.offset\n finalOffset = result.finalOffset\n } else {\n const result = calcLimitCompact(finalOffset)\n finalOffset = result.offset\n }\n\n overrideDirection(SwipeDirection.REVERT)\n\n if (options?.animate === false) {\n setOffset(finalOffset)\n setSwipeEndMT()\n } else {\n easingTo(offset, finalOffset, () => {\n if (options?.onFinished) {\n options.onFinished()\n }\n setSwipeEndMT()\n })\n }\n }\n\n function swipePrev(options?: SwipeToOptions) {\n runOnMainThread(swipePrevMTS)(options)\n }\n\n function swipeNext(options?: SwipeToOptions) {\n runOnMainThread(swipeNextMTS)(options)\n }\n\n function swipeTo(index: number, options?: SwipeToOptions) {\n runOnMainThread(swipeToMTS)(index, options)\n }\n\n function handleOnBounce(params: onBounceParams) {\n if (params.type === 'start' && onStartBounceItemBounce) {\n onStartBounceItemBounce(params)\n } else if (params.type === 'end' && onEndBounceItemBounce) {\n onEndBounceItemBounce(params)\n }\n }\n\n function handleBounceCallback(offset: number) {\n 'main thread'\n if (reachedBounceRef.current) {\n runOnBackground(handleOnBounce)({\n type: offset > 0 ? 'start' : 'end',\n offset: Math.abs(bounceDeltaRef.current),\n })\n reachedBounceRef.current = false\n bounceDeltaRef.current = 0\n }\n }\n\n const {\n pauseMT: pauseAutoPlayMT,\n startMT: startAutoPlayMT,\n } = useAutoplay({\n autoPlay,\n autoPlayInterval,\n prevMT: swipePrevMTS,\n nextMT: swipeNextMTS,\n duration,\n dataCount,\n })\n\n function handleVelocity() {\n 'main thread'\n const VELOCITY_THRESHOLD = 300\n\n if (axisLockVelocity()) {\n return false\n }\n\n const { velocity: velocityValue, direction } = getVelocity()\n if (Math.abs(velocityValue) > VELOCITY_THRESHOLD) {\n overrideDirection(direction)\n if (direction === SwipeDirection.NORMAL && hasNextMTS()) {\n swipeNextMTS({\n onFinished: () => {\n startAutoPlayMT()\n },\n })\n return true\n } else if (direction === SwipeDirection.REVERT && hasPrevMTS()) {\n swipePrevMTS({\n onFinished: () => {\n startAutoPlayMT()\n },\n })\n return true\n }\n }\n return false\n }\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n lastScrollOffsetRef.current = offsetRef.current\n\n touchStartRef.current = event.detail.x\n\n touchStartCrossAxisRef.current = event.detail.y\n axisLockTouchStart(event)\n velocityTouchStart()\n tapLockTouchStart(event)\n cancelAnimation()\n swipeCallbackTouchStart(event)\n directionTouchStart(event)\n pauseAutoPlayMT()\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n // Guard against empty data to prevent state corruption\n if (dataCount === 0) {\n return\n }\n\n if (axisLockTouchMove(event) || tapLockTouchMove(event)) {\n return\n }\n\n const sign = RTL ? -1 : 1\n\n let offsetInner = sign * (event.detail.x - touchStartRef.current)\n + lastScrollOffsetRef.current\n offsetInner = calcBounceOffsetAndLimit(offsetInner)\n if (loop) {\n offsetInner = normalizeLoopOffset(offsetInner, fullSize * dataCount)\n }\n setOffset(offsetInner)\n velocityTouchMove(event)\n swipeCallbackTouchMove(event)\n directionTouchMove(event)\n }\n\n function handleTouchEnd(event: MainThread.TouchEvent) {\n 'main thread'\n let offset = offsetRef.current\n\n handleBounceCallback(offset)\n\n if (handleVelocity()) {\n return\n }\n axisLockTouchEnd()\n directionTouchEnd(event)\n\n let finalOffset = calcPaging(offset)\n if (loop) {\n const result = calcLoop(offset, finalOffset)\n offset = result.offset\n finalOffset = result.finalOffset\n } else {\n const result = calcLimitCompact(finalOffset)\n finalOffset = result.offset\n }\n\n tapLockTouchEnd(event)\n easingTo(offset, finalOffset, () => {\n setSwipeEndMT()\n startAutoPlayMT()\n })\n }\n\n function resetOffsetMT(resetOptions: ResetOptions) {\n 'main thread'\n cancelAnimation()\n if (dataCount === 0) {\n swipeToMTS(0)\n return\n }\n if (resetOptions.fullReset) {\n swipeToMTS(resetOptions.resetIndex!, {\n animate: false,\n })\n } else {\n const currentIndex = prevIndexRef.current\n // Guard against NaN from previous empty data state\n if (isNaN(currentIndex)) {\n swipeToMTS(0, {\n animate: false,\n })\n } else {\n swipeToMTS(currentIndex, {\n animate: false,\n })\n }\n }\n }\n\n function cancelAnimationJS() {\n runOnMainThread(cancelAnimation)()\n }\n\n return {\n startAutoPlayMT,\n offsetRef,\n handleTouchStart,\n handleTouchMove,\n handleTouchEnd,\n swipeTo,\n swipeNext,\n swipePrev,\n resetOffsetMT,\n cancelAnimationJS,\n }\n}\n\nexport { useOffset }\n"],"names":["customRound","num","threshold","decimal","Math","rubberEffect","rubberDelta","bounceWidth","swipeLimit","scaleFactor","absDelta","effectiveDelta","bounce","useOffset","loop","duration","size","spaceBetween","easing","dataCount","initialIndex","autoPlay","autoPlayInterval","offsetLimit","enableBounce","startBounceItemWidth","endBounceItemWidth","onStartBounceItemBounce","onEndBounceItemBounce","experimentalHorizontalSwipeOnly","onSwipeStartMT","onSwipeStopMT","consumeSlideEvent","RTL","onOffsetUpdate","fullSize","getInitialOffset","limiter","touchStartRef","useMainThreadRef","touchStartCrossAxisRef","lastScrollOffsetRef","offsetRef","prevIndexRef","velocityTouchMove","velocityTouchStart","getVelocity","useVelocity","cancelAnimation","animate","useAnimate","reachedBounceRef","bounceDeltaRef","directionRef","directionTouchStart","directionTouchMove","directionTouchEnd","overrideDirection","useDirection","getCurrentIndex","totalWidth","currentIndex","setOffset","offset","isNaN","Error","calcLimitCompact","options","reachingLimit","finalOffset","calcBounceOffsetAndLimit","limitOffset","bounceDelta","bounceItemWidth","calcPaging","rounding","calcLoop","start","end","normalizeLoopTransition","swipeCallbackTouchMove","swipeCallbackTouchStart","setSwipeEndMT","setSwipeStartMT","useSwipeCallback","axisLockTouchStart","axisLockTouchMove","axisLockTouchEnd","axisLockVelocity","useAxisLock","tapLockTouchStart","tapLockTouchMove","tapLockTouchEnd","useTapLock","easingTo","onFinished","onProgress","progress","interpolatedProgress","animeOffset","hasNextMTS","hasPrevMTS","swipeToMTS","index","finalIndex","SwipeDirection","swipeNextMTS","result","swipePrevMTS","swipePrev","runOnMainThread","swipeNext","swipeTo","handleOnBounce","params","handleBounceCallback","runOnBackground","pauseAutoPlayMT","startAutoPlayMT","useAutoplay","handleVelocity","VELOCITY_THRESHOLD","velocityValue","direction","handleTouchStart","event","handleTouchMove","sign","offsetInner","normalizeLoopOffset","handleTouchEnd","resetOffsetMT","resetOptions","cancelAnimationJS"],"mappings":";;;;;;;;;;AAgEA,SAASA,YAAYC,GAAW,EAAEC,YAAY,GAAG;IAC/C;IACA,MAAMC,UAAUF,MAAMG,KAAK,KAAK,CAACH;IAGjC,IAAIE,WAAWD,WACb,OAAOE,KAAK,IAAI,CAACH;IAEjB,OAAOG,KAAK,KAAK,CAACH;AAEtB;AAEA,SAASI,aAAaC,WAAmB,EAAEC,WAAmB;IAC5D;IAEA,IAAID,AAAgB,MAAhBA,eAAqBC,AAAgB,MAAhBA,aACvB,OAAO;IAIT,MAAMC,aAAaD,AAAc,MAAdA;IACnB,MAAME,cAAc;IAEpB,MAAMC,WAAWN,KAAK,GAAG,CAACE;IAC1B,MAAMK,iBAAiBP,KAAK,GAAG,CAACM,UAAUF;IAE1C,MAAMI,SAASD,iBAAkBA,CAAAA,iBAAiBJ,cAAc,GAAE;IAElE,OAAOH,KAAK,IAAI,CAACE,eAAeM,SAASH;AAC3C;AAMA,SAASI,UACP,EACEC,IAAI,EACJC,QAAQ,EACRC,IAAI,EACJC,YAAY,EACZC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,QAAQ,EACRC,gBAAgB,EAChBC,WAAW,EACXC,YAAY,EACZC,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB,EACvBC,qBAAqB,EACrBC,+BAA+B,EAC/BC,cAAc,EACdC,aAAa,EACbC,iBAAiB,EACjBC,GAAG,EACW,EAChBC,cAAmE;IAGnE,MAAMC,WAAWnB,OAAOC;IACxB,SAASmB;QACP,OAAOC,QACL,CAACF,WAAWf,cACZD,WACAH,MACAC,cACAH,MACAS;IAEJ;IAEA,MAAMe,gBAAgBC,iBAAyB;IAC/C,MAAMC,yBAAyBD,iBAAyB;IACxD,MAAME,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E;QACAkF;QACAE;QACAI;QACAlB;QACAD;QACAF;QACAsB;QACAE;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useOffsetLimit.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useOffsetLimit.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 { useMemo } from '@lynx-js/react'\n\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\n\ninterface IOffsetLimit extends\n Required<\n Pick<SwiperProps<unknown>, 'loop' | 'itemWidth' | 'containerWidth'>\n >\n{\n offsetLimit: SwiperProps<unknown>['offsetLimit']\n modeConfig: CompoundModeConfig\n dataCount: number\n spaceBetween: number\n}\n\n/**\n * `offsetLimit` is used to limit the range of offset. Useful for when setting `align='start'`,\n * the last item should align with right edge, instead of align to the left.\n * This can achieved by setting offsetLimit to `[0, containerWidth - itemWidth]`, which basically\n * prevent further scroll if the last item is bond to right edge.\n */\nexport function useOffsetLimit({\n offsetLimit,\n loop,\n modeConfig,\n itemWidth,\n containerWidth,\n spaceBetween,\n dataCount,\n}: IOffsetLimit): OffsetLimitResult {\n const finalOffsetLimit = useMemo<OffsetLimitResult>(() => {\n const epsilon = 0.000001\n const fullSize = itemWidth + spaceBetween\n const totalContentWidth = fullSize * dataCount - spaceBetween\n\n if (loop) {\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n } else if (offsetLimit) {\n return {\n startLimit: offsetLimit[0],\n endLimit: offsetLimit[1],\n isNotEnoughForScreen: false,\n }\n } else {\n // If SwiperItem can not occupy the screen, do not apply offsetLimit.\n if (\n modeConfig.mode === 'normal'\n && totalContentWidth <= containerWidth + epsilon\n ) {\n return {\n startLimit: 0,\n // Lock both start/end to the same offset to disable scroll.\n endLimit: Math.max(fullSize * (dataCount - 1), 0),\n isNotEnoughForScreen: true,\n }\n }\n\n if (modeConfig.mode === 'normal' && modeConfig.align === 'start') {\n return {\n startLimit: 0,\n endLimit: containerWidth - itemWidth,\n isNotEnoughForScreen: false,\n }\n } else if (modeConfig.mode === 'normal' && modeConfig.align === 'end') {\n return {\n startLimit: containerWidth - itemWidth,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n }, [\n dataCount,\n offsetLimit?.[0],\n offsetLimit?.[1],\n modeConfig,\n loop,\n itemWidth,\n spaceBetween,\n containerWidth,\n ])\n\n return finalOffsetLimit\n}\n"],"names":["useOffsetLimit","offsetLimit","loop","modeConfig","itemWidth","containerWidth","spaceBetween","dataCount","finalOffsetLimit","useMemo","epsilon","fullSize","totalContentWidth","Math"],"mappings":";AA6BO,SAASA,eAAe,EAC7BC,WAAW,EACXC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,YAAY,EACZC,SAAS,EACI;IACb,MAAMC,mBAAmBC,QAA2B;QAClD,MAAMC,UAAU;QAChB,MAAMC,WAAWP,YAAYE;QAC7B,MAAMM,oBAAoBD,WAAWJ,YAAYD;QAEjD,IAAIJ,MACF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;QACK,IAAID,aACT,OAAO;YACL,YAAYA,WAAW,CAAC,EAAE;YAC1B,UAAUA,WAAW,CAAC,EAAE;YACxB,sBAAsB;QACxB;QAGA,IACEE,AAAoB,aAApBA,WAAW,IAAI,IACZS,qBAAqBP,iBAAiBK,SAEzC,OAAO;YACL,YAAY;YAEZ,UAAUG,KAAK,GAAG,CAACF,WAAYJ,CAAAA,YAAY,IAAI;YAC/C,sBAAsB;QACxB;QAGF,IAAIJ,AAAoB,aAApBA,WAAW,IAAI,IAAiBA,AAAqB,YAArBA,WAAW,KAAK,EAClD,OAAO;YACL,YAAY;YACZ,UAAUE,iBAAiBD;YAC3B,sBAAsB;QACxB;QACK,IAAID,AAAoB,aAApBA,WAAW,IAAI,IAAiBA,AAAqB,UAArBA,WAAW,KAAK,EACzD,OAAO;YACL,YAAYE,iBAAiBD;YAC7B,UAAU;YACV,sBAAsB;QACxB;QAEF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;IAEJ,GAAG;QACDG;QACAN,aAAa,CAAC,EAAE;QAChBA,aAAa,CAAC,EAAE;QAChBE;QACAD;QACAE;QACAE;QACAD;KACD;IAED,OAAOG;AACT"}
1
+ {"version":3,"file":"hooks/useOffsetLimit.jsx","sources":["../../src/hooks/useOffsetLimit.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 { useMemo } from '@lynx-js/react'\n\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\n\ninterface IOffsetLimit extends\n Required<\n Pick<SwiperProps<unknown>, 'loop' | 'itemWidth' | 'containerWidth'>\n >\n{\n offsetLimit: SwiperProps<unknown>['offsetLimit']\n modeConfig: CompoundModeConfig\n dataCount: number\n spaceBetween: number\n}\n\n/**\n * `offsetLimit` is used to limit the range of offset. Useful for when setting `align='start'`,\n * the last item should align with right edge, instead of align to the left.\n * This can achieved by setting offsetLimit to `[0, containerWidth - itemWidth]`, which basically\n * prevent further scroll if the last item is bond to right edge.\n */\nexport function useOffsetLimit({\n offsetLimit,\n loop,\n modeConfig,\n itemWidth,\n containerWidth,\n spaceBetween,\n dataCount,\n}: IOffsetLimit): OffsetLimitResult {\n const finalOffsetLimit = useMemo<OffsetLimitResult>(() => {\n const epsilon = 0.000001\n const fullSize = itemWidth + spaceBetween\n const totalContentWidth = fullSize * dataCount - spaceBetween\n\n if (loop) {\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n } else if (offsetLimit) {\n return {\n startLimit: offsetLimit[0],\n endLimit: offsetLimit[1],\n isNotEnoughForScreen: false,\n }\n } else {\n // If SwiperItem can not occupy the screen, do not apply offsetLimit.\n if (\n modeConfig.mode === 'normal'\n && totalContentWidth <= containerWidth + epsilon\n ) {\n return {\n startLimit: 0,\n // Lock both start/end to the same offset to disable scroll.\n endLimit: Math.max(fullSize * (dataCount - 1), 0),\n isNotEnoughForScreen: true,\n }\n }\n\n if (modeConfig.mode === 'normal' && modeConfig.align === 'start') {\n return {\n startLimit: 0,\n endLimit: containerWidth - itemWidth,\n isNotEnoughForScreen: false,\n }\n } else if (modeConfig.mode === 'normal' && modeConfig.align === 'end') {\n return {\n startLimit: containerWidth - itemWidth,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n }, [\n dataCount,\n offsetLimit?.[0],\n offsetLimit?.[1],\n modeConfig,\n loop,\n itemWidth,\n spaceBetween,\n containerWidth,\n ])\n\n return finalOffsetLimit\n}\n"],"names":["useOffsetLimit","offsetLimit","loop","modeConfig","itemWidth","containerWidth","spaceBetween","dataCount","finalOffsetLimit","useMemo","epsilon","fullSize","totalContentWidth","Math"],"mappings":";AA6BO,SAASA,eAAe,EAC7BC,WAAW,EACXC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,YAAY,EACZC,SAAS,EACI;IACb,MAAMC,mBAAmBC,QAA2B;QAClD,MAAMC,UAAU;QAChB,MAAMC,WAAWP,YAAYE;QAC7B,MAAMM,oBAAoBD,WAAWJ,YAAYD;QAEjD,IAAIJ,MACF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;QACK,IAAID,aACT,OAAO;YACL,YAAYA,WAAW,CAAC,EAAE;YAC1B,UAAUA,WAAW,CAAC,EAAE;YACxB,sBAAsB;QACxB;QAGA,IACEE,AAAoB,aAApBA,WAAW,IAAI,IACZS,qBAAqBP,iBAAiBK,SAEzC,OAAO;YACL,YAAY;YAEZ,UAAUG,KAAK,GAAG,CAACF,WAAYJ,CAAAA,YAAY,IAAI;YAC/C,sBAAsB;QACxB;QAGF,IAAIJ,AAAoB,aAApBA,WAAW,IAAI,IAAiBA,AAAqB,YAArBA,WAAW,KAAK,EAClD,OAAO;YACL,YAAY;YACZ,UAAUE,iBAAiBD;YAC3B,sBAAsB;QACxB;QACK,IAAID,AAAoB,aAApBA,WAAW,IAAI,IAAiBA,AAAqB,UAArBA,WAAW,KAAK,EACzD,OAAO;YACL,YAAYE,iBAAiBD;YAC7B,UAAU;YACV,sBAAsB;QACxB;QAEF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;IAEJ,GAAG;QACDG;QACAN,aAAa,CAAC,EAAE;QAChBA,aAAa,CAAC,EAAE;QAChBE;QACAD;QACAE;QACAE;QACAD;KACD;IAED,OAAOG;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useReset.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useReset.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 { runOnMainThread, useEffect, useRef } from '@lynx-js/react'\n\nimport { useMemoizedFn } from '@lynx-js/lynx-ui-common'\nimport type { NodesRef } from '@lynx-js/types'\n\nimport type {\n CompoundModeConfig,\n ResetOptions,\n SwiperProps,\n UpdateSwiperInnerContainerOptions,\n} from '../types'\n\ninterface UseResetOpts extends\n Required<\n Pick<\n SwiperProps<unknown>,\n | 'swiperKey'\n | 'loop'\n | 'itemWidth'\n | 'itemHeight'\n | 'containerWidth'\n | 'initialIndex'\n | 'loopDuplicateCount'\n >\n >\n{\n resetOnReuse: SwiperProps<unknown>['resetOnReuse']\n dataCount: number\n modeConfig: CompoundModeConfig\n spaceBetween: number\n resetOffsetMT: (fullReset: ResetOptions) => void\n updateSwiperInnerContainerSizeMT: (\n updateOptions: UpdateSwiperInnerContainerOptions,\n ) => void\n startAutoPlayMT: () => void\n}\n\nexport function useReset({\n swiperKey,\n itemHeight,\n itemWidth,\n containerWidth,\n loop,\n dataCount,\n modeConfig,\n resetOffsetMT,\n resetOnReuse,\n initialIndex,\n updateSwiperInnerContainerSizeMT,\n loopDuplicateCount,\n startAutoPlayMT,\n spaceBetween,\n}: UseResetOpts) {\n const prevSwiperKey = useRef<unknown>(swiperKey)\n const isFirstRun = useRef<boolean>(true)\n const containerRef = useRef<NodesRef | null>(null)\n\n function doResetMT(\n resetOptions: ResetOptions & UpdateSwiperInnerContainerOptions,\n ) {\n 'main thread'\n // Get props from function args, instead of automatically captured, to avoid staled states\n const {\n fullReset,\n resetIndex,\n dataCount: _dataCount,\n itemWidth: _itemWidth,\n loop: _loop,\n loopDuplicateCount: _loopDuplicateCount,\n spaceBetween: _gap,\n itemHeight: _itemHeight,\n } = resetOptions\n resetOffsetMT({\n fullReset,\n resetIndex,\n })\n updateSwiperInnerContainerSizeMT({\n dataCount: _dataCount,\n itemWidth: _itemWidth,\n loop: _loop,\n loopDuplicateCount: _loopDuplicateCount,\n spaceBetween: _gap,\n itemHeight: _itemHeight,\n mode: modeConfig.mode,\n })\n startAutoPlayMT()\n }\n\n const doReset = useMemoizedFn((fullReset: boolean) => {\n runOnMainThread(doResetMT)({\n fullReset,\n resetIndex: fullReset ? initialIndex : undefined,\n dataCount,\n itemWidth,\n loop,\n loopDuplicateCount,\n spaceBetween,\n itemHeight,\n mode: modeConfig.mode,\n })\n })\n\n /**\n * When used in list, while Swiper Component is new, container element will be reused, causing old styles are applied.\n * When reused, ref setter will fire setRef with null, then with actual nodes\n * We use this as the sign of reuse, and doing a clean up.\n */\n const setContainerRef = useMemoizedFn(\n (ref: NodesRef) => {\n if (containerRef.current === null && ref !== null && resetOnReuse) {\n doReset(true)\n }\n containerRef.current = ref\n },\n )\n\n useEffect(() => {\n if (isFirstRun.current) {\n isFirstRun.current = false\n return\n }\n if (prevSwiperKey.current === swiperKey) {\n doReset(false)\n } else {\n prevSwiperKey.current = swiperKey\n doReset(true)\n }\n }, [\n modeConfig,\n itemWidth,\n containerWidth,\n loop,\n dataCount,\n itemHeight,\n swiperKey,\n loopDuplicateCount,\n ])\n\n return { setContainerRef }\n}\n"],"names":["useReset","swiperKey","itemHeight","itemWidth","containerWidth","loop","dataCount","modeConfig","resetOffsetMT","resetOnReuse","initialIndex","updateSwiperInnerContainerSizeMT","loopDuplicateCount","startAutoPlayMT","spaceBetween","prevSwiperKey","useRef","isFirstRun","containerRef","doResetMT","resetOptions","fullReset","resetIndex","_dataCount","_itemWidth","_loop","_loopDuplicateCount","_gap","_itemHeight","doReset","useMemoizedFn","runOnMainThread","undefined","setContainerRef","ref","useEffect"],"mappings":";;AAyCO,SAASA,SAAS,EACvBC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,SAAS,EACTC,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,gCAAgC,EAChCC,kBAAkB,EAClBC,eAAe,EACfC,YAAY,EACC;IACb,MAAMC,gBAAgBC,OAAgBf;IACtC,MAAMgB,aAAaD,OAAgB;IACnC,MAAME,eAAeF,OAAwB;IAE7C,SAASG,UACPC,YAA8D;QAE9D;QAEA,MAAM,EACJC,SAAS,EACTC,UAAU,EACV,WAAWC,UAAU,EACrB,WAAWC,UAAU,EACrB,MAAMC,KAAK,EACX,oBAAoBC,mBAAmB,EACvC,cAAcC,IAAI,EAClB,YAAYC,WAAW,EACxB,GAAGR;QACJZ,cAAc;YACZa;YACAC;QACF;QACAX,iCAAiC;YAC/B,WAAWY;YACX,WAAWC;YACX,MAAMC;YACN,oBAAoBC;YACpB,cAAcC;YACd,YAAYC;YACZ,MAAMrB,WAAW,IAAI;QACvB;QACAM;IACF;IAEA,MAAMgB,UAAUC,cAAc,CAACT;QAC7BU,gBAAgBZ,WAAW;YACzBE;YACA,YAAYA,YAAYX,eAAesB;YACvC1B;YACAH;YACAE;YACAO;YACAE;YACAZ;YACA,MAAMK,WAAW,IAAI;QACvB;IACF;IAOA,MAAM0B,kBAAkBH,cACtB,CAACI;QACC,IAAIhB,AAAyB,SAAzBA,aAAa,OAAO,IAAagB,AAAQ,SAARA,OAAgBzB,cACnDoB,QAAQ;QAEVX,aAAa,OAAO,GAAGgB;IACzB;IAGFC,UAAU;QACR,IAAIlB,WAAW,OAAO,EAAE;YACtBA,WAAW,OAAO,GAAG;YACrB;QACF;QACA,IAAIF,cAAc,OAAO,KAAKd,WAC5B4B,QAAQ;aACH;YACLd,cAAc,OAAO,GAAGd;YACxB4B,QAAQ;QACV;IACF,GAAG;QACDtB;QACAJ;QACAC;QACAC;QACAC;QACAJ;QACAD;QACAW;KACD;IAED,OAAO;QAAEqB;IAAgB;AAC3B"}
1
+ {"version":3,"file":"hooks/useReset.jsx","sources":["../../src/hooks/useReset.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 { runOnMainThread, useEffect, useRef } from '@lynx-js/react'\n\nimport { useMemoizedFn } from '@lynx-js/lynx-ui-common'\nimport type { NodesRef } from '@lynx-js/types'\n\nimport type {\n CompoundModeConfig,\n ResetOptions,\n SwiperProps,\n UpdateSwiperInnerContainerOptions,\n} from '../types'\n\ninterface UseResetOpts extends\n Required<\n Pick<\n SwiperProps<unknown>,\n | 'swiperKey'\n | 'loop'\n | 'itemWidth'\n | 'itemHeight'\n | 'containerWidth'\n | 'initialIndex'\n | 'loopDuplicateCount'\n >\n >\n{\n resetOnReuse: SwiperProps<unknown>['resetOnReuse']\n dataCount: number\n modeConfig: CompoundModeConfig\n spaceBetween: number\n resetOffsetMT: (fullReset: ResetOptions) => void\n updateSwiperInnerContainerSizeMT: (\n updateOptions: UpdateSwiperInnerContainerOptions,\n ) => void\n startAutoPlayMT: () => void\n}\n\nexport function useReset({\n swiperKey,\n itemHeight,\n itemWidth,\n containerWidth,\n loop,\n dataCount,\n modeConfig,\n resetOffsetMT,\n resetOnReuse,\n initialIndex,\n updateSwiperInnerContainerSizeMT,\n loopDuplicateCount,\n startAutoPlayMT,\n spaceBetween,\n}: UseResetOpts) {\n const prevSwiperKey = useRef<unknown>(swiperKey)\n const isFirstRun = useRef<boolean>(true)\n const containerRef = useRef<NodesRef | null>(null)\n\n function doResetMT(\n resetOptions: ResetOptions & UpdateSwiperInnerContainerOptions,\n ) {\n 'main thread'\n // Get props from function args, instead of automatically captured, to avoid staled states\n const {\n fullReset,\n resetIndex,\n dataCount: _dataCount,\n itemWidth: _itemWidth,\n loop: _loop,\n loopDuplicateCount: _loopDuplicateCount,\n spaceBetween: _gap,\n itemHeight: _itemHeight,\n } = resetOptions\n resetOffsetMT({\n fullReset,\n resetIndex,\n })\n updateSwiperInnerContainerSizeMT({\n dataCount: _dataCount,\n itemWidth: _itemWidth,\n loop: _loop,\n loopDuplicateCount: _loopDuplicateCount,\n spaceBetween: _gap,\n itemHeight: _itemHeight,\n mode: modeConfig.mode,\n })\n startAutoPlayMT()\n }\n\n const doReset = useMemoizedFn((fullReset: boolean) => {\n runOnMainThread(doResetMT)({\n fullReset,\n resetIndex: fullReset ? initialIndex : undefined,\n dataCount,\n itemWidth,\n loop,\n loopDuplicateCount,\n spaceBetween,\n itemHeight,\n mode: modeConfig.mode,\n })\n })\n\n /**\n * When used in list, while Swiper Component is new, container element will be reused, causing old styles are applied.\n * When reused, ref setter will fire setRef with null, then with actual nodes\n * We use this as the sign of reuse, and doing a clean up.\n */\n const setContainerRef = useMemoizedFn(\n (ref: NodesRef) => {\n if (containerRef.current === null && ref !== null && resetOnReuse) {\n doReset(true)\n }\n containerRef.current = ref\n },\n )\n\n useEffect(() => {\n if (isFirstRun.current) {\n isFirstRun.current = false\n return\n }\n if (prevSwiperKey.current === swiperKey) {\n doReset(false)\n } else {\n prevSwiperKey.current = swiperKey\n doReset(true)\n }\n }, [\n modeConfig,\n itemWidth,\n containerWidth,\n loop,\n dataCount,\n itemHeight,\n swiperKey,\n loopDuplicateCount,\n ])\n\n return { setContainerRef }\n}\n"],"names":["useReset","swiperKey","itemHeight","itemWidth","containerWidth","loop","dataCount","modeConfig","resetOffsetMT","resetOnReuse","initialIndex","updateSwiperInnerContainerSizeMT","loopDuplicateCount","startAutoPlayMT","spaceBetween","prevSwiperKey","useRef","isFirstRun","containerRef","doResetMT","resetOptions","fullReset","resetIndex","_dataCount","_itemWidth","_loop","_loopDuplicateCount","_gap","_itemHeight","doReset","useMemoizedFn","runOnMainThread","undefined","setContainerRef","ref","useEffect"],"mappings":";;AAyCO,SAASA,SAAS,EACvBC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,SAAS,EACTC,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,YAAY,EACZC,gCAAgC,EAChCC,kBAAkB,EAClBC,eAAe,EACfC,YAAY,EACC;IACb,MAAMC,gBAAgBC,OAAgBf;IACtC,MAAMgB,aAAaD,OAAgB;IACnC,MAAME,eAAeF,OAAwB;IAE7C,SAASG,UACPC,YAA8D;QAE9D;QAEA,MAAM,EACJC,SAAS,EACTC,UAAU,EACV,WAAWC,UAAU,EACrB,WAAWC,UAAU,EACrB,MAAMC,KAAK,EACX,oBAAoBC,mBAAmB,EACvC,cAAcC,IAAI,EAClB,YAAYC,WAAW,EACxB,GAAGR;QACJZ,cAAc;YACZa;YACAC;QACF;QACAX,iCAAiC;YAC/B,WAAWY;YACX,WAAWC;YACX,MAAMC;YACN,oBAAoBC;YACpB,cAAcC;YACd,YAAYC;YACZ,MAAMrB,WAAW,IAAI;QACvB;QACAM;IACF;IAEA,MAAMgB,UAAUC,cAAc,CAACT;QAC7BU,gBAAgBZ,WAAW;YACzBE;YACA,YAAYA,YAAYX,eAAesB;YACvC1B;YACAH;YACAE;YACAO;YACAE;YACAZ;YACA,MAAMK,WAAW,IAAI;QACvB;IACF;IAOA,MAAM0B,kBAAkBH,cACtB,CAACI;QACC,IAAIhB,AAAyB,SAAzBA,aAAa,OAAO,IAAagB,AAAQ,SAARA,OAAgBzB,cACnDoB,QAAQ;QAEVX,aAAa,OAAO,GAAGgB;IACzB;IAGFC,UAAU;QACR,IAAIlB,WAAW,OAAO,EAAE;YACtBA,WAAW,OAAO,GAAG;YACrB;QACF;QACA,IAAIF,cAAc,OAAO,KAAKd,WAC5B4B,QAAQ;aACH;YACLd,cAAc,OAAO,GAAGd;YACxB4B,QAAQ;QACV;IACF,GAAG;QACDtB;QACAJ;QACAC;QACAC;QACAC;QACAJ;QACAD;QACAW;KACD;IAED,OAAO;QAAEqB;IAAgB;AAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useSwipeCallback.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useSwipeCallback.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport { useTapLock } from '@lynx-js/react-use'\nimport type { MainThread } from '@lynx-js/types'\n\n/**\n * Determine whether a touch is swipe or click.\n */\nexport function useSwipeCallback({\n onSwipeStartMT,\n onSwipeStopMT,\n}: {\n onSwipeStartMT: () => void\n onSwipeStopMT: () => void\n}) {\n const swipeStartedMTRef = useMainThreadRef<boolean>(false)\n\n const {\n handleTouchStart: tapLockTouchStart,\n handleTouchMove: tapLockTouchMove,\n } = useTapLock()\n\n function setSwipeStartMT() {\n 'main thread'\n if (swipeStartedMTRef.current) {\n return\n }\n swipeStartedMTRef.current = true\n onSwipeStartMT()\n }\n\n function setSwipeEndMT() {\n 'main thread'\n if (swipeStartedMTRef.current) {\n onSwipeStopMT()\n swipeStartedMTRef.current = false\n }\n }\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n tapLockTouchStart(event)\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (!swipeStartedMTRef.current && !tapLockTouchMove(event)) {\n swipeStartedMTRef.current = true\n onSwipeStartMT()\n return\n }\n }\n\n return {\n handleTouchStart,\n handleTouchMove,\n setSwipeEndMT,\n setSwipeStartMT,\n }\n}\n"],"names":["useSwipeCallback","onSwipeStartMT","onSwipeStopMT","swipeStartedMTRef","useMainThreadRef","tapLockTouchStart","tapLockTouchMove","useTapLock","setSwipeStartMT","setSwipeEndMT","handleTouchStart","event","handleTouchMove"],"mappings":";;AAYO,SAASA,iBAAiB,EAC/BC,cAAc,EACdC,aAAa,EAId;IACC,MAAMC,oBAAoBC,iBAA0B;IAEpD,MAAM,EACJ,kBAAkBC,iBAAiB,EACnC,iBAAiBC,gBAAgB,EAClC,GAAGC;IAEJ,SAASC;QACP;QACA,IAAIL,kBAAkB,OAAO,EAC3B;QAEFA,kBAAkB,OAAO,GAAG;QAC5BF;IACF;IAEA,SAASQ;QACP;QACA,IAAIN,kBAAkB,OAAO,EAAE;YAC7BD;YACAC,kBAAkB,OAAO,GAAG;QAC9B;IACF;IAEA,SAASO,iBAAiBC,KAA4B;QACpD;QAEAN,kBAAkBM;IACpB;IAEA,SAASC,gBAAgBD,KAA4B;QACnD;QAEA,IAAI,CAACR,kBAAkB,OAAO,IAAI,CAACG,iBAAiBK,QAAQ;YAC1DR,kBAAkB,OAAO,GAAG;YAC5BF;YACA;QACF;IACF;IAEA,OAAO;QACLS;QACAE;QACAH;QACAD;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useSwipeCallback.jsx","sources":["../../src/hooks/useSwipeCallback.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport { useTapLock } from '@lynx-js/react-use'\nimport type { MainThread } from '@lynx-js/types'\n\n/**\n * Determine whether a touch is swipe or click.\n */\nexport function useSwipeCallback({\n onSwipeStartMT,\n onSwipeStopMT,\n}: {\n onSwipeStartMT: () => void\n onSwipeStopMT: () => void\n}) {\n const swipeStartedMTRef = useMainThreadRef<boolean>(false)\n\n const {\n handleTouchStart: tapLockTouchStart,\n handleTouchMove: tapLockTouchMove,\n } = useTapLock()\n\n function setSwipeStartMT() {\n 'main thread'\n if (swipeStartedMTRef.current) {\n return\n }\n swipeStartedMTRef.current = true\n onSwipeStartMT()\n }\n\n function setSwipeEndMT() {\n 'main thread'\n if (swipeStartedMTRef.current) {\n onSwipeStopMT()\n swipeStartedMTRef.current = false\n }\n }\n\n function handleTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n tapLockTouchStart(event)\n }\n\n function handleTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n if (!swipeStartedMTRef.current && !tapLockTouchMove(event)) {\n swipeStartedMTRef.current = true\n onSwipeStartMT()\n return\n }\n }\n\n return {\n handleTouchStart,\n handleTouchMove,\n setSwipeEndMT,\n setSwipeStartMT,\n }\n}\n"],"names":["useSwipeCallback","onSwipeStartMT","onSwipeStopMT","swipeStartedMTRef","useMainThreadRef","tapLockTouchStart","tapLockTouchMove","useTapLock","setSwipeStartMT","setSwipeEndMT","handleTouchStart","event","handleTouchMove"],"mappings":";;AAYO,SAASA,iBAAiB,EAC/BC,cAAc,EACdC,aAAa,EAId;IACC,MAAMC,oBAAoBC,iBAA0B;IAEpD,MAAM,EACJ,kBAAkBC,iBAAiB,EACnC,iBAAiBC,gBAAgB,EAClC,GAAGC;IAEJ,SAASC;QACP;QACA,IAAIL,kBAAkB,OAAO,EAC3B;QAEFA,kBAAkB,OAAO,GAAG;QAC5BF;IACF;IAEA,SAASQ;QACP;QACA,IAAIN,kBAAkB,OAAO,EAAE;YAC7BD;YACAC,kBAAkB,OAAO,GAAG;QAC9B;IACF;IAEA,SAASO,iBAAiBC,KAA4B;QACpD;QAEAN,kBAAkBM;IACpB;IAEA,SAASC,gBAAgBD,KAA4B;QACnD;QAEA,IAAI,CAACR,kBAAkB,OAAO,IAAI,CAACG,iBAAiBK,QAAQ;YAC1DR,kBAAkB,OAAO,GAAG;YAC5BF;YACA;QACF;IACF;IAEA,OAAO;QACLS;QACAE;QACAH;QACAD;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useVelocity.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useVelocity.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nimport { SwipeDirection } from '../types'\nimport type { SwiperProps } from '../types'\n\nexport function useVelocity({ RTL }: { RTL: SwiperProps<unknown>['RTL'] }) {\n const positionQueueRef = useMainThreadRef<number[]>([])\n const timeQueueRef = useMainThreadRef<number[]>([])\n\n const reset = () => {\n 'main thread'\n timeQueueRef.current = []\n positionQueueRef.current = []\n }\n\n const pruneQueue = (ms: number, minLength = 0) => {\n 'main thread'\n const timeQueue = timeQueueRef.current\n const positionQueue = positionQueueRef.current\n\n const nowTs = Date.now()\n // pull old values off of the queue\n while (timeQueue.length > minLength && timeQueue[0] < nowTs - ms) {\n timeQueue.shift()\n positionQueue.shift()\n }\n }\n\n const getVelocity = () => {\n 'main thread'\n pruneQueue(500)\n const timeQueue = timeQueueRef.current\n const positionQueue = positionQueueRef.current\n const { length } = timeQueue\n if (length < 2) {\n return {\n velocity: 0,\n direction: SwipeDirection.REVERT,\n }\n }\n const distance = RTL\n ? positionQueue[0] - positionQueue[length - 1]\n : positionQueue[length - 1] - positionQueue[0]\n const time = (timeQueue[length - 1] - timeQueue[0]) / 1000\n return {\n velocity: distance / time,\n direction: distance > 0 ? SwipeDirection.REVERT : SwipeDirection.NORMAL,\n }\n }\n\n const updatePosition = (position: number) => {\n 'main thread'\n const timeQueue = timeQueueRef.current\n const positionQueue = positionQueueRef.current\n\n positionQueue.push(position)\n timeQueue.push(Date.now())\n // Keep one older sample around so sparse touchmove delivery can still\n // produce a release velocity from the latest two points.\n pruneQueue(50, 2)\n }\n\n function velocityTouchStart() {\n 'main thread'\n reset()\n }\n\n function velocityTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n updatePosition(event.detail.x)\n }\n\n return {\n getVelocity,\n velocityTouchStart,\n velocityTouchMove,\n }\n}\n"],"names":["useVelocity","RTL","positionQueueRef","useMainThreadRef","timeQueueRef","reset","pruneQueue","ms","minLength","timeQueue","positionQueue","nowTs","Date","getVelocity","length","SwipeDirection","distance","time","updatePosition","position","velocityTouchStart","velocityTouchMove","event"],"mappings":";;AAWO,SAASA,YAAY,EAAEC,GAAG,EAAwC;IACvE,MAAMC,mBAAmBC,iBAA2B,EAAE;IACtD,MAAMC,eAAeD,iBAA2B,EAAE;IAElD,MAAME,QAAQ;QACZ;QACAD,aAAa,OAAO,GAAG,EAAE;QACzBF,iBAAiB,OAAO,GAAG,EAAE;IAC/B;IAEA,MAAMI,aAAa,CAACC,IAAYC,YAAY,CAAC;QAC3C;QACA,MAAMC,YAAYL,aAAa,OAAO;QACtC,MAAMM,gBAAgBR,iBAAiB,OAAO;QAE9C,MAAMS,QAAQC,KAAK,GAAG;QAEtB,MAAOH,UAAU,MAAM,GAAGD,aAAaC,SAAS,CAAC,EAAE,GAAGE,QAAQJ,GAAI;YAChEE,UAAU,KAAK;YACfC,cAAc,KAAK;QACrB;IACF;IAEA,MAAMG,cAAc;QAClB;QACAP,WAAW;QACX,MAAMG,YAAYL,aAAa,OAAO;QACtC,MAAMM,gBAAgBR,iBAAiB,OAAO;QAC9C,MAAM,EAAEY,MAAM,EAAE,GAAGL;QACnB,IAAIK,SAAS,GACX,OAAO;YACL,UAAU;YACV,WAAWC,eAAe,MAAM;QAClC;QAEF,MAAMC,WAAWf,MACbS,aAAa,CAAC,EAAE,GAAGA,aAAa,CAACI,SAAS,EAAE,GAC5CJ,aAAa,CAACI,SAAS,EAAE,GAAGJ,aAAa,CAAC,EAAE;QAChD,MAAMO,OAAQR,AAAAA,CAAAA,SAAS,CAACK,SAAS,EAAE,GAAGL,SAAS,CAAC,EAAC,IAAK;QACtD,OAAO;YACL,UAAUO,WAAWC;YACrB,WAAWD,WAAW,IAAID,eAAe,MAAM,GAAGA,eAAe,MAAM;QACzE;IACF;IAEA,MAAMG,iBAAiB,CAACC;QACtB;QACA,MAAMV,YAAYL,aAAa,OAAO;QACtC,MAAMM,gBAAgBR,iBAAiB,OAAO;QAE9CQ,cAAc,IAAI,CAACS;QACnBV,UAAU,IAAI,CAACG,KAAK,GAAG;QAGvBN,WAAW,IAAI;IACjB;IAEA,SAASc;QACP;QACAf;IACF;IAEA,SAASgB,kBAAkBC,KAA4B;QACrD;QAEAJ,eAAeI,MAAM,MAAM,CAAC,CAAC;IAC/B;IAEA,OAAO;QACLT;QACAO;QACAC;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useVelocity.jsx","sources":["../../src/hooks/useVelocity.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nimport { SwipeDirection } from '../types'\nimport type { SwiperProps } from '../types'\n\nexport function useVelocity({ RTL }: { RTL: SwiperProps<unknown>['RTL'] }) {\n const positionQueueRef = useMainThreadRef<number[]>([])\n const timeQueueRef = useMainThreadRef<number[]>([])\n\n const reset = () => {\n 'main thread'\n timeQueueRef.current = []\n positionQueueRef.current = []\n }\n\n const pruneQueue = (ms: number, minLength = 0) => {\n 'main thread'\n const timeQueue = timeQueueRef.current\n const positionQueue = positionQueueRef.current\n\n const nowTs = Date.now()\n // pull old values off of the queue\n while (timeQueue.length > minLength && timeQueue[0] < nowTs - ms) {\n timeQueue.shift()\n positionQueue.shift()\n }\n }\n\n const getVelocity = () => {\n 'main thread'\n pruneQueue(500)\n const timeQueue = timeQueueRef.current\n const positionQueue = positionQueueRef.current\n const { length } = timeQueue\n if (length < 2) {\n return {\n velocity: 0,\n direction: SwipeDirection.REVERT,\n }\n }\n const distance = RTL\n ? positionQueue[0] - positionQueue[length - 1]\n : positionQueue[length - 1] - positionQueue[0]\n const time = (timeQueue[length - 1] - timeQueue[0]) / 1000\n return {\n velocity: distance / time,\n direction: distance > 0 ? SwipeDirection.REVERT : SwipeDirection.NORMAL,\n }\n }\n\n const updatePosition = (position: number) => {\n 'main thread'\n const timeQueue = timeQueueRef.current\n const positionQueue = positionQueueRef.current\n\n positionQueue.push(position)\n timeQueue.push(Date.now())\n // Keep one older sample around so sparse touchmove delivery can still\n // produce a release velocity from the latest two points.\n pruneQueue(50, 2)\n }\n\n function velocityTouchStart() {\n 'main thread'\n reset()\n }\n\n function velocityTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n\n updatePosition(event.detail.x)\n }\n\n return {\n getVelocity,\n velocityTouchStart,\n velocityTouchMove,\n }\n}\n"],"names":["useVelocity","RTL","positionQueueRef","useMainThreadRef","timeQueueRef","reset","pruneQueue","ms","minLength","timeQueue","positionQueue","nowTs","Date","getVelocity","length","SwipeDirection","distance","time","updatePosition","position","velocityTouchStart","velocityTouchMove","event"],"mappings":";;AAWO,SAASA,YAAY,EAAEC,GAAG,EAAwC;IACvE,MAAMC,mBAAmBC,iBAA2B,EAAE;IACtD,MAAMC,eAAeD,iBAA2B,EAAE;IAElD,MAAME,QAAQ;QACZ;QACAD,aAAa,OAAO,GAAG,EAAE;QACzBF,iBAAiB,OAAO,GAAG,EAAE;IAC/B;IAEA,MAAMI,aAAa,CAACC,IAAYC,YAAY,CAAC;QAC3C;QACA,MAAMC,YAAYL,aAAa,OAAO;QACtC,MAAMM,gBAAgBR,iBAAiB,OAAO;QAE9C,MAAMS,QAAQC,KAAK,GAAG;QAEtB,MAAOH,UAAU,MAAM,GAAGD,aAAaC,SAAS,CAAC,EAAE,GAAGE,QAAQJ,GAAI;YAChEE,UAAU,KAAK;YACfC,cAAc,KAAK;QACrB;IACF;IAEA,MAAMG,cAAc;QAClB;QACAP,WAAW;QACX,MAAMG,YAAYL,aAAa,OAAO;QACtC,MAAMM,gBAAgBR,iBAAiB,OAAO;QAC9C,MAAM,EAAEY,MAAM,EAAE,GAAGL;QACnB,IAAIK,SAAS,GACX,OAAO;YACL,UAAU;YACV,WAAWC,eAAe,MAAM;QAClC;QAEF,MAAMC,WAAWf,MACbS,aAAa,CAAC,EAAE,GAAGA,aAAa,CAACI,SAAS,EAAE,GAC5CJ,aAAa,CAACI,SAAS,EAAE,GAAGJ,aAAa,CAAC,EAAE;QAChD,MAAMO,OAAQR,AAAAA,CAAAA,SAAS,CAACK,SAAS,EAAE,GAAGL,SAAS,CAAC,EAAC,IAAK;QACtD,OAAO;YACL,UAAUO,WAAWC;YACrB,WAAWD,WAAW,IAAID,eAAe,MAAM,GAAGA,eAAe,MAAM;QACzE;IACF;IAEA,MAAMG,iBAAiB,CAACC;QACtB;QACA,MAAMV,YAAYL,aAAa,OAAO;QACtC,MAAMM,gBAAgBR,iBAAiB,OAAO;QAE9CQ,cAAc,IAAI,CAACS;QACnBV,UAAU,IAAI,CAACG,KAAK,GAAG;QAGvBN,WAAW,IAAI;IACjB;IAEA,SAASc;QACP;QACAf;IACF;IAEA,SAASgB,kBAAkBC,KAA4B;QACrD;QAEAJ,eAAeI,MAAM,MAAM,CAAC,CAAC;IAC/B;IAEA,OAAO;QACLT;QACAO;QACAC;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks/useVelocity_experiment.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useVelocity_experiment.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nexport function useVelocity({ deceleratingRate = 0.99 }) {\n const touchStartRef = useMainThreadRef<number>(0)\n const velocityRef = useMainThreadRef<number>(0)\n\n function velocityTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n touchStartRef.current = event.detail.x\n }\n\n function velocityTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n const timeDuration = Date.now() - event.timestamp\n\n const delta = event.detail.x - touchStartRef.current\n const velocity = delta / timeDuration\n velocityRef.current = velocity\n }\n\n function getVelocityDistance() {\n 'main thread'\n const velocity = velocityRef.current\n const distance = Math.pow(velocity, 2) / (2 * deceleratingRate)\n return distance\n }\n\n function getVelocity() {\n 'main thread'\n const distance = getVelocityDistance()\n\n return {\n velocity: velocityRef.current,\n distance,\n }\n }\n\n return {\n getVelocity,\n velocityTouchStart,\n velocityTouchMove,\n }\n}\n"],"names":["useVelocity","deceleratingRate","touchStartRef","useMainThreadRef","velocityRef","velocityTouchStart","event","velocityTouchMove","timeDuration","Date","delta","velocity","getVelocityDistance","distance","Math","getVelocity"],"mappings":";AAQO,SAASA,YAAY,EAAEC,mBAAmB,IAAI,EAAE;IACrD,MAAMC,gBAAgBC,iBAAyB;IAC/C,MAAMC,cAAcD,iBAAyB;IAE7C,SAASE,mBAAmBC,KAA4B;QACtD;QAEAJ,cAAc,OAAO,GAAGI,MAAM,MAAM,CAAC,CAAC;IACxC;IAEA,SAASC,kBAAkBD,KAA4B;QACrD;QACA,MAAME,eAAeC,KAAK,GAAG,KAAKH,MAAM,SAAS;QAEjD,MAAMI,QAAQJ,MAAM,MAAM,CAAC,CAAC,GAAGJ,cAAc,OAAO;QACpD,MAAMS,WAAWD,QAAQF;QACzBJ,YAAY,OAAO,GAAGO;IACxB;IAEA,SAASC;QACP;QACA,MAAMD,WAAWP,YAAY,OAAO;QACpC,MAAMS,WAAWC,KAAK,GAAG,CAACH,UAAU,KAAM,KAAIV,gBAAe;QAC7D,OAAOY;IACT;IAEA,SAASE;QACP;QACA,MAAMF,WAAWD;QAEjB,OAAO;YACL,UAAUR,YAAY,OAAO;YAC7BS;QACF;IACF;IAEA,OAAO;QACLE;QACAV;QACAE;IACF;AACF"}
1
+ {"version":3,"file":"hooks/useVelocity_experiment.jsx","sources":["../../src/hooks/useVelocity_experiment.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 { useMainThreadRef } from '@lynx-js/react'\n\nimport type { MainThread } from '@lynx-js/types'\n\nexport function useVelocity({ deceleratingRate = 0.99 }) {\n const touchStartRef = useMainThreadRef<number>(0)\n const velocityRef = useMainThreadRef<number>(0)\n\n function velocityTouchStart(event: MainThread.TouchEvent) {\n 'main thread'\n\n touchStartRef.current = event.detail.x\n }\n\n function velocityTouchMove(event: MainThread.TouchEvent) {\n 'main thread'\n const timeDuration = Date.now() - event.timestamp\n\n const delta = event.detail.x - touchStartRef.current\n const velocity = delta / timeDuration\n velocityRef.current = velocity\n }\n\n function getVelocityDistance() {\n 'main thread'\n const velocity = velocityRef.current\n const distance = Math.pow(velocity, 2) / (2 * deceleratingRate)\n return distance\n }\n\n function getVelocity() {\n 'main thread'\n const distance = getVelocityDistance()\n\n return {\n velocity: velocityRef.current,\n distance,\n }\n }\n\n return {\n getVelocity,\n velocityTouchStart,\n velocityTouchMove,\n }\n}\n"],"names":["useVelocity","deceleratingRate","touchStartRef","useMainThreadRef","velocityRef","velocityTouchStart","event","velocityTouchMove","timeDuration","Date","delta","velocity","getVelocityDistance","distance","Math","getVelocity"],"mappings":";AAQO,SAASA,YAAY,EAAEC,mBAAmB,IAAI,EAAE;IACrD,MAAMC,gBAAgBC,iBAAyB;IAC/C,MAAMC,cAAcD,iBAAyB;IAE7C,SAASE,mBAAmBC,KAA4B;QACtD;QAEAJ,cAAc,OAAO,GAAGI,MAAM,MAAM,CAAC,CAAC;IACxC;IAEA,SAASC,kBAAkBD,KAA4B;QACrD;QACA,MAAME,eAAeC,KAAK,GAAG,KAAKH,MAAM,SAAS;QAEjD,MAAMI,QAAQJ,MAAM,MAAM,CAAC,CAAC,GAAGJ,cAAc,OAAO;QACpD,MAAMS,WAAWD,QAAQF;QACzBJ,YAAY,OAAO,GAAGO;IACxB;IAEA,SAASC;QACP;QACA,MAAMD,WAAWP,YAAY,OAAO;QACpC,MAAMS,WAAWC,KAAK,GAAG,CAACH,UAAU,KAAM,KAAIV,gBAAe;QAC7D,OAAOY;IACT;IAEA,SAASE;QACP;QACA,MAAMF,WAAWD;QAEjB,OAAO;YACL,UAAUR,YAAY,OAAO;YAC7BS;QACF;IACF;IAEA,OAAO;QACLE;QACAV;QACAE;IACF;AACF"}
package/dist/index.jsx CHANGED
@@ -1,3 +1,2 @@
1
- import { Swiper } from "./Swiper/index.jsx";
2
- import { SwiperItem } from "./SwiperItem/index.jsx";
3
- export { Swiper, SwiperItem };
1
+ export { Swiper } from "./Swiper/index.jsx";
2
+ export { SwiperItem } from "./SwiperItem/index.jsx";
@@ -1 +1 @@
1
- {"version":3,"file":"store/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/store/index.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 { createContext } from '@lynx-js/react'\n\nimport { noop } from '@lynx-js/lynx-ui-common'\n\nimport type { SwiperContextProps } from '../types'\n\nexport interface SwiperItemContextProps {\n index: number\n realIndex: number\n}\n\nexport const SwiperContext = createContext<SwiperContextProps>({\n itemWidth: 350,\n itemHeight: 'auto',\n setChildrenRef: noop,\n modeConfig: {\n mode: 'normal',\n align: 'start',\n },\n initialIndex: 0,\n loop: false,\n spaceBetween: 0,\n RTL: false,\n})\n\nexport const SwiperItemContext = createContext<\n SwiperItemContextProps | undefined\n>(undefined)\n"],"names":["SwiperContext","createContext","noop","SwiperItemContext","undefined"],"mappings":";;AAeO,MAAMA,gBAAgBC,cAAkC;IAC7D,WAAW;IACX,YAAY;IACZ,gBAAgBC;IAChB,YAAY;QACV,MAAM;QACN,OAAO;IACT;IACA,cAAc;IACd,MAAM;IACN,cAAc;IACd,KAAK;AACP;AAEO,MAAMC,oBAAoBF,cAE/BG"}
1
+ {"version":3,"file":"store/index.jsx","sources":["../../src/store/index.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 { createContext } from '@lynx-js/react'\n\nimport { noop } from '@lynx-js/lynx-ui-common'\n\nimport type { SwiperContextProps } from '../types'\n\nexport interface SwiperItemContextProps {\n index: number\n realIndex: number\n}\n\nexport const SwiperContext = createContext<SwiperContextProps>({\n itemWidth: 350,\n itemHeight: 'auto',\n setChildrenRef: noop,\n modeConfig: {\n mode: 'normal',\n align: 'start',\n },\n initialIndex: 0,\n loop: false,\n spaceBetween: 0,\n RTL: false,\n})\n\nexport const SwiperItemContext = createContext<\n SwiperItemContextProps | undefined\n>(undefined)\n"],"names":["SwiperContext","createContext","noop","SwiperItemContext","undefined"],"mappings":";;AAeO,MAAMA,gBAAgBC,cAAkC;IAC7D,WAAW;IACX,YAAY;IACZ,gBAAgBC;IAChB,YAAY;QACV,MAAM;QACN,OAAO;IACT;IACA,cAAc;IACd,MAAM;IACN,cAAc;IACd,KAAK;AACP;AAEO,MAAMC,oBAAoBF,cAE/BG"}
@@ -0,0 +1 @@
1
+ export { };
@@ -1 +1 @@
1
- {"version":3,"file":"types/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/types/index.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 { CSSProperties, MainThread } from '@lynx-js/types'\n\nimport type {\n BounceConfig,\n SwipeToOptions,\n SwiperPropsReal as SwiperProps,\n SwiperRef,\n onBounceParams,\n} from './index.docs'\n\nexport interface SwiperContextProps extends\n Pick<\n SwiperProps<unknown>,\n 'itemWidth' | 'itemHeight' | 'customAnimationFirstScreen' | 'RTL'\n >,\n Required<Pick<SwiperProps<unknown>, 'initialIndex' | 'loop'>>\n{\n setChildrenRef: (ref: MainThread.Element, index: number) => void\n spaceBetween: number\n modeConfig: CompoundModeConfig\n}\n\nexport interface CompoundNormalModeConfig {\n mode: 'normal'\n align: 'start' | 'center' | 'end'\n}\n\nexport interface CompoundCustomModeConfig {\n mode: 'custom'\n}\n\nexport type CompoundModeConfig =\n | CompoundNormalModeConfig\n | CompoundCustomModeConfig\n\nexport type customAnimation = (\n progress: number,\n props: SwiperProps<unknown>,\n) => CSSProperties\n\nexport interface CustomTouch {\n identifier: number\n pageX: number\n pageY: number\n clientX: number\n clientY: number\n x: number\n y: number\n}\n\n/**\n * Rewrite forwardRef to make it supports generic\n * see: https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\n */\ndeclare module 'react' {\n // biome-ignore lint/complexity/noBannedTypes: Expected\n function forwardRef<T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,\n ): (props: P & React.RefAttributes<T>) => React.ReactElement | null\n}\n\ndeclare module '@lynx-js/types' {\n interface GlobalProps {\n screenWidth: number\n }\n}\n\nexport interface ResetOptions {\n fullReset?: boolean\n resetIndex?: number\n}\n\nexport interface UpdateSwiperInnerContainerOptions {\n itemWidth: number\n loopDuplicateCount: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n itemHeight: SwiperProps<unknown>['itemHeight']\n mode: CompoundModeConfig['mode']\n}\n\nexport enum SwipeDirection {\n NORMAL = -1,\n NONE = 0,\n REVERT = 1,\n}\n\nexport interface OffsetLimitResult {\n startLimit: number\n endLimit: number\n isNotEnoughForScreen: boolean\n}\n\nexport type {\n BounceConfig,\n SwiperRef,\n onBounceParams,\n SwipeToOptions,\n SwiperProps,\n}\n"],"names":["SwipeDirection"],"mappings":"AAsFO,IAAKA,uBAAcA,WAAAA,GAAAA,SAAdA,cAAc;;;;WAAdA"}
1
+ {"version":3,"file":"types/index.jsx","sources":["../../src/types/index.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 { CSSProperties, MainThread } from '@lynx-js/types'\n\nimport type {\n BounceConfig,\n SwipeToOptions,\n SwiperPropsReal as SwiperProps,\n SwiperRef,\n onBounceParams,\n} from './index.docs'\n\nexport interface SwiperContextProps extends\n Pick<\n SwiperProps<unknown>,\n 'itemWidth' | 'itemHeight' | 'customAnimationFirstScreen' | 'RTL'\n >,\n Required<Pick<SwiperProps<unknown>, 'initialIndex' | 'loop'>>\n{\n setChildrenRef: (ref: MainThread.Element, index: number) => void\n spaceBetween: number\n modeConfig: CompoundModeConfig\n}\n\nexport interface CompoundNormalModeConfig {\n mode: 'normal'\n align: 'start' | 'center' | 'end'\n}\n\nexport interface CompoundCustomModeConfig {\n mode: 'custom'\n}\n\nexport type CompoundModeConfig =\n | CompoundNormalModeConfig\n | CompoundCustomModeConfig\n\nexport type customAnimation = (\n progress: number,\n props: SwiperProps<unknown>,\n) => CSSProperties\n\nexport interface CustomTouch {\n identifier: number\n pageX: number\n pageY: number\n clientX: number\n clientY: number\n x: number\n y: number\n}\n\n/**\n * Rewrite forwardRef to make it supports generic\n * see: https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\n */\ndeclare module 'react' {\n // biome-ignore lint/complexity/noBannedTypes: Expected\n function forwardRef<T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,\n ): (props: P & React.RefAttributes<T>) => React.ReactElement | null\n}\n\ndeclare module '@lynx-js/types' {\n interface GlobalProps {\n screenWidth: number\n }\n}\n\nexport interface ResetOptions {\n fullReset?: boolean\n resetIndex?: number\n}\n\nexport interface UpdateSwiperInnerContainerOptions {\n itemWidth: number\n loopDuplicateCount: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n itemHeight: SwiperProps<unknown>['itemHeight']\n mode: CompoundModeConfig['mode']\n}\n\nexport enum SwipeDirection {\n NORMAL = -1,\n NONE = 0,\n REVERT = 1,\n}\n\nexport interface OffsetLimitResult {\n startLimit: number\n endLimit: number\n isNotEnoughForScreen: boolean\n}\n\nexport type {\n BounceConfig,\n SwiperRef,\n onBounceParams,\n SwipeToOptions,\n SwiperProps,\n}\n"],"names":["SwipeDirection"],"mappings":"AAsFO,IAAKA,uBAAcA,WAAAA,GAAAA,SAAdA,cAAc;;;;WAAdA"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils/animate.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/utils/animate.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\nexport function animate(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n) {\n 'main thread'\n let startTs = 0\n let rafId = 0\n\n function tick(ts: number) {\n const progress = Math.max(\n Math.min(((ts - startTs) * 100) / duration, 100),\n 0,\n )\n\n onUpdate(progress)\n }\n\n function updateRafId(id: number) {\n rafId = id\n }\n\n function step(ts: number) {\n if (!startTs) {\n startTs = Number(ts)\n }\n // make sure progress can reach 100%\n if (ts - startTs <= duration + 100) {\n tick(ts)\n updateRafId(requestAnimationFrame(step))\n } else {\n onFinished?.()\n }\n }\n\n updateRafId(requestAnimationFrame(step))\n\n function cancel() {\n cancelAnimationFrame(rafId)\n }\n\n return {\n cancel,\n }\n}\n"],"names":["animate","duration","onUpdate","onFinished","startTs","rafId","tick","ts","progress","Math","updateRafId","id","step","Number","requestAnimationFrame","cancel","cancelAnimationFrame"],"mappings":"AAIO,SAASA,QACdC,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;IAEvB;IACA,IAAIC,UAAU;IACd,IAAIC,QAAQ;IAEZ,SAASC,KAAKC,EAAU;QACtB,MAAMC,WAAWC,KAAK,GAAG,CACvBA,KAAK,GAAG,CAAGF,AAAAA,CAAAA,KAAKH,OAAM,IAAK,MAAOH,UAAU,MAC5C;QAGFC,SAASM;IACX;IAEA,SAASE,YAAYC,EAAU;QAC7BN,QAAQM;IACV;IAEA,SAASC,KAAKL,EAAU;QACtB,IAAI,CAACH,SACHA,UAAUS,OAAON;QAGnB,IAAIA,KAAKH,WAAWH,WAAW,KAAK;YAClCK,KAAKC;YACLG,YAAYI,sBAAsBF;QACpC,OACET;IAEJ;IAEAO,YAAYI,sBAAsBF;IAElC,SAASG;QACPC,qBAAqBX;IACvB;IAEA,OAAO;QACLU;IACF;AACF"}
1
+ {"version":3,"file":"utils/animate.jsx","sources":["../../src/utils/animate.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\nexport function animate(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n) {\n 'main thread'\n let startTs = 0\n let rafId = 0\n\n function tick(ts: number) {\n const progress = Math.max(\n Math.min(((ts - startTs) * 100) / duration, 100),\n 0,\n )\n\n onUpdate(progress)\n }\n\n function updateRafId(id: number) {\n rafId = id\n }\n\n function step(ts: number) {\n if (!startTs) {\n startTs = Number(ts)\n }\n // make sure progress can reach 100%\n if (ts - startTs <= duration + 100) {\n tick(ts)\n updateRafId(requestAnimationFrame(step))\n } else {\n onFinished?.()\n }\n }\n\n updateRafId(requestAnimationFrame(step))\n\n function cancel() {\n cancelAnimationFrame(rafId)\n }\n\n return {\n cancel,\n }\n}\n"],"names":["animate","duration","onUpdate","onFinished","startTs","rafId","tick","ts","progress","Math","updateRafId","id","step","Number","requestAnimationFrame","cancel","cancelAnimationFrame"],"mappings":"AAIO,SAASA,QACdC,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;IAEvB;IACA,IAAIC,UAAU;IACd,IAAIC,QAAQ;IAEZ,SAASC,KAAKC,EAAU;QACtB,MAAMC,WAAWC,KAAK,GAAG,CACvBA,KAAK,GAAG,CAAGF,AAAAA,CAAAA,KAAKH,OAAM,IAAK,MAAOH,UAAU,MAC5C;QAGFC,SAASM;IACX;IAEA,SAASE,YAAYC,EAAU;QAC7BN,QAAQM;IACV;IAEA,SAASC,KAAKL,EAAU;QACtB,IAAI,CAACH,SACHA,UAAUS,OAAON;QAGnB,IAAIA,KAAKH,WAAWH,WAAW,KAAK;YAClCK,KAAKC;YACLG,YAAYI,sBAAsBF;QACpC,OACET;IAEJ;IAEAO,YAAYI,sBAAsBF;IAElC,SAASG;QACPC,qBAAqBX;IACvB;IAEA,OAAO;QACLU;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils/compareProps.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/utils/compareProps.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\ntype DeepObject = Record<string, unknown>\n\nexport function comparePropsWithObject(\n prev: unknown,\n next: unknown,\n objectKeys?: string[],\n): boolean {\n if (prev === next) {\n return true\n }\n\n if (\n typeof prev !== 'object' || typeof next !== 'object' || prev === null\n || next === null\n ) {\n return false\n }\n\n const prevKeys = Object.keys(prev)\n const nextKeys = Object.keys(next)\n\n if (prevKeys.length !== nextKeys.length) {\n return false\n }\n\n for (const key of prevKeys) {\n if (objectKeys?.includes(key)) {\n if (\n !comparePropsWithObject(\n (prev as DeepObject)[key],\n (next as DeepObject)[key],\n [],\n )\n ) {\n return false\n }\n } else {\n if (\n !Object.is(\n (prev as DeepObject)[key],\n (next as DeepObject)[key],\n )\n ) {\n return false\n }\n }\n }\n\n return true\n}\n"],"names":["comparePropsWithObject","prev","next","objectKeys","prevKeys","Object","nextKeys","key"],"mappings":"AAMO,SAASA,uBACdC,IAAa,EACbC,IAAa,EACbC,UAAqB;IAErB,IAAIF,SAASC,MACX,OAAO;IAGT,IACE,AAAgB,YAAhB,OAAOD,QAAqB,AAAgB,YAAhB,OAAOC,QAAqBD,AAAS,SAATA,QACrDC,AAAS,SAATA,MAEH,OAAO;IAGT,MAAME,WAAWC,OAAO,IAAI,CAACJ;IAC7B,MAAMK,WAAWD,OAAO,IAAI,CAACH;IAE7B,IAAIE,SAAS,MAAM,KAAKE,SAAS,MAAM,EACrC,OAAO;IAGT,KAAK,MAAMC,OAAOH,SAChB,IAAID,YAAY,SAASI,MACvB;QAAA,IACE,CAACP,uBACEC,IAAmB,CAACM,IAAI,EACxBL,IAAmB,CAACK,IAAI,EACzB,EAAE,GAGJ,OAAO;IACT,OAEA,IACE,CAACF,OAAO,EAAE,CACPJ,IAAmB,CAACM,IAAI,EACxBL,IAAmB,CAACK,IAAI,GAG3B,OAAO;IAKb,OAAO;AACT"}
1
+ {"version":3,"file":"utils/compareProps.jsx","sources":["../../src/utils/compareProps.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\ntype DeepObject = Record<string, unknown>\n\nexport function comparePropsWithObject(\n prev: unknown,\n next: unknown,\n objectKeys?: string[],\n): boolean {\n if (prev === next) {\n return true\n }\n\n if (\n typeof prev !== 'object' || typeof next !== 'object' || prev === null\n || next === null\n ) {\n return false\n }\n\n const prevKeys = Object.keys(prev)\n const nextKeys = Object.keys(next)\n\n if (prevKeys.length !== nextKeys.length) {\n return false\n }\n\n for (const key of prevKeys) {\n if (objectKeys?.includes(key)) {\n if (\n !comparePropsWithObject(\n (prev as DeepObject)[key],\n (next as DeepObject)[key],\n [],\n )\n ) {\n return false\n }\n } else {\n if (\n !Object.is(\n (prev as DeepObject)[key],\n (next as DeepObject)[key],\n )\n ) {\n return false\n }\n }\n }\n\n return true\n}\n"],"names":["comparePropsWithObject","prev","next","objectKeys","prevKeys","Object","nextKeys","key"],"mappings":"AAMO,SAASA,uBACdC,IAAa,EACbC,IAAa,EACbC,UAAqB;IAErB,IAAIF,SAASC,MACX,OAAO;IAGT,IACE,AAAgB,YAAhB,OAAOD,QAAqB,AAAgB,YAAhB,OAAOC,QAAqBD,AAAS,SAATA,QACrDC,AAAS,SAATA,MAEH,OAAO;IAGT,MAAME,WAAWC,OAAO,IAAI,CAACJ;IAC7B,MAAMK,WAAWD,OAAO,IAAI,CAACH;IAE7B,IAAIE,SAAS,MAAM,KAAKE,SAAS,MAAM,EACrC,OAAO;IAGT,KAAK,MAAMC,OAAOH,SAChB,IAAID,YAAY,SAASI,MACvB;QAAA,IACE,CAACP,uBACEC,IAAmB,CAACM,IAAI,EACxBL,IAAmB,CAACK,IAAI,EACzB,EAAE,GAGJ,OAAO;IACT,OAEA,IACE,CAACF,OAAO,EAAE,CACPJ,IAAmB,CAACM,IAAI,EACxBL,IAAmB,CAACK,IAAI,GAG3B,OAAO;IAKb,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils/customRound.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/utils/customRound.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\n/**\n * Round with threshold other than 0.5\n * eg: customRound(1.8, 0.7) === 2\n * eg: customRound(1.6, 0.7) === 1\n * @param num\n * @param threshold\n * @returns number\n */\nexport function customRound(num: number, threshold = 0.5) {\n 'main thread'\n const decimal = num - Math.floor(num)\n\n // Check if the decimal part is greater than or equal to 0.9\n if (decimal >= threshold) {\n return Math.ceil(num)\n } else {\n return Math.floor(num)\n }\n}\n"],"names":["customRound","num","threshold","decimal","Math"],"mappings":"AAYO,SAASA,YAAYC,GAAW,EAAEC,YAAY,GAAG;IACtD;IACA,MAAMC,UAAUF,MAAMG,KAAK,KAAK,CAACH;IAGjC,IAAIE,WAAWD,WACb,OAAOE,KAAK,IAAI,CAACH;IAEjB,OAAOG,KAAK,KAAK,CAACH;AAEtB"}
1
+ {"version":3,"file":"utils/customRound.jsx","sources":["../../src/utils/customRound.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\n/**\n * Round with threshold other than 0.5\n * eg: customRound(1.8, 0.7) === 2\n * eg: customRound(1.6, 0.7) === 1\n * @param num\n * @param threshold\n * @returns number\n */\nexport function customRound(num: number, threshold = 0.5) {\n 'main thread'\n const decimal = num - Math.floor(num)\n\n // Check if the decimal part is greater than or equal to 0.9\n if (decimal >= threshold) {\n return Math.ceil(num)\n } else {\n return Math.floor(num)\n }\n}\n"],"names":["customRound","num","threshold","decimal","Math"],"mappings":"AAYO,SAASA,YAAYC,GAAW,EAAEC,YAAY,GAAG;IACtD;IACA,MAAMC,UAAUF,MAAMG,KAAK,KAAK,CAACH;IAGjC,IAAIE,WAAWD,WACb,OAAOE,KAAK,IAAI,CAACH;IAEjB,OAAOG,KAAK,KAAK,CAACH;AAEtB"}
@@ -12,9 +12,14 @@ declare function limiterMTS(offset: number, dataCount: number, size: number, loo
12
12
  offset: number;
13
13
  reachingLimit: boolean;
14
14
  };
15
+ declare function normalizeLoopOffset(offset: number, totalSize: number): number;
16
+ declare function normalizeLoopTransition(startOffset: number, finalOffset: number, totalSize: number): {
17
+ offset: number;
18
+ finalOffset: number;
19
+ };
15
20
  export declare function fixPrecisionMT(num: number): number;
16
21
  export declare function safeEqualMT(a: number, b: number, epsilon?: number): boolean;
17
22
  export declare function eqOrGtMT(a: number, b: number, epsilon?: number): boolean;
18
23
  export declare function eqOrLtMT(a: number, b: number, epsilon?: number): boolean;
19
- export { easeOut, limiter, limiterMTS, limiterForFirstScreen };
24
+ export { easeOut, limiter, limiterForFirstScreen, limiterMTS, normalizeLoopOffset, normalizeLoopTransition, };
20
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,iBAAS,OAAO,CAAC,QAAQ,EAAE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AE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,iBAAiB,GAC7B,MAAM,CAkBR;AAED;;;;;GAKG;AACH,iBAAS,qBAAqB,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,MAAM,UAapB;AAED,iBAAS,UAAU,CACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,iBAAiB;;;EAe/B;AAED,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,UAQ7D;AAED,iBAAS,uBAAuB,CAC9B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM;;;EAclB;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASlD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAU,WAGlE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAU,WAG/D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAU,WAG/D;AAED,OAAO,EACL,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,UAAU,EACV,mBAAmB,EACnB,uBAAuB,GACxB,CAAA"}
@@ -31,6 +31,25 @@ function limiterMTS(offset, dataCount, size, loop, offsetLimit) {
31
31
  reachingLimit
32
32
  };
33
33
  }
34
+ function normalizeLoopOffset(offset, totalSize) {
35
+ 'main thread';
36
+ if (totalSize <= 0) return 0;
37
+ const normalizedOffset = -((-offset % totalSize + totalSize) % totalSize);
38
+ return 0 === normalizedOffset ? 0 : normalizedOffset;
39
+ }
40
+ function normalizeLoopTransition(startOffset, finalOffset, totalSize) {
41
+ 'main thread';
42
+ if (totalSize <= 0) return {
43
+ offset: 0,
44
+ finalOffset: 0
45
+ };
46
+ const normalizedFinalOffset = normalizeLoopOffset(finalOffset, totalSize);
47
+ const normalizationDelta = normalizedFinalOffset - finalOffset;
48
+ return {
49
+ offset: startOffset + normalizationDelta,
50
+ finalOffset: normalizedFinalOffset
51
+ };
52
+ }
34
53
  const EPSILON = 1e-10;
35
54
  function fixPrecisionMT(num) {
36
55
  'main thread';
@@ -50,6 +69,6 @@ function eqOrLtMT(a, b, epsilon = EPSILON) {
50
69
  'main thread';
51
70
  return Math.abs(a - b) < epsilon || a < b;
52
71
  }
53
- export { easeOut, eqOrGtMT, eqOrLtMT, fixPrecisionMT, limiter, limiterForFirstScreen, limiterMTS, safeEqualMT };
72
+ export { easeOut, eqOrGtMT, eqOrLtMT, fixPrecisionMT, limiter, limiterForFirstScreen, limiterMTS, normalizeLoopOffset, normalizeLoopTransition, safeEqualMT };
54
73
 
55
74
  //# sourceMappingURL=index.jsx.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/utils/index.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 { OffsetLimitResult } from '../types'\n\nfunction easeOut(progress: number) {\n 'main thread'\n return 1 - Math.pow(1 - progress, 3)\n}\n\nfunction limiter(\n offset: number,\n dataCount: number,\n size: number,\n spaceBetween: number,\n loop: boolean,\n offsetLimit: OffsetLimitResult,\n): number {\n if (dataCount === 0) {\n return 0\n }\n if (!loop) {\n if (offset >= -offsetLimit.startLimit) {\n return -offsetLimit.startLimit\n } else if (\n offset\n < -(size + spaceBetween) * (dataCount - 1) + spaceBetween\n + offsetLimit.endLimit\n ) {\n return -(size + spaceBetween) * (dataCount - 1) + spaceBetween\n + offsetLimit.startLimit\n }\n }\n\n return offset\n}\n\n/**\n * limiter is used for useOffset\n * When mode === 'normal', different aligns are applied an alignOffset based on realOffset returned by useOffset\n * We first remove the offset, and use limiter to get the realOffset from useOffset\n * And then applied alignOffset back, to make the position right.\n */\nfunction limiterForFirstScreen(\n offset: number,\n dataCount: number,\n size: number,\n spaceBetween: number,\n loop: boolean,\n offsetLimit: OffsetLimitResult,\n alignOffset: number,\n) {\n return (\n alignOffset\n + limiter(\n offset - alignOffset,\n dataCount,\n size,\n spaceBetween,\n loop,\n offsetLimit,\n )\n )\n}\n\nfunction limiterMTS(\n offset: number,\n dataCount: number,\n size: number,\n loop: boolean,\n offsetLimit: OffsetLimitResult,\n) {\n 'main thread'\n let reachingLimit = false\n let finalOffset = offset\n if (!loop) {\n if (offset >= offsetLimit.startLimit) {\n reachingLimit = true\n finalOffset = offsetLimit.startLimit\n } else if (offset <= -size * (dataCount - 1) + offsetLimit.endLimit) {\n reachingLimit = true\n finalOffset = -size * (dataCount - 1) + offsetLimit.endLimit\n }\n }\n return { offset: finalOffset, reachingLimit }\n}\n\nconst EPSILON = 1e-10\n\nexport function fixPrecisionMT(num: number): number {\n 'main thread'\n // Use a small epsilon value to handle floating point precision\n const epsilon = 0.000001\n // Round to the nearest integer if the number is very close to an integer\n if (Math.abs(num - Math.round(num)) < epsilon) {\n return Math.round(num)\n }\n return num\n}\n\nexport function safeEqualMT(a: number, b: number, epsilon = EPSILON) {\n 'main thread'\n return Math.abs(a - b) < epsilon\n}\n\nexport function eqOrGtMT(a: number, b: number, epsilon = EPSILON) {\n 'main thread'\n return Math.abs(a - b) < epsilon || a > b\n}\n\nexport function eqOrLtMT(a: number, b: number, epsilon = EPSILON) {\n 'main thread'\n return Math.abs(a - b) < epsilon || a < b\n}\n\nexport { easeOut, limiter, limiterMTS, limiterForFirstScreen }\n"],"names":["easeOut","progress","Math","limiter","offset","dataCount","size","spaceBetween","loop","offsetLimit","limiterForFirstScreen","alignOffset","limiterMTS","reachingLimit","finalOffset","EPSILON","fixPrecisionMT","num","epsilon","safeEqualMT","a","b","eqOrGtMT","eqOrLtMT"],"mappings":"AAMA,SAASA,QAAQC,QAAgB;IAC/B;IACA,OAAO,IAAIC,KAAK,GAAG,CAAC,IAAID,UAAU;AACpC;AAEA,SAASE,QACPC,MAAc,EACdC,SAAiB,EACjBC,IAAY,EACZC,YAAoB,EACpBC,IAAa,EACbC,WAA8B;IAE9B,IAAIJ,AAAc,MAAdA,WACF,OAAO;IAET,IAAI,CAACG,MACH;QAAA,IAAIJ,UAAU,CAACK,YAAY,UAAU,EACnC,OAAO,CAACA,YAAY,UAAU;aACzB,IACLL,SACI,CAAEE,CAAAA,OAAOC,YAAW,IAAMF,CAAAA,YAAY,KAAKE,eACzCE,YAAY,QAAQ,EAE1B,OAAO,CAAEH,CAAAA,OAAOC,YAAW,IAAMF,CAAAA,YAAY,KAAKE,eAC9CE,YAAY,UAAU;IAC5B;IAGF,OAAOL;AACT;AAQA,SAASM,sBACPN,MAAc,EACdC,SAAiB,EACjBC,IAAY,EACZC,YAAoB,EACpBC,IAAa,EACbC,WAA8B,EAC9BE,WAAmB;IAEnB,OACEA,cACER,QACAC,SAASO,aACTN,WACAC,MACAC,cACAC,MACAC;AAGN;AAEA,SAASG,WACPR,MAAc,EACdC,SAAiB,EACjBC,IAAY,EACZE,IAAa,EACbC,WAA8B;IAE9B;IACA,IAAII,gBAAgB;IACpB,IAAIC,cAAcV;IAClB,IAAI,CAACI,MACH;QAAA,IAAIJ,UAAUK,YAAY,UAAU,EAAE;YACpCI,gBAAgB;YAChBC,cAAcL,YAAY,UAAU;QACtC,OAAO,IAAIL,UAAU,CAACE,OAAQD,CAAAA,YAAY,KAAKI,YAAY,QAAQ,EAAE;YACnEI,gBAAgB;YAChBC,cAAc,CAACR,OAAQD,CAAAA,YAAY,KAAKI,YAAY,QAAQ;QAC9D;IAAA;IAEF,OAAO;QAAE,QAAQK;QAAaD;IAAc;AAC9C;AAEA,MAAME,UAAU;AAET,SAASC,eAAeC,GAAW;IACxC;IAEA,MAAMC,UAAU;IAEhB,IAAIhB,KAAK,GAAG,CAACe,MAAMf,KAAK,KAAK,CAACe,QAAQC,SACpC,OAAOhB,KAAK,KAAK,CAACe;IAEpB,OAAOA;AACT;AAEO,SAASE,YAAYC,CAAS,EAAEC,CAAS,EAAEH,UAAUH,OAAO;IACjE;IACA,OAAOb,KAAK,GAAG,CAACkB,IAAIC,KAAKH;AAC3B;AAEO,SAASI,SAASF,CAAS,EAAEC,CAAS,EAAEH,UAAUH,OAAO;IAC9D;IACA,OAAOb,KAAK,GAAG,CAACkB,IAAIC,KAAKH,WAAWE,IAAIC;AAC1C;AAEO,SAASE,SAASH,CAAS,EAAEC,CAAS,EAAEH,UAAUH,OAAO;IAC9D;IACA,OAAOb,KAAK,GAAG,CAACkB,IAAIC,KAAKH,WAAWE,IAAIC;AAC1C"}
1
+ {"version":3,"file":"utils/index.jsx","sources":["../../src/utils/index.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 { OffsetLimitResult } from '../types'\n\nfunction easeOut(progress: number) {\n 'main thread'\n return 1 - Math.pow(1 - progress, 3)\n}\n\nfunction limiter(\n offset: number,\n dataCount: number,\n size: number,\n spaceBetween: number,\n loop: boolean,\n offsetLimit: OffsetLimitResult,\n): number {\n if (dataCount === 0) {\n return 0\n }\n if (!loop) {\n if (offset >= -offsetLimit.startLimit) {\n return -offsetLimit.startLimit\n } else if (\n offset\n < -(size + spaceBetween) * (dataCount - 1) + spaceBetween\n + offsetLimit.endLimit\n ) {\n return -(size + spaceBetween) * (dataCount - 1) + spaceBetween\n + offsetLimit.startLimit\n }\n }\n\n return offset\n}\n\n/**\n * limiter is used for useOffset\n * When mode === 'normal', different aligns are applied an alignOffset based on realOffset returned by useOffset\n * We first remove the offset, and use limiter to get the realOffset from useOffset\n * And then applied alignOffset back, to make the position right.\n */\nfunction limiterForFirstScreen(\n offset: number,\n dataCount: number,\n size: number,\n spaceBetween: number,\n loop: boolean,\n offsetLimit: OffsetLimitResult,\n alignOffset: number,\n) {\n return (\n alignOffset\n + limiter(\n offset - alignOffset,\n dataCount,\n size,\n spaceBetween,\n loop,\n offsetLimit,\n )\n )\n}\n\nfunction limiterMTS(\n offset: number,\n dataCount: number,\n size: number,\n loop: boolean,\n offsetLimit: OffsetLimitResult,\n) {\n 'main thread'\n let reachingLimit = false\n let finalOffset = offset\n if (!loop) {\n if (offset >= offsetLimit.startLimit) {\n reachingLimit = true\n finalOffset = offsetLimit.startLimit\n } else if (offset <= -size * (dataCount - 1) + offsetLimit.endLimit) {\n reachingLimit = true\n finalOffset = -size * (dataCount - 1) + offsetLimit.endLimit\n }\n }\n return { offset: finalOffset, reachingLimit }\n}\n\nfunction normalizeLoopOffset(offset: number, totalSize: number) {\n 'main thread'\n if (totalSize <= 0) {\n return 0\n }\n\n const normalizedOffset = -(((-offset % totalSize) + totalSize) % totalSize)\n return normalizedOffset === 0 ? 0 : normalizedOffset\n}\n\nfunction normalizeLoopTransition(\n startOffset: number,\n finalOffset: number,\n totalSize: number,\n) {\n 'main thread'\n if (totalSize <= 0) {\n return { offset: 0, finalOffset: 0 }\n }\n\n const normalizedFinalOffset = normalizeLoopOffset(finalOffset, totalSize)\n const normalizationDelta = normalizedFinalOffset - finalOffset\n\n return {\n offset: startOffset + normalizationDelta,\n finalOffset: normalizedFinalOffset,\n }\n}\n\nconst EPSILON = 1e-10\n\nexport function fixPrecisionMT(num: number): number {\n 'main thread'\n // Use a small epsilon value to handle floating point precision\n const epsilon = 0.000001\n // Round to the nearest integer if the number is very close to an integer\n if (Math.abs(num - Math.round(num)) < epsilon) {\n return Math.round(num)\n }\n return num\n}\n\nexport function safeEqualMT(a: number, b: number, epsilon = EPSILON) {\n 'main thread'\n return Math.abs(a - b) < epsilon\n}\n\nexport function eqOrGtMT(a: number, b: number, epsilon = EPSILON) {\n 'main thread'\n return Math.abs(a - b) < epsilon || a > b\n}\n\nexport function eqOrLtMT(a: number, b: number, epsilon = EPSILON) {\n 'main thread'\n return Math.abs(a - b) < epsilon || a < b\n}\n\nexport {\n easeOut,\n limiter,\n limiterForFirstScreen,\n limiterMTS,\n normalizeLoopOffset,\n normalizeLoopTransition,\n}\n"],"names":["easeOut","progress","Math","limiter","offset","dataCount","size","spaceBetween","loop","offsetLimit","limiterForFirstScreen","alignOffset","limiterMTS","reachingLimit","finalOffset","normalizeLoopOffset","totalSize","normalizedOffset","normalizeLoopTransition","startOffset","normalizedFinalOffset","normalizationDelta","EPSILON","fixPrecisionMT","num","epsilon","safeEqualMT","a","b","eqOrGtMT","eqOrLtMT"],"mappings":"AAMA,SAASA,QAAQC,QAAgB;IAC/B;IACA,OAAO,IAAIC,KAAK,GAAG,CAAC,IAAID,UAAU;AACpC;AAEA,SAASE,QACPC,MAAc,EACdC,SAAiB,EACjBC,IAAY,EACZC,YAAoB,EACpBC,IAAa,EACbC,WAA8B;IAE9B,IAAIJ,AAAc,MAAdA,WACF,OAAO;IAET,IAAI,CAACG,MACH;QAAA,IAAIJ,UAAU,CAACK,YAAY,UAAU,EACnC,OAAO,CAACA,YAAY,UAAU;aACzB,IACLL,SACI,CAAEE,CAAAA,OAAOC,YAAW,IAAMF,CAAAA,YAAY,KAAKE,eACzCE,YAAY,QAAQ,EAE1B,OAAO,CAAEH,CAAAA,OAAOC,YAAW,IAAMF,CAAAA,YAAY,KAAKE,eAC9CE,YAAY,UAAU;IAC5B;IAGF,OAAOL;AACT;AAQA,SAASM,sBACPN,MAAc,EACdC,SAAiB,EACjBC,IAAY,EACZC,YAAoB,EACpBC,IAAa,EACbC,WAA8B,EAC9BE,WAAmB;IAEnB,OACEA,cACER,QACAC,SAASO,aACTN,WACAC,MACAC,cACAC,MACAC;AAGN;AAEA,SAAS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EAAEH,UAAUH,OAAO;IAC9D;IACA,OAAOpB,KAAK,GAAG,CAACyB,IAAIC,KAAKH,WAAWE,IAAIC;AAC1C;AAEO,SAASE,SAASH,CAAS,EAAEC,CAAS,EAAEH,UAAUH,OAAO;IAC9D;IACA,OAAOpB,KAAK,GAAG,CAACyB,IAAIC,KAAKH,WAAWE,IAAIC;AAC1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-swiper",
3
- "version": "3.135.1",
3
+ "version": "3.135.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lynx-family/lynx-ui.git",
@@ -25,15 +25,15 @@
25
25
  "dist/**"
26
26
  ],
27
27
  "dependencies": {
28
- "@lynx-js/react-use": "0.1.3",
29
- "@lynx-js/lynx-ui-common": "3.133.1"
28
+ "@lynx-js/react-use": "0.2.2",
29
+ "@lynx-js/lynx-ui-common": "3.135.4"
30
30
  },
31
31
  "devDependencies": {
32
- "@lynx-js/react": "0.114.0",
33
- "@lynx-js/types": "3.6.0",
34
- "@rslib/core": "^0.16.0",
32
+ "@lynx-js/react": "0.123.1",
33
+ "@lynx-js/types": "4.1.0",
34
+ "@rslib/core": "0.23.2",
35
35
  "@types/react": "^18.3.8",
36
- "typescript": "^5.5.3"
36
+ "typescript": "^5.8.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@lynx-js/react": ">=0.100.0",
@@ -11,7 +11,7 @@ import {
11
11
  import { useTapLock } from '@lynx-js/react-use'
12
12
  import type { MainThread } from '@lynx-js/types'
13
13
 
14
- import { limiter } from '../utils'
14
+ import { limiter, normalizeLoopOffset, normalizeLoopTransition } from '../utils'
15
15
  import { useAnimate } from './useAnimate'
16
16
  import { useAutoplay } from './useAutoPlay'
17
17
  import { useAxisLock } from './useAxisLock'
@@ -239,27 +239,15 @@ function useOffset(
239
239
 
240
240
  function calcLoop(start: number, end: number) {
241
241
  'main thread'
242
- let startOffset = start
243
- let finalOffset = end
244
242
  if (dataCount === 0) {
245
243
  return { offset: 0, finalOffset: 0 }
246
244
  }
247
- const totalWidth = fullSize * dataCount
248
- if (loop) {
249
- if (finalOffset < -totalWidth + fullSize) {
250
- // If go beyond last item, like n + 1 item, let the destination be 1
251
- finalOffset = finalOffset + totalWidth
252
- startOffset = startOffset + totalWidth
253
- } else if (finalOffset > 0) {
254
- // If go before first item, like -1 item, let the destination be n - 1
255
- finalOffset = finalOffset - totalWidth
256
- startOffset = startOffset - totalWidth
257
- }
258
- }
259
- return {
260
- offset: startOffset,
261
- finalOffset,
245
+
246
+ if (!loop) {
247
+ return { offset: start, finalOffset: end }
262
248
  }
249
+
250
+ return normalizeLoopTransition(start, end, fullSize * dataCount)
263
251
  }
264
252
 
265
253
  const {
@@ -527,6 +515,9 @@ function useOffset(
527
515
  let offsetInner = sign * (event.detail.x - touchStartRef.current)
528
516
  + lastScrollOffsetRef.current
529
517
  offsetInner = calcBounceOffsetAndLimit(offsetInner)
518
+ if (loop) {
519
+ offsetInner = normalizeLoopOffset(offsetInner, fullSize * dataCount)
520
+ }
530
521
  setOffset(offsetInner)
531
522
  velocityTouchMove(event)
532
523
  swipeCallbackTouchMove(event)
@@ -86,6 +86,35 @@ function limiterMTS(
86
86
  return { offset: finalOffset, reachingLimit }
87
87
  }
88
88
 
89
+ function normalizeLoopOffset(offset: number, totalSize: number) {
90
+ 'main thread'
91
+ if (totalSize <= 0) {
92
+ return 0
93
+ }
94
+
95
+ const normalizedOffset = -(((-offset % totalSize) + totalSize) % totalSize)
96
+ return normalizedOffset === 0 ? 0 : normalizedOffset
97
+ }
98
+
99
+ function normalizeLoopTransition(
100
+ startOffset: number,
101
+ finalOffset: number,
102
+ totalSize: number,
103
+ ) {
104
+ 'main thread'
105
+ if (totalSize <= 0) {
106
+ return { offset: 0, finalOffset: 0 }
107
+ }
108
+
109
+ const normalizedFinalOffset = normalizeLoopOffset(finalOffset, totalSize)
110
+ const normalizationDelta = normalizedFinalOffset - finalOffset
111
+
112
+ return {
113
+ offset: startOffset + normalizationDelta,
114
+ finalOffset: normalizedFinalOffset,
115
+ }
116
+ }
117
+
89
118
  const EPSILON = 1e-10
90
119
 
91
120
  export function fixPrecisionMT(num: number): number {
@@ -114,4 +143,11 @@ export function eqOrLtMT(a: number, b: number, epsilon = EPSILON) {
114
143
  return Math.abs(a - b) < epsilon || a < b
115
144
  }
116
145
 
117
- export { easeOut, limiter, limiterMTS, limiterForFirstScreen }
146
+ export {
147
+ easeOut,
148
+ limiter,
149
+ limiterForFirstScreen,
150
+ limiterMTS,
151
+ normalizeLoopOffset,
152
+ normalizeLoopTransition,
153
+ }