@lynx-js/lynx-ui-swiper 3.133.0 → 3.133.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/hooks/useAutoPlay.jsx.map +1 -1
- package/dist/hooks/useModeConfig.d.ts.map +1 -1
- package/dist/hooks/useModeConfig.jsx.map +1 -1
- package/dist/utils/compareProps.jsx.map +1 -1
- package/package.json +2 -2
- package/src/hooks/useAutoPlay.ts +1 -1
- package/src/hooks/useModeConfig.ts +1 -2
- package/src/utils/compareProps.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-swiper
|
|
2
2
|
|
|
3
|
+
## 3.133.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve Web and desktop touch compatibility by routing `onTouchStart`, ([#200](https://github.com/lynx-family/lynx-ui/pull/200))
|
|
8
|
+
`onTouchMove`, `onTouchEnd`, and `onTouchCancel` through shared touch
|
|
9
|
+
emulation.
|
|
10
|
+
- Updated dependencies [[`3932070`](https://github.com/lynx-family/lynx-ui/commit/393207073522e221a79e65c643df2afb329ec931)]:
|
|
11
|
+
- @lynx-js/lynx-ui-common@3.133.1
|
|
12
|
+
|
|
3
13
|
## 3.133.0
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -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)
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModeConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useModeConfig.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"useModeConfig.d.ts","sourceRoot":"","sources":["../../src/hooks/useModeConfig.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kBAAkB,EAElB,WAAW,EACZ,MAAM,UAAU,CAAA;AAGjB;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAe,EACf,UAGC,GACF,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;;;EA2BnD"}
|
|
@@ -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
|
|
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 +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
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-swiper",
|
|
3
|
-
"version": "3.133.
|
|
3
|
+
"version": "3.133.1",
|
|
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.1.3",
|
|
29
|
-
"@lynx-js/lynx-ui-common": "3.133.
|
|
29
|
+
"@lynx-js/lynx-ui-common": "3.133.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@lynx-js/react": "0.114.0",
|
package/src/hooks/useAutoPlay.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import { useMemo, useRef } from '@lynx-js/react'
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
|
-
CompoundCustomModeConfig,
|
|
9
8
|
CompoundModeConfig,
|
|
10
9
|
CompoundNormalModeConfig,
|
|
11
10
|
SwiperProps,
|
|
@@ -31,7 +30,7 @@ export function useModeConfig({
|
|
|
31
30
|
|
|
32
31
|
const normalizedModeConfig = useMemo(() => {
|
|
33
32
|
const newConfig: CompoundModeConfig = mode === 'custom'
|
|
34
|
-
? { mode, ...(modeConfig ?? {}) }
|
|
33
|
+
? { mode, ...(modeConfig ?? {}) }
|
|
35
34
|
: {
|
|
36
35
|
mode,
|
|
37
36
|
...(modeConfig ?? { align: 'start' }),
|
|
@@ -20,8 +20,8 @@ export function comparePropsWithObject(
|
|
|
20
20
|
return false
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const prevKeys = Object.keys(prev
|
|
24
|
-
const nextKeys = Object.keys(next
|
|
23
|
+
const prevKeys = Object.keys(prev)
|
|
24
|
+
const nextKeys = Object.keys(next)
|
|
25
25
|
|
|
26
26
|
if (prevKeys.length !== nextKeys.length) {
|
|
27
27
|
return false
|