@lynx-js/lynx-ui-swiper 3.133.1 → 3.135.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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-swiper
|
|
2
2
|
|
|
3
|
+
## 3.135.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Keep custom-mode swiper navigation from being locked when item content does not fill the container. ([#223](https://github.com/lynx-family/lynx-ui/pull/223))
|
|
8
|
+
|
|
3
9
|
## 3.133.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOffsetLimit.d.ts","sourceRoot":"","sources":["../../src/hooks/useOffsetLimit.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAA;AAEjB,UAAU,YAAa,SACrB,QAAQ,CACN,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,CAAC,CACpE;IAED,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IAChD,UAAU,EAAE,kBAAkB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,IAAI,EACJ,UAAU,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACZ,SAAS,GACV,EAAE,YAAY,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"useOffsetLimit.d.ts","sourceRoot":"","sources":["../../src/hooks/useOffsetLimit.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACZ,MAAM,UAAU,CAAA;AAEjB,UAAU,YAAa,SACrB,QAAQ,CACN,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,CAAC,CACpE;IAED,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAA;IAChD,UAAU,EAAE,kBAAkB,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EACX,IAAI,EACJ,UAAU,EACV,SAAS,EACT,cAAc,EACd,YAAY,EACZ,SAAS,GACV,EAAE,YAAY,GAAG,iBAAiB,CA+DlC"}
|
|
@@ -14,7 +14,7 @@ function useOffsetLimit({ offsetLimit, loop, modeConfig, itemWidth, containerWid
|
|
|
14
14
|
endLimit: offsetLimit[1],
|
|
15
15
|
isNotEnoughForScreen: false
|
|
16
16
|
};
|
|
17
|
-
if (totalContentWidth <= containerWidth + epsilon) return {
|
|
17
|
+
if ('normal' === modeConfig.mode && totalContentWidth <= containerWidth + epsilon) return {
|
|
18
18
|
startLimit: 0,
|
|
19
19
|
endLimit: Math.max(fullSize * (dataCount - 1), 0),
|
|
20
20
|
isNotEnoughForScreen: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks/useOffsetLimit.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useOffsetLimit.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMemo } from '@lynx-js/react'\n\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\n\ninterface IOffsetLimit extends\n Required<\n Pick<SwiperProps<unknown>, 'loop' | 'itemWidth' | 'containerWidth'>\n >\n{\n offsetLimit: SwiperProps<unknown>['offsetLimit']\n modeConfig: CompoundModeConfig\n dataCount: number\n spaceBetween: number\n}\n\n/**\n * `offsetLimit` is used to limit the range of offset. Useful for when setting `align='start'`,\n * the last item should align with right edge, instead of align to the left.\n * This can achieved by setting offsetLimit to `[0, containerWidth - itemWidth]`, which basically\n * prevent further scroll if the last item is bond to right edge.\n */\nexport function useOffsetLimit({\n offsetLimit,\n loop,\n modeConfig,\n itemWidth,\n containerWidth,\n spaceBetween,\n dataCount,\n}: IOffsetLimit): OffsetLimitResult {\n const finalOffsetLimit = useMemo<OffsetLimitResult>(() => {\n const epsilon = 0.000001\n const fullSize = itemWidth + spaceBetween\n const totalContentWidth = fullSize * dataCount - spaceBetween\n\n if (loop) {\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n } else if (offsetLimit) {\n return {\n startLimit: offsetLimit[0],\n endLimit: offsetLimit[1],\n isNotEnoughForScreen: false,\n }\n } else {\n // If SwiperItem can not occupy the screen, do not apply offsetLimit.\n if (totalContentWidth <= containerWidth + epsilon) {\n return {\n startLimit: 0,\n // Lock both start/end to the same offset to disable scroll.\n endLimit: Math.max(fullSize * (dataCount - 1), 0),\n isNotEnoughForScreen: true,\n }\n }\n\n if (modeConfig.mode === 'normal' && modeConfig.align === 'start') {\n return {\n startLimit: 0,\n endLimit: containerWidth - itemWidth,\n isNotEnoughForScreen: false,\n }\n } else if (modeConfig.mode === 'normal' && modeConfig.align === 'end') {\n return {\n startLimit: containerWidth - itemWidth,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n }, [\n dataCount,\n offsetLimit?.[0],\n offsetLimit?.[1],\n modeConfig,\n loop,\n itemWidth,\n spaceBetween,\n containerWidth,\n ])\n\n return finalOffsetLimit\n}\n"],"names":["useOffsetLimit","offsetLimit","loop","modeConfig","itemWidth","containerWidth","spaceBetween","dataCount","finalOffsetLimit","useMemo","epsilon","fullSize","totalContentWidth","Math"],"mappings":";AA6BO,SAASA,eAAe,EAC7BC,WAAW,EACXC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,YAAY,EACZC,SAAS,EACI;IACb,MAAMC,mBAAmBC,QAA2B;QAClD,MAAMC,UAAU;QAChB,MAAMC,WAAWP,YAAYE;QAC7B,MAAMM,oBAAoBD,WAAWJ,YAAYD;QAEjD,IAAIJ,MACF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;QACK,IAAID,aACT,OAAO;YACL,YAAYA,WAAW,CAAC,EAAE;YAC1B,UAAUA,WAAW,CAAC,EAAE;YACxB,sBAAsB;QACxB;QAGA,
|
|
1
|
+
{"version":3,"file":"hooks/useOffsetLimit.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/hooks/useOffsetLimit.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { useMemo } from '@lynx-js/react'\n\nimport type {\n CompoundModeConfig,\n OffsetLimitResult,\n SwiperProps,\n} from '../types'\n\ninterface IOffsetLimit extends\n Required<\n Pick<SwiperProps<unknown>, 'loop' | 'itemWidth' | 'containerWidth'>\n >\n{\n offsetLimit: SwiperProps<unknown>['offsetLimit']\n modeConfig: CompoundModeConfig\n dataCount: number\n spaceBetween: number\n}\n\n/**\n * `offsetLimit` is used to limit the range of offset. Useful for when setting `align='start'`,\n * the last item should align with right edge, instead of align to the left.\n * This can achieved by setting offsetLimit to `[0, containerWidth - itemWidth]`, which basically\n * prevent further scroll if the last item is bond to right edge.\n */\nexport function useOffsetLimit({\n offsetLimit,\n loop,\n modeConfig,\n itemWidth,\n containerWidth,\n spaceBetween,\n dataCount,\n}: IOffsetLimit): OffsetLimitResult {\n const finalOffsetLimit = useMemo<OffsetLimitResult>(() => {\n const epsilon = 0.000001\n const fullSize = itemWidth + spaceBetween\n const totalContentWidth = fullSize * dataCount - spaceBetween\n\n if (loop) {\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n } else if (offsetLimit) {\n return {\n startLimit: offsetLimit[0],\n endLimit: offsetLimit[1],\n isNotEnoughForScreen: false,\n }\n } else {\n // If SwiperItem can not occupy the screen, do not apply offsetLimit.\n if (\n modeConfig.mode === 'normal'\n && totalContentWidth <= containerWidth + epsilon\n ) {\n return {\n startLimit: 0,\n // Lock both start/end to the same offset to disable scroll.\n endLimit: Math.max(fullSize * (dataCount - 1), 0),\n isNotEnoughForScreen: true,\n }\n }\n\n if (modeConfig.mode === 'normal' && modeConfig.align === 'start') {\n return {\n startLimit: 0,\n endLimit: containerWidth - itemWidth,\n isNotEnoughForScreen: false,\n }\n } else if (modeConfig.mode === 'normal' && modeConfig.align === 'end') {\n return {\n startLimit: containerWidth - itemWidth,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n return {\n startLimit: 0,\n endLimit: 0,\n isNotEnoughForScreen: false,\n }\n }\n }, [\n dataCount,\n offsetLimit?.[0],\n offsetLimit?.[1],\n modeConfig,\n loop,\n itemWidth,\n spaceBetween,\n containerWidth,\n ])\n\n return finalOffsetLimit\n}\n"],"names":["useOffsetLimit","offsetLimit","loop","modeConfig","itemWidth","containerWidth","spaceBetween","dataCount","finalOffsetLimit","useMemo","epsilon","fullSize","totalContentWidth","Math"],"mappings":";AA6BO,SAASA,eAAe,EAC7BC,WAAW,EACXC,IAAI,EACJC,UAAU,EACVC,SAAS,EACTC,cAAc,EACdC,YAAY,EACZC,SAAS,EACI;IACb,MAAMC,mBAAmBC,QAA2B;QAClD,MAAMC,UAAU;QAChB,MAAMC,WAAWP,YAAYE;QAC7B,MAAMM,oBAAoBD,WAAWJ,YAAYD;QAEjD,IAAIJ,MACF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;QACK,IAAID,aACT,OAAO;YACL,YAAYA,WAAW,CAAC,EAAE;YAC1B,UAAUA,WAAW,CAAC,EAAE;YACxB,sBAAsB;QACxB;QAGA,IACEE,AAAoB,aAApBA,WAAW,IAAI,IACZS,qBAAqBP,iBAAiBK,SAEzC,OAAO;YACL,YAAY;YAEZ,UAAUG,KAAK,GAAG,CAACF,WAAYJ,CAAAA,YAAY,IAAI;YAC/C,sBAAsB;QACxB;QAGF,IAAIJ,AAAoB,aAApBA,WAAW,IAAI,IAAiBA,AAAqB,YAArBA,WAAW,KAAK,EAClD,OAAO;YACL,YAAY;YACZ,UAAUE,iBAAiBD;YAC3B,sBAAsB;QACxB;QACK,IAAID,AAAoB,aAApBA,WAAW,IAAI,IAAiBA,AAAqB,UAArBA,WAAW,KAAK,EACzD,OAAO;YACL,YAAYE,iBAAiBD;YAC7B,UAAU;YACV,sBAAsB;QACxB;QAEF,OAAO;YACL,YAAY;YACZ,UAAU;YACV,sBAAsB;QACxB;IAEJ,GAAG;QACDG;QACAN,aAAa,CAAC,EAAE;QAChBA,aAAa,CAAC,EAAE;QAChBE;QACAD;QACAE;QACAE;QACAD;KACD;IAED,OAAOG;AACT"}
|
package/package.json
CHANGED
|
@@ -55,7 +55,10 @@ export function useOffsetLimit({
|
|
|
55
55
|
}
|
|
56
56
|
} else {
|
|
57
57
|
// If SwiperItem can not occupy the screen, do not apply offsetLimit.
|
|
58
|
-
if (
|
|
58
|
+
if (
|
|
59
|
+
modeConfig.mode === 'normal'
|
|
60
|
+
&& totalContentWidth <= containerWidth + epsilon
|
|
61
|
+
) {
|
|
59
62
|
return {
|
|
60
63
|
startLimit: 0,
|
|
61
64
|
// Lock both start/end to the same offset to disable scroll.
|