@lynx-js/lynx-ui-swiper 3.137.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 +9 -0
- 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/types/index.docs.d.ts +4 -0
- package/dist/types/index.docs.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Swiper/index.tsx +10 -7
- package/src/types/index.docs.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
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
|
+
|
|
3
12
|
## 3.137.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -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","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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AASE;QACP;QACA1B;IACF;IAEA,SAAS2B;QACP;QACA1B;IACF;IAIA,MAAM,EAAE2B,cAAc,EAAE,GAAGC,oBAAoB;QAC7CxF;QACAC;QACAG;QACAM;QACAwB;QACAM;QACA/B;QACAkC;QACAR;QACAH;QACAS;QACAlB;QACAE;IACF;IAEA,MAAM,EACJgE,eAAe,EACfC,gBAAgB,EAChBC,cAAc,EACdC,SAAS,EACTC,SAAS,EACTC,OAAO,EACPC,aAAa,EACbC,iBAAiB,EACjBC,eAAe,EAChB,GAAGC,UACF;QACE5F;QACAC;QACAH;QACA,MAAMJ;QACNyC;QACAP;QACA1B;QACAU;QACAyB;QACAjC;QACA8B;QACAvC;QACA4C;QACAG;QACAC;QACAC;QACAC;QACAtB;QACAwD;QACAC;QACAxD;QACAE;IACF,GACAkD;IAGF,MAAM,EAAEiB,eAAe,EAAE,GAAGC,SAAS;QACnC7E;QACAd;QACAT;QACAC;QACAG;QACA8B;QACAM;QACAuD;QACAvE;QACAd;QACAyB;QACA8B;QACAgC;QACAxD;IACF;IAEA,MAAM4D,gBAAgBC,kBAAkB;QACtC,iBAAiBX;QACjB,cAAcA;QACd,eAAeF;QACf,gBAAgBC;IAClB;IAEAa,oBAAoBtE,KAAK,IAAO;YAC9B2D;YACAC;YACAC;YACA,iBAAiBE;QACnB;IAEA,SAASQ,iBAAiBC,KAIzB;QACC,QACGC,kBAAkB,SACjB,KAAKD,MAAM,SAAS,EACpB,OAAO;YACL,OAAOA,MAAM,KAAK;YAClB,WAAWA,MAAM,SAAS;QAC5B,GACD;UACC,CAACxF,SAASwF,OAAO;QACnB,EAAEC,kBAAkB;IAExB;IAEA,MAAM,EAAEC,eAAe,EAAEC,aAAa,EAAE,GAAGC,cAAc;QACvD/D;QACAC;QACA3C;QACA,MAAMoC,WAAW,IAAI;QACrBxC;QACA,OAAOkC;QACPF;QACA/B;IACF;IAEA,QACG6G,cAAc,SAAS,OAAOtD,cAAc;QAC3C,CAACuD,KACC,MAAM,uBACN,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../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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pC,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,EAAEI,KAAK;QACT,EAAEA,KAAK;MACT,EAAED,cAAc;AAEpB;AAGF,MAAMM,iBAAiBC,KACrBzH,QACA,CAAC0H,WAAWC,YACVC,uBAAuBF,WAAWC,WAAW;QAAC;QAAc;KAAU"}
|
|
@@ -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
|
/**
|
|
@@ -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,IAAI,CAAC,EAA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BAAuB,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/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/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
|
/**
|
|
@@ -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
|
/**
|