@lynx-js/lynx-ui-swiper 3.136.0 → 3.139.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/Swiper/index.d.ts +1 -1
- package/dist/Swiper/index.d.ts.map +1 -1
- package/dist/Swiper/index.jsx +5 -3
- package/dist/Swiper/index.jsx.map +1 -1
- package/dist/SwiperItem/index.d.ts +1 -1
- package/dist/SwiperItem/index.jsx.map +1 -1
- package/dist/hooks/useAxisLock.d.ts +1 -1
- package/dist/hooks/useBounceConfig.d.ts +3 -3
- package/dist/hooks/useBounceView.d.ts +1 -1
- package/dist/hooks/useChange.d.ts +2 -2
- package/dist/hooks/useDirection.d.ts +2 -2
- package/dist/hooks/useFirstScreenStyle.d.ts +1 -1
- package/dist/hooks/useModeConfig.d.ts +1 -1
- package/dist/hooks/useOffset.d.ts +2 -2
- package/dist/hooks/useOffsetLimit.d.ts +1 -1
- package/dist/hooks/useReset.d.ts +1 -1
- package/dist/hooks/useVelocity.d.ts +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/store/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.docs.d.ts +5 -1
- package/dist/types/index.docs.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/Swiper/index.tsx +10 -7
- package/src/SwiperItem/index.tsx +1 -1
- package/src/types/index.docs.ts +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-swiper
|
|
2
2
|
|
|
3
|
+
## 3.139.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Default the Swiper root view's `z-index` to `0` so z-indexed items remain in the wrapper event chain and directional gesture consumption works in custom mode. ([#310](https://github.com/lynx-family/lynx-ui/pull/310))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`1a4ad19`](https://github.com/lynx-family/lynx-ui/commit/1a4ad190993d57425b4c377a7dd63882cc65a8d2)]:
|
|
10
|
+
- @lynx-js/lynx-ui-common@3.139.0
|
|
11
|
+
|
|
12
|
+
## 3.137.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Emit declaration imports with explicit ESM-compatible paths. ([#280](https://github.com/lynx-family/lynx-ui/pull/280))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`064ea4e`](https://github.com/lynx-family/lynx-ui/commit/064ea4e49cd3d0ac5754519cbee43d8ab3040024)]:
|
|
19
|
+
- @lynx-js/lynx-ui-common@3.137.0
|
|
20
|
+
|
|
3
21
|
## 3.136.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/Swiper/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Swiper/index.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,WAAW,EACX,SAAS,EAEV,MAAM,UAAU,CAAA;AAIjB,OAAO,cAAc,CAAA;AAErB;;GAEG;AACH,QAAA,MAAM,MAAM,GACT,CAAC;sCAqCwD,OAAO;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Swiper/index.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAEV,WAAW,EACX,SAAS,EAEV,MAAM,UAAU,CAAA;AAIjB,OAAO,cAAc,CAAA;AAErB;;GAEG;AACH,QAAA,MAAM,MAAM,GACT,CAAC;sCAqCwD,OAAO;2EA0VlE,CAAA;AAED,QAAA,MAAM,cAAc,EAIf,OAAO,MAAM,CAAA;AAElB,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,CAAA"}
|
package/dist/Swiper/index.jsx
CHANGED
|
@@ -223,13 +223,15 @@ const Swiper = forwardRef(({ data = [], itemWidth, containerWidth = lynx.__globa
|
|
|
223
223
|
RTL,
|
|
224
224
|
containerWidth
|
|
225
225
|
});
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
const rootStyle = {
|
|
227
|
+
zIndex: 0,
|
|
228
228
|
...style,
|
|
229
229
|
width: `${containerWidth}px`,
|
|
230
230
|
height: `${itemHeight}px`,
|
|
231
231
|
direction: 'lynx-rtl' === RTL ? 'lynx-rtl' : RTL ? 'rtl' : 'ltr'
|
|
232
|
-
}
|
|
232
|
+
};
|
|
233
|
+
return <SwiperContext.Provider value={contextValue}>
|
|
234
|
+
<view class='lynx-ui-swiper__root' style={rootStyle} {...touchHandlers} consume-slide-event={consumeSlideEvent} block-native-event={blockNativeEvent}>
|
|
233
235
|
<view class='lynx-ui-swiper__track' style={containerStyle} ref={setContainerRef} main-thread:ref={containerRef} implicit-animation='false'>
|
|
234
236
|
{bounceStartView}
|
|
235
237
|
{loop ? <>
|
|
@@ -1 +1 @@
|
|
|
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='lynx-ui-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='lynx-ui-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","Memoized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;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 { CSSProperties, 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 const rootStyle: CSSProperties = {\n zIndex: 0,\n ...style,\n width: `${containerWidth}px`,\n height: `${itemHeight}px`,\n direction: RTL === 'lynx-rtl' ? 'lynx-rtl' : (RTL ? 'rtl' : 'ltr'),\n }\n\n return (\n <SwiperContext.Provider value={contextValue}>\n <view\n class='lynx-ui-swiper__root'\n style={rootStyle}\n {...touchHandlers}\n consume-slide-event={consumeSlideEvent}\n block-native-event={blockNativeEvent}\n >\n <view\n class='lynx-ui-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","rootStyle","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;IAE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c;KAAU"}
|
|
@@ -34,7 +34,7 @@ export interface SwiperItemProps {
|
|
|
34
34
|
/**
|
|
35
35
|
* `overlap` attribute passed to SwiperItem's direct child.
|
|
36
36
|
* This property is used only when opacity has issues.
|
|
37
|
-
* Refer to {@link https://lynxjs.org/
|
|
37
|
+
* Refer to {@link https://lynxjs.org/api/css/properties/opacity#opacity}
|
|
38
38
|
* @Android
|
|
39
39
|
* @iOS
|
|
40
40
|
* @Harmony
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwiperItem/index.jsx","sources":["../../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/
|
|
1
|
+
{"version":3,"file":"SwiperItem/index.jsx","sources":["../../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/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='lynx-ui-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,EAA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H;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,uBACN,OAAO3B,gBACP,YAAY,KAAKyB,QACjB,SAASd,SACV;MACC,CAACD,SAAS;IACZ,EAAEiB;AAEN;AAEA,MAAMC,iBAAiBC,KAAKrB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MainThread } from '@lynx-js/types';
|
|
2
|
-
import type { SwiperProps } from '../types';
|
|
2
|
+
import type { SwiperProps } from '../types/index.js';
|
|
3
3
|
export declare function useAxisLock({ consumeSlideEvent, experimentalHorizontalSwipeOnly, }: {
|
|
4
4
|
consumeSlideEvent: NonNullable<SwiperProps<unknown>['consumeSlideEvent']>;
|
|
5
5
|
experimentalHorizontalSwipeOnly: boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { BounceConfig } from '../types';
|
|
1
|
+
import type { BounceConfig } from '../types/index.js';
|
|
2
2
|
declare function useBounceConfig(bounceConfig?: BounceConfig): {
|
|
3
3
|
enableBounce: boolean;
|
|
4
4
|
startBounceItem: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
5
5
|
endBounceItem: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | undefined;
|
|
6
6
|
startBounceItemWidth: number;
|
|
7
7
|
endBounceItemWidth: number;
|
|
8
|
-
onStartBounceItemBounce: ((bounceParams: import("../types").onBounceParams) => void) | undefined;
|
|
9
|
-
onEndBounceItemBounce: ((bounceParams: import("../types").onBounceParams) => void) | undefined;
|
|
8
|
+
onStartBounceItemBounce: ((bounceParams: import("../types/index.js").onBounceParams) => void) | undefined;
|
|
9
|
+
onEndBounceItemBounce: ((bounceParams: import("../types/index.js").onBounceParams) => void) | undefined;
|
|
10
10
|
};
|
|
11
11
|
export { useBounceConfig };
|
|
12
12
|
//# sourceMappingURL=useBounceConfig.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement } from '@lynx-js/react';
|
|
2
|
-
import type { CompoundModeConfig, SwiperProps } from '../types';
|
|
2
|
+
import type { CompoundModeConfig, SwiperProps } from '../types/index.js';
|
|
3
3
|
declare function useBounceView({ startBounceItem, endBounceItem, RTL, itemWidth, count, containerWidth, mode, loop, }: {
|
|
4
4
|
startBounceItem?: ReactElement;
|
|
5
5
|
endBounceItem?: ReactElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SwipeDirection } from '../types';
|
|
2
|
-
import type { CompoundModeConfig, OffsetLimitResult, SwiperProps } from '../types';
|
|
1
|
+
import { SwipeDirection } from '../types/index.js';
|
|
2
|
+
import type { CompoundModeConfig, OffsetLimitResult, SwiperProps } from '../types/index.js';
|
|
3
3
|
interface UseChangeOpts extends Pick<SwiperProps<unknown>, 'containerWidth' | 'onSwipeStart' | 'onSwipeStop'> {
|
|
4
4
|
onChange?: (offset: number) => void;
|
|
5
5
|
size: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MainThread } from '@lynx-js/types';
|
|
2
|
-
import { SwipeDirection } from '../types';
|
|
3
|
-
import type { SwiperProps } from '../types';
|
|
2
|
+
import { SwipeDirection } from '../types/index.js';
|
|
3
|
+
import type { SwiperProps } from '../types/index.js';
|
|
4
4
|
export declare function useDirection({ RTL }: {
|
|
5
5
|
RTL: SwiperProps<unknown>['RTL'];
|
|
6
6
|
}): {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties } from '@lynx-js/types';
|
|
2
|
-
import type { CompoundModeConfig, OffsetLimitResult, SwiperProps } from '../types';
|
|
2
|
+
import type { CompoundModeConfig, OffsetLimitResult, SwiperProps } from '../types/index.js';
|
|
3
3
|
interface LayoutSwiperPropsType extends Pick<SwiperProps<unknown>, 'itemWidth' | 'initialIndex' | 'itemHeight' | 'trackStyle'>, Required<Pick<SwiperProps<unknown>, 'containerWidth' | 'loop' | 'loopDuplicateCount' | 'RTL' | 'swiperKey'>> {
|
|
4
4
|
spaceBetween: number;
|
|
5
5
|
dataCount: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MainThread } from '@lynx-js/types';
|
|
2
|
-
import { SwipeDirection } from '../types';
|
|
3
|
-
import type { BounceConfig, CompoundModeConfig, OffsetLimitResult, ResetOptions, SwipeToOptions, SwiperProps } from '../types';
|
|
2
|
+
import { SwipeDirection } from '../types/index.js';
|
|
3
|
+
import type { BounceConfig, CompoundModeConfig, OffsetLimitResult, ResetOptions, SwipeToOptions, SwiperProps } from '../types/index.js';
|
|
4
4
|
interface UseOffsetOpts extends Required<Pick<SwiperProps<unknown>, 'loop' | 'duration' | 'initialIndex' | 'containerWidth' | 'autoPlay' | 'autoPlayInterval' | 'consumeSlideEvent' | 'RTL'>> {
|
|
5
5
|
dataCount: number;
|
|
6
6
|
size: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompoundModeConfig, OffsetLimitResult, SwiperProps } from '../types';
|
|
1
|
+
import type { CompoundModeConfig, OffsetLimitResult, SwiperProps } from '../types/index.js';
|
|
2
2
|
interface IOffsetLimit extends Required<Pick<SwiperProps<unknown>, 'loop' | 'itemWidth' | 'containerWidth'>> {
|
|
3
3
|
offsetLimit: SwiperProps<unknown>['offsetLimit'];
|
|
4
4
|
modeConfig: CompoundModeConfig;
|
package/dist/hooks/useReset.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodesRef } from '@lynx-js/types';
|
|
2
|
-
import type { CompoundModeConfig, ResetOptions, SwiperProps, UpdateSwiperInnerContainerOptions } from '../types';
|
|
2
|
+
import type { CompoundModeConfig, ResetOptions, SwiperProps, UpdateSwiperInnerContainerOptions } from '../types/index.js';
|
|
3
3
|
interface UseResetOpts extends Required<Pick<SwiperProps<unknown>, 'swiperKey' | 'loop' | 'itemWidth' | 'itemHeight' | 'containerWidth' | 'initialIndex' | 'loopDuplicateCount'>> {
|
|
4
4
|
resetOnReuse: SwiperProps<unknown>['resetOnReuse'];
|
|
5
5
|
dataCount: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MainThread } from '@lynx-js/types';
|
|
2
|
-
import { SwipeDirection } from '../types';
|
|
3
|
-
import type { SwiperProps } from '../types';
|
|
2
|
+
import { SwipeDirection } from '../types/index.js';
|
|
3
|
+
import type { SwiperProps } from '../types/index.js';
|
|
4
4
|
export declare function useVelocity({ RTL }: {
|
|
5
5
|
RTL: SwiperProps<unknown>['RTL'];
|
|
6
6
|
}): {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { Swiper } from './Swiper';
|
|
2
|
-
export { SwiperItem } from './SwiperItem';
|
|
3
|
-
export type { SwiperItemProps } from './SwiperItem';
|
|
4
|
-
export type { SwiperProps, SwiperRef } from './types';
|
|
1
|
+
export { Swiper } from './Swiper/index.js';
|
|
2
|
+
export { SwiperItem } from './SwiperItem/index.js';
|
|
3
|
+
export type { SwiperItemProps } from './SwiperItem/index.js';
|
|
4
|
+
export type { SwiperProps, SwiperRef } from './types/index.js';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/store/index.d.ts
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties, MainThread } from '@lynx-js/types';
|
|
2
|
-
import type { BounceConfig, SwipeToOptions, SwiperPropsReal as SwiperProps, SwiperRef, onBounceParams } from './index.docs';
|
|
2
|
+
import type { BounceConfig, SwipeToOptions, SwiperPropsReal as SwiperProps, SwiperRef, onBounceParams } from './index.docs.js';
|
|
3
3
|
export interface SwiperContextProps extends Pick<SwiperProps<unknown>, 'itemWidth' | 'itemHeight' | 'customAnimationFirstScreen' | 'RTL'>, Required<Pick<SwiperProps<unknown>, 'initialIndex' | 'loop'>> {
|
|
4
4
|
setChildrenRef: (ref: MainThread.Element, index: number) => void;
|
|
5
5
|
spaceBetween: number;
|
|
@@ -45,6 +45,7 @@ export interface SwiperProps<T> {
|
|
|
45
45
|
* )}
|
|
46
46
|
* </Swiper>
|
|
47
47
|
* ```
|
|
48
|
+
* @docTypeFallback (prop: {index: number, item: T, realIndex: number}) => ReactElement
|
|
48
49
|
*/
|
|
49
50
|
children: (prop: RenderFunctionProps<T>) => ReactElement;
|
|
50
51
|
/**
|
|
@@ -235,7 +236,7 @@ export interface SwiperProps<T> {
|
|
|
235
236
|
/**
|
|
236
237
|
* Determines how swiper respond to touch in different angle.
|
|
237
238
|
* By default, swiper will only respond to horizontal touches.
|
|
238
|
-
* Refer to https://lynxjs.org/
|
|
239
|
+
* Refer to https://lynxjs.org/api/elements/built-in/view.html#consume-slide-event for more
|
|
239
240
|
* @defaultValue [[-180, -135], [-45, 45], [135, 180]]
|
|
240
241
|
* @Android
|
|
241
242
|
* @iOS
|
|
@@ -369,6 +370,7 @@ export interface BounceConfig {
|
|
|
369
370
|
* @iOS
|
|
370
371
|
* @Harmony
|
|
371
372
|
* @zh 当startBounceItem处于回弹状态时,释放手指将调用此函数。
|
|
373
|
+
* @docTypeFallback (bounceParams: {offset: number, type: 'start' | 'end'}) => void
|
|
372
374
|
*/
|
|
373
375
|
onStartBounceItemBounce?: (bounceParams: onBounceParams) => void;
|
|
374
376
|
/** ····· ··
|
|
@@ -377,6 +379,7 @@ export interface BounceConfig {
|
|
|
377
379
|
* @iOS
|
|
378
380
|
* @Harmony
|
|
379
381
|
* @zh 当endBounceItem处于回弹状态时,释放手指将调用此函数。
|
|
382
|
+
* @docTypeFallback (bounceParams: {offset: number, type: 'start' | 'end'}) => void
|
|
380
383
|
*/
|
|
381
384
|
onEndBounceItemBounce?: (bounceParams: onBounceParams) => void;
|
|
382
385
|
/**
|
|
@@ -407,6 +410,7 @@ export interface SwiperRef {
|
|
|
407
410
|
* @iOS
|
|
408
411
|
* @Harmony
|
|
409
412
|
* @zh 滑动到指定索引的项目
|
|
413
|
+
* @docTypeFallback (index: number, options?: {animate?: boolean, onFinished?: () => void}) => void
|
|
410
414
|
*/
|
|
411
415
|
swipeTo: (index: number, options?: SwipeToOptions) => void;
|
|
412
416
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B;;;;;;OAMG;IACH,IAAI,EAAE,CAAC,EAAE,CAAA;IACT;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B
|
|
1
|
+
{"version":3,"file":"index.docs.d.ts","sourceRoot":"","sources":["../../src/types/index.docs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B;;;;;;OAMG;IACH,IAAI,EAAE,CAAC,EAAE,CAAA;IACT;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,KAAK,YAAY,CAAA;IACxD;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;;;OAOG;IACH,IAA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OAOG;IACH,uBAAuB,CAAC,EAAE,CAAC,YAAY,EAAE,cAAc,KAAK,IAAI,CAAA;IAChE;;;;;;;OAOG;IACH,qBAAqB,CAAC,EAAE,CAAC,YAAY,EAAE,cAAc,KAAK,IAAI,CAAA;IAC9D;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB;;;;;;;OAOG;IACH,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;IAC1D;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB;;;;;;;;OAQG;IACH,eAAe,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,GAAG,KAAK,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC;;;OAGG;IACH,IAAI,EAAE,CAAC,CAAA;IACP;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;;;;;OAMG;IACH,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OffsetLimitResult } from '../types';
|
|
1
|
+
import type { OffsetLimitResult } from '../types/index.js';
|
|
2
2
|
declare function easeOut(progress: number): number;
|
|
3
3
|
declare function limiter(offset: number, dataCount: number, size: number, spaceBetween: number, loop: boolean, offsetLimit: OffsetLimitResult): number;
|
|
4
4
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-swiper",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.139.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@lynx-js/react-use": "0.2.2",
|
|
29
|
-
"@lynx-js/lynx-ui-common": "3.
|
|
29
|
+
"@lynx-js/lynx-ui-common": "3.139.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@lynx-js/react": "0.123.1",
|
package/src/Swiper/index.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import type { ForwardedRef } from '@lynx-js/react'
|
|
13
13
|
|
|
14
14
|
import { useTouchEmulation } from '@lynx-js/react-use'
|
|
15
|
-
import type { MainThread } from '@lynx-js/types'
|
|
15
|
+
import type { CSSProperties, MainThread } from '@lynx-js/types'
|
|
16
16
|
|
|
17
17
|
import { LOOP_COUNT } from '../const'
|
|
18
18
|
import { useBounceConfig } from '../hooks/useBounceConfig'
|
|
@@ -355,16 +355,19 @@ const Swiper = forwardRef(
|
|
|
355
355
|
containerWidth,
|
|
356
356
|
})
|
|
357
357
|
|
|
358
|
+
const rootStyle: CSSProperties = {
|
|
359
|
+
zIndex: 0,
|
|
360
|
+
...style,
|
|
361
|
+
width: `${containerWidth}px`,
|
|
362
|
+
height: `${itemHeight}px`,
|
|
363
|
+
direction: RTL === 'lynx-rtl' ? 'lynx-rtl' : (RTL ? 'rtl' : 'ltr'),
|
|
364
|
+
}
|
|
365
|
+
|
|
358
366
|
return (
|
|
359
367
|
<SwiperContext.Provider value={contextValue}>
|
|
360
368
|
<view
|
|
361
369
|
class='lynx-ui-swiper__root'
|
|
362
|
-
style={
|
|
363
|
-
...style,
|
|
364
|
-
width: `${containerWidth}px`,
|
|
365
|
-
height: `${itemHeight}px`,
|
|
366
|
-
direction: RTL === 'lynx-rtl' ? 'lynx-rtl' : (RTL ? 'rtl' : 'ltr'),
|
|
367
|
-
}}
|
|
370
|
+
style={rootStyle}
|
|
368
371
|
{...touchHandlers}
|
|
369
372
|
consume-slide-event={consumeSlideEvent}
|
|
370
373
|
block-native-event={blockNativeEvent}
|
package/src/SwiperItem/index.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export interface SwiperItemProps {
|
|
|
51
51
|
/**
|
|
52
52
|
* `overlap` attribute passed to SwiperItem's direct child.
|
|
53
53
|
* This property is used only when opacity has issues.
|
|
54
|
-
* Refer to {@link https://lynxjs.org/
|
|
54
|
+
* Refer to {@link https://lynxjs.org/api/css/properties/opacity#opacity}
|
|
55
55
|
* @Android
|
|
56
56
|
* @iOS
|
|
57
57
|
* @Harmony
|
package/src/types/index.docs.ts
CHANGED
|
@@ -51,6 +51,7 @@ export interface SwiperProps<T> {
|
|
|
51
51
|
* )}
|
|
52
52
|
* </Swiper>
|
|
53
53
|
* ```
|
|
54
|
+
* @docTypeFallback (prop: {index: number, item: T, realIndex: number}) => ReactElement
|
|
54
55
|
*/
|
|
55
56
|
children: (prop: RenderFunctionProps<T>) => ReactElement
|
|
56
57
|
/**
|
|
@@ -245,7 +246,7 @@ export interface SwiperProps<T> {
|
|
|
245
246
|
/**
|
|
246
247
|
* Determines how swiper respond to touch in different angle.
|
|
247
248
|
* By default, swiper will only respond to horizontal touches.
|
|
248
|
-
* Refer to https://lynxjs.org/
|
|
249
|
+
* Refer to https://lynxjs.org/api/elements/built-in/view.html#consume-slide-event for more
|
|
249
250
|
* @defaultValue [[-180, -135], [-45, 45], [135, 180]]
|
|
250
251
|
* @Android
|
|
251
252
|
* @iOS
|
|
@@ -384,6 +385,7 @@ export interface BounceConfig {
|
|
|
384
385
|
* @iOS
|
|
385
386
|
* @Harmony
|
|
386
387
|
* @zh 当startBounceItem处于回弹状态时,释放手指将调用此函数。
|
|
388
|
+
* @docTypeFallback (bounceParams: {offset: number, type: 'start' | 'end'}) => void
|
|
387
389
|
*/
|
|
388
390
|
onStartBounceItemBounce?: (bounceParams: onBounceParams) => void
|
|
389
391
|
/** ····· ··
|
|
@@ -392,6 +394,7 @@ export interface BounceConfig {
|
|
|
392
394
|
* @iOS
|
|
393
395
|
* @Harmony
|
|
394
396
|
* @zh 当endBounceItem处于回弹状态时,释放手指将调用此函数。
|
|
397
|
+
* @docTypeFallback (bounceParams: {offset: number, type: 'start' | 'end'}) => void
|
|
395
398
|
*/
|
|
396
399
|
onEndBounceItemBounce?: (bounceParams: onBounceParams) => void
|
|
397
400
|
/**
|
|
@@ -423,6 +426,7 @@ export interface SwiperRef {
|
|
|
423
426
|
* @iOS
|
|
424
427
|
* @Harmony
|
|
425
428
|
* @zh 滑动到指定索引的项目
|
|
429
|
+
* @docTypeFallback (index: number, options?: {animate?: boolean, onFinished?: () => void}) => void
|
|
426
430
|
*/
|
|
427
431
|
swipeTo: (index: number, options?: SwipeToOptions) => void
|
|
428
432
|
/**
|