@lynx-js/lynx-ui-swiper 0.0.0 → 3.131.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.
Files changed (137) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +201 -0
  3. package/README.md +51 -0
  4. package/dist/Swiper/index.d.ts +11 -0
  5. package/dist/Swiper/index.d.ts.map +1 -0
  6. package/dist/Swiper/index.jsx +261 -0
  7. package/dist/Swiper/index.jsx.map +1 -0
  8. package/dist/Swiper/styles.css +47 -0
  9. package/dist/Swiper/styles.css.map +1 -0
  10. package/dist/SwiperItem/index.d.ts +46 -0
  11. package/dist/SwiperItem/index.d.ts.map +1 -0
  12. package/dist/SwiperItem/index.jsx +86 -0
  13. package/dist/SwiperItem/index.jsx.map +1 -0
  14. package/dist/const/index.d.ts +5 -0
  15. package/dist/const/index.d.ts.map +1 -0
  16. package/dist/const/index.jsx +7 -0
  17. package/dist/const/index.jsx.map +1 -0
  18. package/dist/hooks/useAnimate.d.ts +5 -0
  19. package/dist/hooks/useAnimate.d.ts.map +1 -0
  20. package/dist/hooks/useAnimate.jsx +47 -0
  21. package/dist/hooks/useAnimate.jsx.map +1 -0
  22. package/dist/hooks/useAutoPlay.d.ts +16 -0
  23. package/dist/hooks/useAutoPlay.d.ts.map +1 -0
  24. package/dist/hooks/useAutoPlay.jsx +58 -0
  25. package/dist/hooks/useAutoPlay.jsx.map +1 -0
  26. package/dist/hooks/useAxisLock.d.ts +12 -0
  27. package/dist/hooks/useAxisLock.d.ts.map +1 -0
  28. package/dist/hooks/useAxisLock.jsx +58 -0
  29. package/dist/hooks/useAxisLock.jsx.map +1 -0
  30. package/dist/hooks/useBounceConfig.d.ts +12 -0
  31. package/dist/hooks/useBounceConfig.d.ts.map +1 -0
  32. package/dist/hooks/useBounceConfig.jsx +15 -0
  33. package/dist/hooks/useBounceConfig.jsx.map +1 -0
  34. package/dist/hooks/useBounceView.d.ts +17 -0
  35. package/dist/hooks/useBounceView.d.ts.map +1 -0
  36. package/dist/hooks/useBounceView.jsx +16 -0
  37. package/dist/hooks/useBounceView.jsx.map +1 -0
  38. package/dist/hooks/useChange.d.ts +22 -0
  39. package/dist/hooks/useChange.d.ts.map +1 -0
  40. package/dist/hooks/useChange.jsx +53 -0
  41. package/dist/hooks/useChange.jsx.map +1 -0
  42. package/dist/hooks/useDirection.d.ts +13 -0
  43. package/dist/hooks/useDirection.d.ts.map +1 -0
  44. package/dist/hooks/useDirection.jsx +37 -0
  45. package/dist/hooks/useDirection.jsx.map +1 -0
  46. package/dist/hooks/useFirstScreenStyle.d.ts +34 -0
  47. package/dist/hooks/useFirstScreenStyle.d.ts.map +1 -0
  48. package/dist/hooks/useFirstScreenStyle.jsx +63 -0
  49. package/dist/hooks/useFirstScreenStyle.jsx.map +1 -0
  50. package/dist/hooks/useModeConfig.d.ts +14 -0
  51. package/dist/hooks/useModeConfig.d.ts.map +1 -0
  52. package/dist/hooks/useModeConfig.jsx +33 -0
  53. package/dist/hooks/useModeConfig.jsx.map +1 -0
  54. package/dist/hooks/useOffset.d.ts +37 -0
  55. package/dist/hooks/useOffset.d.ts.map +1 -0
  56. package/dist/hooks/useOffset.jsx +362 -0
  57. package/dist/hooks/useOffset.jsx.map +1 -0
  58. package/dist/hooks/useOffsetLimit.d.ts +16 -0
  59. package/dist/hooks/useOffsetLimit.d.ts.map +1 -0
  60. package/dist/hooks/useOffsetLimit.jsx +51 -0
  61. package/dist/hooks/useOffsetLimit.jsx.map +1 -0
  62. package/dist/hooks/useReset.d.ts +16 -0
  63. package/dist/hooks/useReset.d.ts.map +1 -0
  64. package/dist/hooks/useReset.jsx +68 -0
  65. package/dist/hooks/useReset.jsx.map +1 -0
  66. package/dist/hooks/useSwipeCallback.d.ts +14 -0
  67. package/dist/hooks/useSwipeCallback.d.ts.map +1 -0
  68. package/dist/hooks/useSwipeCallback.jsx +40 -0
  69. package/dist/hooks/useSwipeCallback.jsx.map +1 -0
  70. package/dist/hooks/useVelocity.d.ts +14 -0
  71. package/dist/hooks/useVelocity.d.ts.map +1 -0
  72. package/dist/hooks/useVelocity.jsx +62 -0
  73. package/dist/hooks/useVelocity.jsx.map +1 -0
  74. package/dist/hooks/useVelocity_experiment.d.ts +12 -0
  75. package/dist/hooks/useVelocity_experiment.d.ts.map +1 -0
  76. package/dist/hooks/useVelocity_experiment.jsx +38 -0
  77. package/dist/hooks/useVelocity_experiment.jsx.map +1 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.jsx +3 -0
  81. package/dist/store/index.d.ts +3 -0
  82. package/dist/store/index.d.ts.map +1 -0
  83. package/dist/store/index.jsx +18 -0
  84. package/dist/store/index.jsx.map +1 -0
  85. package/dist/types/index.d.ts +62 -0
  86. package/dist/types/index.d.ts.map +1 -0
  87. package/dist/types/index.docs.d.ts +448 -0
  88. package/dist/types/index.docs.d.ts.map +1 -0
  89. package/dist/types/index.jsx +9 -0
  90. package/dist/types/index.jsx.map +1 -0
  91. package/dist/utils/animate.d.ts +4 -0
  92. package/dist/utils/animate.d.ts.map +1 -0
  93. package/dist/utils/animate.jsx +29 -0
  94. package/dist/utils/animate.jsx.map +1 -0
  95. package/dist/utils/compareProps.d.ts +2 -0
  96. package/dist/utils/compareProps.d.ts.map +1 -0
  97. package/dist/utils/compareProps.jsx +14 -0
  98. package/dist/utils/compareProps.jsx.map +1 -0
  99. package/dist/utils/customRound.d.ts +10 -0
  100. package/dist/utils/customRound.d.ts.map +1 -0
  101. package/dist/utils/customRound.jsx +9 -0
  102. package/dist/utils/customRound.jsx.map +1 -0
  103. package/dist/utils/index.d.ts +20 -0
  104. package/dist/utils/index.d.ts.map +1 -0
  105. package/dist/utils/index.jsx +55 -0
  106. package/dist/utils/index.jsx.map +1 -0
  107. package/package.json +47 -4
  108. package/src/Swiper/index.tsx +414 -0
  109. package/src/Swiper/styles.css +44 -0
  110. package/src/SwiperItem/index.tsx +205 -0
  111. package/src/const/index.ts +11 -0
  112. package/src/hooks/useAnimate.ts +80 -0
  113. package/src/hooks/useAutoPlay.ts +95 -0
  114. package/src/hooks/useAxisLock.ts +92 -0
  115. package/src/hooks/useBounceConfig.ts +29 -0
  116. package/src/hooks/useBounceView.tsx +50 -0
  117. package/src/hooks/useChange.ts +131 -0
  118. package/src/hooks/useDirection.ts +59 -0
  119. package/src/hooks/useFirstScreenStyle.ts +200 -0
  120. package/src/hooks/useModeConfig.ts +56 -0
  121. package/src/hooks/useOffset.ts +609 -0
  122. package/src/hooks/useOffsetLimit.ts +98 -0
  123. package/src/hooks/useReset.ts +144 -0
  124. package/src/hooks/useSwipeCallback.ts +66 -0
  125. package/src/hooks/useVelocity.ts +85 -0
  126. package/src/hooks/useVelocity_experiment.ts +50 -0
  127. package/src/index.ts +8 -0
  128. package/src/store/index.ts +23 -0
  129. package/src/types/index.docs.ts +465 -0
  130. package/src/types/index.ts +105 -0
  131. package/src/utils/animate.ts +49 -0
  132. package/src/utils/compareProps.ts +54 -0
  133. package/src/utils/customRound.ts +23 -0
  134. package/src/utils/index.ts +117 -0
  135. package/tsconfig.docs.json +7 -0
  136. package/tsconfig.json +9 -0
  137. /package/{index.js → dist/types/index.docs.jsx} +0 -0
@@ -0,0 +1,448 @@
1
+ import type { ReactElement } from '@lynx-js/react';
2
+ import type { CSSProperties } from '@lynx-js/types';
3
+ export interface SwiperProps<T> {
4
+ /**
5
+ * Swiper items data set
6
+ * @Android
7
+ * @iOS
8
+ * @Harmony
9
+ * @zh 轮播图数据集合
10
+ */
11
+ data: T[];
12
+ /**
13
+ * Width of swiper item
14
+ * @Android
15
+ * @iOS
16
+ * @Harmony
17
+ * @zh 轮播图项宽度
18
+ */
19
+ itemWidth: number;
20
+ /**
21
+ * Height of SwiperItem
22
+ * @Android
23
+ * @iOS
24
+ * @Harmony
25
+ * @zh 轮播图项高度
26
+ */
27
+ itemHeight?: number | 'auto';
28
+ /**
29
+ * Children of Swiper should be a function, returning a SwiperItem
30
+ * @Android
31
+ * @iOS
32
+ * @Harmony
33
+ * @zh Swiper的子元素应该是一个函数,返回一个SwiperItem
34
+ * @example
35
+ * ```tsx
36
+ * <Swiper
37
+ * data={items}
38
+ * itemWidth={350}
39
+ * >
40
+ * {({ index, item }) => (
41
+ * <SwiperItem index={index} key={index}>
42
+ * <image class="image" src={`${item}`}></image>
43
+ * <text class="image-text">Number.{index}</text>
44
+ * </SwiperItem>
45
+ * )}
46
+ * </Swiper>
47
+ * ```
48
+ */
49
+ children: (prop: RenderFunctionProps<T>) => ReactElement;
50
+ /**
51
+ * Width of swiper item
52
+ * @defaultValue lynx.__globalProps.screenWidth
53
+ * @Android
54
+ * @iOS
55
+ * @Harmony
56
+ * @zh 轮播图容器的宽度
57
+ */
58
+ containerWidth?: number;
59
+ /**
60
+ * Initial index of Swiper, this value will only be used at firstScreen. Later updates will be ignored.
61
+ * @defaultValue 0
62
+ * @Android
63
+ * @iOS
64
+ * @Harmony
65
+ * @zh Swiper的初始索引,该值仅在首屏时使用。后续更新将被忽略。
66
+ */
67
+ initialIndex?: number;
68
+ /**
69
+ * Swiper loop back
70
+ * @defaultValue false
71
+ * @Android
72
+ * @iOS
73
+ * @Harmony
74
+ * @zh 是否开启循环轮播
75
+ */
76
+ loop?: boolean;
77
+ /**
78
+ * When loop is true, Swiper will duplicate the first 2 items and last 2 items to create a loop effect.
79
+ * This prop can be used to customize how many items to duplicate the first and last item.
80
+ * @defaultValue 2
81
+ * @Android
82
+ * @iOS
83
+ * @Harmony
84
+ * @zh 当loop为true时,Swiper会复制前2个和后2个项目来创建循环效果。此属性可用于自定义复制第一个和最后一个项目的数量。
85
+ */
86
+ loopDuplicateCount?: number;
87
+ /**
88
+ * Duration of animation for paging or swiping
89
+ * @defaultValue 500
90
+ * @Android
91
+ * @iOS
92
+ * @Harmony
93
+ * @zh 翻页或滑动动画的持续时间
94
+ */
95
+ duration?: number;
96
+ /**
97
+ * Callback fired when currentIndex of Swiper has changed
98
+ * @Android
99
+ * @iOS
100
+ * @Harmony
101
+ * @zh 当前索引改变时的回调函数
102
+ */
103
+ onChange?: (current: number) => void;
104
+ /**
105
+ * Callback fired when swiper started to swipe. Can be used with `onSwipeStop`.
106
+ * This is useful for disabling clicking when swiping.
107
+ * @Android
108
+ * @iOS
109
+ * @Harmony
110
+ * @zh 开始滑动时的回调函数。可与`onSwipeStop`配合使用。用于在滑动时禁用点击事件。
111
+ */
112
+ onSwipeStart?: (current: number) => void;
113
+ /**
114
+ * Callback fired when swiper stopped to swipe. Can be used with `onSwipeStart`.
115
+ * This is useful for disabling clicking when swiping.
116
+ * @Android
117
+ * @iOS
118
+ * @Harmony
119
+ * @zh 停止滑动时的回调函数。可与`onSwipeStart`配合使用。用于在滑动时禁用点击事件。
120
+ */
121
+ onSwipeStop?: (current: number) => void;
122
+ /**
123
+ * Callback fired when offset of Swiper changed.
124
+ * Should be a MainThread function
125
+ * @Android
126
+ * @iOS
127
+ * @Harmony
128
+ * @zh Swiper偏移量改变时的回调函数。应该是一个主线程函数
129
+ */
130
+ 'main-thread:onOffsetChange'?: (offset: number) => void;
131
+ /**
132
+ * Custom easing function for paging effect
133
+ * @Android
134
+ * @iOS
135
+ * @Harmony
136
+ * @zh 自定义翻页效果的缓动函数
137
+ */
138
+ 'main-thread:easing'?: (progress: number) => number;
139
+ /**
140
+ * Custom animation effect, should be a MainThread function
141
+ * @Android
142
+ * @iOS
143
+ * @Harmony
144
+ * @zh 自定义动画效果,应该是一个主线程函数
145
+ */
146
+ 'main-thread:customAnimation'?: (value: number, index: number) => CSSProperties;
147
+ /**
148
+ * Custom animation effect used in JS, should be a JS function.
149
+ * customAnimationFirstScreen should be a function of the same content of 'main-thread:customAnimation' without 'main thread' annotation
150
+ * This is a workaround for MainThreadScript's disability for supporting firstScreen.
151
+ * We are working on removing the duplicated JS version of customAnimation. For now, this is needed.
152
+ * @Android
153
+ * @iOS
154
+ * @Harmony
155
+ * @zh 在JS中使用的自定义动画效果,应该是一个JS函数。customAnimationFirstScreen应该是与'main-thread:customAnimation'内容相同的函数,但不带'main thread'注解。这是对MainThreadScript不支持首屏的临时解决方案。我们正在努力移除重复的JS版本的customAnimation。目前这是必需的。
156
+ */
157
+ customAnimationFirstScreen?: (value: number, index: number) => CSSProperties;
158
+ /**
159
+ * Whether to enable autoPlay
160
+ * @defaultValue false
161
+ * @Android
162
+ * @iOS
163
+ * @Harmony
164
+ * @zh 是否启用自动播放
165
+ */
166
+ autoPlay?: boolean;
167
+ /**
168
+ * Auto play interval
169
+ * @defaultValue 2000
170
+ * @Android
171
+ * @iOS
172
+ * @Harmony
173
+ * @zh 自动播放间隔
174
+ */
175
+ autoPlayInterval?: number;
176
+ /**
177
+ * Use this to limit or extend the offset of Swiper's range.
178
+ * This can be useful for limiting offset to avoid overscroll.
179
+ * For example, when mode === 'normal', and modeConfig.align === 'start', swipe to the last item technically means the last item's left
180
+ * edge align with container's left edge, leaving a blank area, which usually is not what we want.
181
+ * So we add an offsetLimit of [0, containerWidth - itemWidth], to limit the offset of Swiper.
182
+ * In this case, when swipe to the end, the last item's right edge align with container's right edge, leaving no blank area.
183
+ * @Android
184
+ * @iOS
185
+ * @Harmony
186
+ * @zh 用于限制或扩展Swiper的偏移量范围。可用于限制偏移量以避免过度滚动。例如,当mode === 'normal'且modeConfig.align === 'start'时,滑动到最后一个项目技术上意味着最后一个项目的左边缘与容器的左边缘对齐,留下空白区域,这通常不是我们想要的。因此我们添加了offsetLimit为[0, containerWidth - itemWidth],来限制Swiper的偏移量。在这种情况下,当滑动到末尾时,最后一个项目的右边缘与容器的右边缘对齐,不会留下空白区域。
187
+ */
188
+ offsetLimit?: [number, number];
189
+ /**
190
+ * BounceParams
191
+ * @Android
192
+ * @iOS
193
+ * @Harmony
194
+ * @zh 回弹参数配置
195
+ */
196
+ bounceConfig?: BounceConfig;
197
+ /**
198
+ * key of Swiper Component. Change this will reset Swiper progress and state.
199
+ * Can be used when reusing Swiper Component. Upon resting, `initialIndex` will be used again.
200
+ * @Android
201
+ * @iOS
202
+ * @Harmony
203
+ * @zh Swiper组件的key。更改此值将重置Swiper的进度和状态。可在重用Swiper组件时使用。重置时,将再次使用`initialIndex`。
204
+ */
205
+ swiperKey?: unknown;
206
+ /**
207
+ * Whether to reset Swiper progress and state when reuse Swiper Component.
208
+ * Can be useful when used in list.
209
+ * @defaultValue false
210
+ * @Android
211
+ * @iOS
212
+ * @Harmony
213
+ * @zh 在重用Swiper组件时是否重置Swiper的进度和状态。
214
+ */
215
+ resetOnReuse?: boolean;
216
+ /**
217
+ * Style for the root element of the Swiper component.
218
+ * This controls the visible viewport/frame that contains the swiper.
219
+ * Use this for: background, borders, padding, dimensions, overflow, etc.
220
+ * @Android
221
+ * @iOS
222
+ * @Harmony
223
+ * @zh Swiper组件根元素的样式。控制包含轮播图的可见视口/框架。用于:背景、边框、内边距、尺寸、溢出等。
224
+ */
225
+ style?: CSSProperties;
226
+ /**
227
+ * Style for the inner sliding track that holds all swiper items.
228
+ * This is the element that actually moves/slides.
229
+ * @Android
230
+ * @iOS
231
+ * @Harmony
232
+ * @zh 包含所有轮播项的内部滑动轨道的样式。这是实际移动/滑动的元素。
233
+ */
234
+ trackStyle?: CSSProperties;
235
+ /**
236
+ * Determines how swiper respond to touch in different angle.
237
+ * By default, swiper will only respond to horizontal touches.
238
+ * Refer to https://lynxjs.org/en/api/elements/built-in/view.html#consume-slide-event for more
239
+ * @defaultValue [[-180, -135], [-45, 45], [135, 180]]
240
+ * @Android
241
+ * @iOS
242
+ * @Harmony
243
+ * @zh 决定Swiper如何响应不同角度的触摸。默认情况下,Swiper只会响应水平方向的触摸。更多信息请参考 https://lynxjs.org/zh/api/elements/built-in/view.html#consume-slide-event
244
+ */
245
+ consumeSlideEvent?: [number, number][];
246
+ /**
247
+ * Whether to block native event.
248
+ * Can be useful when swiper is in Scrollview, List or other components that will block swiper's touch event.
249
+ * @defaultValue false
250
+ * @Android
251
+ * @iOS
252
+ * @Harmony
253
+ * @zh 是否阻止原生事件。当Swiper在Scrollview、List或其他会阻止Swiper触摸事件的组件中时可能有用。
254
+ */
255
+ blockNativeEvent?: boolean;
256
+ /**
257
+ * Whether to enable RTL mode.
258
+ * @defaultValue false
259
+ * @Android
260
+ * @iOS
261
+ * @Harmony
262
+ * @zh 是否启用RTL模式。
263
+ */
264
+ RTL?: boolean | 'lynx-rtl';
265
+ }
266
+ /**
267
+ * @hidden
268
+ */
269
+ export interface SwiperPropsNormal<T> extends SwiperProps<T> {
270
+ /**
271
+ * Mode of Swiper. Normal mode will make SwiperItem placed one after another.
272
+ * Custom mode will make SwiperItem placed in absolute position in the most left.
273
+ * This is used for complex modification and customLayout.
274
+ * You need to return proper position of each SwiperItem in 'main-thread:customAnimation'
275
+ * @defaultValue normal
276
+ * @Android
277
+ * @iOS
278
+ * @Harmony
279
+ * @zh Swiper的模式。普通模式会使SwiperItem依次排列。自定义模式会使SwiperItem以绝对定位方式放置在最左侧。这用于复杂的修改和自定义布局。你需要在'main-thread:customAnimation'中返回每个SwiperItem的正确位置
280
+ */
281
+ mode?: 'normal';
282
+ /**
283
+ * Additional config for mode
284
+ * @Android
285
+ * @iOS
286
+ * @Harmony
287
+ * @zh 模式的额外配置
288
+ */
289
+ modeConfig?: {
290
+ /**
291
+ * Alignment of SwiperItem.
292
+ * @defaultValue start
293
+ * @Android
294
+ * @iOS
295
+ * @Harmony
296
+ * @zh `<SwiperItem>` 的对齐方式。
297
+ */
298
+ align?: 'start' | 'center' | 'end';
299
+ /**
300
+ * Space between SwiperItem
301
+ * @defaultValue 0
302
+ * @Android
303
+ * @iOS
304
+ * @Harmony
305
+ * @zh `<SwiperItem>` 之间的间距
306
+ */
307
+ spaceBetween?: number;
308
+ };
309
+ }
310
+ /**
311
+ * @hidden
312
+ */
313
+ export interface SwiperPropsCustom<T> extends SwiperProps<T> {
314
+ /**
315
+ * Mode of Swiper. Normal mode will make SwiperItem placed one after another.
316
+ * Custom mode will make SwiperItem placed in absolute position in the most left.
317
+ * This is used for complex modification and customLayout.
318
+ * You need to return proper position of each SwiperItem in 'main-thread:customAnimation'
319
+ * @defaultValue normal
320
+ * @Android
321
+ * @iOS
322
+ * @Harmony
323
+ * @zh Swiper的模式。普通模式会使SwiperItem依次排列。自定义模式会使SwiperItem以绝对定位方式放置在最左侧。这用于复杂的修改和自定义布局。你需要在'main-thread:customAnimation'中返回每个SwiperItem的正确位置
324
+ */
325
+ mode?: 'custom';
326
+ /**
327
+ * Additional config for mode
328
+ * @Android
329
+ * @iOS
330
+ * @Harmony
331
+ * @zh 模式的额外配置
332
+ */
333
+ modeConfig?: Record<string, unknown>;
334
+ }
335
+ export type SwiperPropsReal<T> = SwiperPropsNormal<T> | SwiperPropsCustom<T>;
336
+ export interface SwipeToOptions {
337
+ animate?: boolean;
338
+ onFinished?: () => void;
339
+ }
340
+ export interface BounceConfig {
341
+ /**
342
+ * Whether to enable bounces. Ignored when loop is true.
343
+ * @defaultValue false
344
+ * @Android
345
+ * @iOS
346
+ * @Harmony
347
+ * @zh 是否启用回弹效果。当loop为true时忽略此设置。
348
+ */
349
+ enable?: boolean;
350
+ /**
351
+ * The left bounceItem (when in horizontal)
352
+ * @Android
353
+ * @iOS
354
+ * @Harmony
355
+ * @zh 左侧回弹项(水平方向时)
356
+ */
357
+ startBounceItem?: ReactElement;
358
+ /**
359
+ * The right bounceItem (when in horizontal)
360
+ * @Android
361
+ * @iOS
362
+ * @Harmony
363
+ * @zh 右侧回弹项(水平方向时)
364
+ */
365
+ endBounceItem?: ReactElement;
366
+ /**
367
+ * When startBounceItem is in bounce state, releasing finger will call this.
368
+ * @Android
369
+ * @iOS
370
+ * @Harmony
371
+ * @zh 当startBounceItem处于回弹状态时,释放手指将调用此函数。
372
+ */
373
+ onStartBounceItemBounce?: (bounceParams: onBounceParams) => void;
374
+ /** ····· ··
375
+ * When endBounceItem is in bounce state, releasing finger will call this.
376
+ * @Android
377
+ * @iOS
378
+ * @Harmony
379
+ * @zh 当endBounceItem处于回弹状态时,释放手指将调用此函数。
380
+ */
381
+ onEndBounceItemBounce?: (bounceParams: onBounceParams) => void;
382
+ /**
383
+ * Width of bounceItem.
384
+ * When overscroll the bounces, you will have larger and larger resistance, to make overscroll not exceed bounceItemWidth
385
+ * @defaultValue 100
386
+ * @Android
387
+ * @iOS
388
+ * @Harmony
389
+ * @zh 回弹项的宽度。当过度滚动回弹时,你会感受到越来越大的阻力,以防止过度滚动超过bounceItemWidth
390
+ */
391
+ startBounceItemWidth?: number;
392
+ /**
393
+ * Width of bounceItem.
394
+ * When overscroll the bounces, you will have larger and larger resistance, to make overscroll not exceed bounceItemWidth
395
+ * @defaultValue 100
396
+ * @Android
397
+ * @iOS
398
+ * @Harmony
399
+ * @zh 回弹项的宽度。当过度滚动回弹时,你会感受到越来越大的阻力,以防止过度滚动超过bounceItemWidth
400
+ */
401
+ endBounceItemWidth?: number;
402
+ }
403
+ export interface SwiperRef {
404
+ /**
405
+ * SwiperTo item of index
406
+ * @Android
407
+ * @iOS
408
+ * @Harmony
409
+ * @zh 滑动到指定索引的项目
410
+ */
411
+ swipeTo: (index: number, options?: SwipeToOptions) => void;
412
+ /**
413
+ * Swiper to next item
414
+ * @Android
415
+ * @iOS
416
+ * @Harmony
417
+ * @zh 滑动到下一个项目
418
+ */
419
+ swipeNext: () => void;
420
+ /**
421
+ * Swiper to previous item
422
+ * @Android
423
+ * @iOS
424
+ * @Harmony
425
+ * @zh 滑动到上一个项目
426
+ */
427
+ swipePrev: () => void;
428
+ /**
429
+ * Cancel Current Running Animation.
430
+ * Use with caution, may break internal states.
431
+ * @experimental
432
+ * @Android
433
+ * @iOS
434
+ * @Harmony
435
+ * @zh 取消当前正在运行的动画。谨慎使用,可能会破坏内部状态。
436
+ */
437
+ cancelAnimation: () => void;
438
+ }
439
+ export interface onBounceParams {
440
+ type: 'start' | 'end';
441
+ offset: number;
442
+ }
443
+ export interface RenderFunctionProps<T> {
444
+ item: T;
445
+ index: number;
446
+ realIndex: number;
447
+ }
448
+ //# sourceMappingURL=index.docs.d.ts.map
@@ -0,0 +1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AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,GAAG,KAAK,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC,IAAI,EAAE,CAAC,CAAA;IACP,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;CAClB"}
@@ -0,0 +1,9 @@
1
+ var types_SwipeDirection = /*#__PURE__*/ function(SwipeDirection) {
2
+ SwipeDirection[SwipeDirection["NORMAL"] = -1] = "NORMAL";
3
+ SwipeDirection[SwipeDirection["NONE"] = 0] = "NONE";
4
+ SwipeDirection[SwipeDirection["REVERT"] = 1] = "REVERT";
5
+ return SwipeDirection;
6
+ }({});
7
+ export { types_SwipeDirection as SwipeDirection };
8
+
9
+ //# sourceMappingURL=index.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types/index.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/types/index.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport type { CSSProperties, MainThread } from '@lynx-js/types'\n\nimport type {\n BounceConfig,\n SwipeToOptions,\n SwiperPropsReal as SwiperProps,\n SwiperRef,\n onBounceParams,\n} from './index.docs'\n\nexport interface SwiperContextProps extends\n Pick<\n SwiperProps<unknown>,\n 'itemWidth' | 'itemHeight' | 'customAnimationFirstScreen' | 'RTL'\n >,\n Required<Pick<SwiperProps<unknown>, 'initialIndex' | 'loop'>>\n{\n setChildrenRef: (ref: MainThread.Element, index: number) => void\n spaceBetween: number\n modeConfig: CompoundModeConfig\n}\n\nexport interface CompoundNormalModeConfig {\n mode: 'normal'\n align: 'start' | 'center' | 'end'\n}\n\nexport interface CompoundCustomModeConfig {\n mode: 'custom'\n}\n\nexport type CompoundModeConfig =\n | CompoundNormalModeConfig\n | CompoundCustomModeConfig\n\nexport type customAnimation = (\n progress: number,\n props: SwiperProps<unknown>,\n) => CSSProperties\n\nexport interface CustomTouch {\n identifier: number\n pageX: number\n pageY: number\n clientX: number\n clientY: number\n x: number\n y: number\n}\n\n/**\n * Rewrite forwardRef to make it supports generic\n * see: https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\n */\ndeclare module 'react' {\n // biome-ignore lint/complexity/noBannedTypes: Expected\n function forwardRef<T, P = {}>(\n render: (props: P, ref: React.Ref<T>) => React.ReactElement | null,\n ): (props: P & React.RefAttributes<T>) => React.ReactElement | null\n}\n\ndeclare module '@lynx-js/types' {\n interface GlobalProps {\n screenWidth: number\n }\n}\n\nexport interface ResetOptions {\n fullReset?: boolean\n resetIndex?: number\n}\n\nexport interface UpdateSwiperInnerContainerOptions {\n itemWidth: number\n loopDuplicateCount: number\n loop: boolean\n dataCount: number\n spaceBetween: number\n itemHeight: SwiperProps<unknown>['itemHeight']\n mode: CompoundModeConfig['mode']\n}\n\nexport enum SwipeDirection {\n NORMAL = -1,\n NONE = 0,\n REVERT = 1,\n}\n\nexport interface OffsetLimitResult {\n startLimit: number\n endLimit: number\n isNotEnoughForScreen: boolean\n}\n\nexport type {\n BounceConfig,\n SwiperRef,\n onBounceParams,\n SwipeToOptions,\n SwiperProps,\n}\n"],"names":["SwipeDirection"],"mappings":"AAsFO,IAAKA,uBAAcA,WAAAA,GAAAA,SAAdA,cAAc;;;;WAAdA"}
@@ -0,0 +1,4 @@
1
+ export declare function animate(duration: number, onUpdate: (progress: number) => void, onFinished?: () => void): {
2
+ cancel: () => void;
3
+ };
4
+ //# sourceMappingURL=animate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animate.d.ts","sourceRoot":"","sources":["../../src/utils/animate.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,CACrB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,EACpC,UAAU,CAAC,EAAE,MAAM,IAAI;;EAyCxB"}
@@ -0,0 +1,29 @@
1
+ function animate(duration, onUpdate, onFinished) {
2
+ 'main thread';
3
+ let startTs = 0;
4
+ let rafId = 0;
5
+ function tick(ts) {
6
+ const progress = Math.max(Math.min((ts - startTs) * 100 / duration, 100), 0);
7
+ onUpdate(progress);
8
+ }
9
+ function updateRafId(id) {
10
+ rafId = id;
11
+ }
12
+ function step(ts) {
13
+ if (!startTs) startTs = Number(ts);
14
+ if (ts - startTs <= duration + 100) {
15
+ tick(ts);
16
+ updateRafId(requestAnimationFrame(step));
17
+ } else onFinished?.();
18
+ }
19
+ updateRafId(requestAnimationFrame(step));
20
+ function cancel() {
21
+ cancelAnimationFrame(rafId);
22
+ }
23
+ return {
24
+ cancel
25
+ };
26
+ }
27
+ export { animate };
28
+
29
+ //# sourceMappingURL=animate.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/animate.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/utils/animate.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nexport function animate(\n duration: number,\n onUpdate: (progress: number) => void,\n onFinished?: () => void,\n) {\n 'main thread'\n let startTs = 0\n let rafId = 0\n\n function tick(ts: number) {\n const progress = Math.max(\n Math.min(((ts - startTs) * 100) / duration, 100),\n 0,\n )\n\n onUpdate(progress)\n }\n\n function updateRafId(id: number) {\n rafId = id\n }\n\n function step(ts: number) {\n if (!startTs) {\n startTs = Number(ts)\n }\n // make sure progress can reach 100%\n if (ts - startTs <= duration + 100) {\n tick(ts)\n updateRafId(requestAnimationFrame(step))\n } else {\n onFinished?.()\n }\n }\n\n updateRafId(requestAnimationFrame(step))\n\n function cancel() {\n cancelAnimationFrame(rafId)\n }\n\n return {\n cancel,\n }\n}\n"],"names":["animate","duration","onUpdate","onFinished","startTs","rafId","tick","ts","progress","Math","updateRafId","id","step","Number","requestAnimationFrame","cancel","cancelAnimationFrame"],"mappings":"AAIO,SAASA,QACdC,QAAgB,EAChBC,QAAoC,EACpCC,UAAuB;IAEvB;IACA,IAAIC,UAAU;IACd,IAAIC,QAAQ;IAEZ,SAASC,KAAKC,EAAU;QACtB,MAAMC,WAAWC,KAAK,GAAG,CACvBA,KAAK,GAAG,CAAGF,AAAAA,CAAAA,KAAKH,OAAM,IAAK,MAAOH,UAAU,MAC5C;QAGFC,SAASM;IACX;IAEA,SAASE,YAAYC,EAAU;QAC7BN,QAAQM;IACV;IAEA,SAASC,KAAKL,EAAU;QACtB,IAAI,CAACH,SACHA,UAAUS,OAAON;QAGnB,IAAIA,KAAKH,WAAWH,WAAW,KAAK;YAClCK,KAAKC;YACLG,YAAYI,sBAAsBF;QACpC,OACET;IAEJ;IAEAO,YAAYI,sBAAsBF;IAElC,SAASG;QACPC,qBAAqBX;IACvB;IAEA,OAAO;QACLU;IACF;AACF"}
@@ -0,0 +1,2 @@
1
+ export declare function comparePropsWithObject(prev: unknown, next: unknown, objectKeys?: string[]): boolean;
2
+ //# sourceMappingURL=compareProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compareProps.d.ts","sourceRoot":"","sources":["../../src/utils/compareProps.ts"],"names":[],"mappings":"AAMA,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,OAAO,EACb,UAAU,CAAC,EAAE,MAAM,EAAE,GACpB,OAAO,CA2CT"}
@@ -0,0 +1,14 @@
1
+ function comparePropsWithObject(prev, next, objectKeys) {
2
+ if (prev === next) return true;
3
+ if ('object' != typeof prev || 'object' != typeof next || null === prev || null === next) return false;
4
+ const prevKeys = Object.keys(prev);
5
+ const nextKeys = Object.keys(next);
6
+ if (prevKeys.length !== nextKeys.length) return false;
7
+ for (const key of prevKeys)if (objectKeys?.includes(key)) {
8
+ if (!comparePropsWithObject(prev[key], next[key], [])) return false;
9
+ } else if (!Object.is(prev[key], next[key])) return false;
10
+ return true;
11
+ }
12
+ export { comparePropsWithObject };
13
+
14
+ //# sourceMappingURL=compareProps.jsx.map
@@ -0,0 +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 as DeepObject)\n const nextKeys = Object.keys(next as DeepObject)\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"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Round with threshold other than 0.5
3
+ * eg: customRound(1.8, 0.7) === 2
4
+ * eg: customRound(1.6, 0.7) === 1
5
+ * @param num
6
+ * @param threshold
7
+ * @returns number
8
+ */
9
+ export declare function customRound(num: number, threshold?: number): number;
10
+ //# sourceMappingURL=customRound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customRound.d.ts","sourceRoot":"","sources":["../../src/utils/customRound.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAM,UAUvD"}
@@ -0,0 +1,9 @@
1
+ function customRound(num, threshold = 0.5) {
2
+ 'main thread';
3
+ const decimal = num - Math.floor(num);
4
+ if (decimal >= threshold) return Math.ceil(num);
5
+ return Math.floor(num);
6
+ }
7
+ export { customRound };
8
+
9
+ //# sourceMappingURL=customRound.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils/customRound.jsx","sources":["webpack://@lynx-js/lynx-ui-swiper/./src/utils/customRound.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\n/**\n * Round with threshold other than 0.5\n * eg: customRound(1.8, 0.7) === 2\n * eg: customRound(1.6, 0.7) === 1\n * @param num\n * @param threshold\n * @returns number\n */\nexport function customRound(num: number, threshold = 0.5) {\n 'main thread'\n const decimal = num - Math.floor(num)\n\n // Check if the decimal part is greater than or equal to 0.9\n if (decimal >= threshold) {\n return Math.ceil(num)\n } else {\n return Math.floor(num)\n }\n}\n"],"names":["customRound","num","threshold","decimal","Math"],"mappings":"AAYO,SAASA,YAAYC,GAAW,EAAEC,YAAY,GAAG;IACtD;IACA,MAAMC,UAAUF,MAAMG,KAAK,KAAK,CAACH;IAGjC,IAAIE,WAAWD,WACb,OAAOE,KAAK,IAAI,CAACH;IAEjB,OAAOG,KAAK,KAAK,CAACH;AAEtB"}
@@ -0,0 +1,20 @@
1
+ import type { OffsetLimitResult } from '../types';
2
+ declare function easeOut(progress: number): number;
3
+ declare function limiter(offset: number, dataCount: number, size: number, spaceBetween: number, loop: boolean, offsetLimit: OffsetLimitResult): number;
4
+ /**
5
+ * limiter is used for useOffset
6
+ * When mode === 'normal', different aligns are applied an alignOffset based on realOffset returned by useOffset
7
+ * We first remove the offset, and use limiter to get the realOffset from useOffset
8
+ * And then applied alignOffset back, to make the position right.
9
+ */
10
+ declare function limiterForFirstScreen(offset: number, dataCount: number, size: number, spaceBetween: number, loop: boolean, offsetLimit: OffsetLimitResult, alignOffset: number): number;
11
+ declare function limiterMTS(offset: number, dataCount: number, size: number, loop: boolean, offsetLimit: OffsetLimitResult): {
12
+ offset: number;
13
+ reachingLimit: boolean;
14
+ };
15
+ export declare function fixPrecisionMT(num: number): number;
16
+ export declare function safeEqualMT(a: number, b: number, epsilon?: number): boolean;
17
+ export declare function eqOrGtMT(a: number, b: number, epsilon?: number): boolean;
18
+ export declare function eqOrLtMT(a: number, b: number, epsilon?: number): boolean;
19
+ export { easeOut, limiter, limiterMTS, limiterForFirstScreen };
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,iBAAS,OAAO,CAAC,QAAQ,EAAE,MAAM,UAGhC;AAED,iBAAS,OAAO,CACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,iBAAiB,GAC7B,MAAM,CAkBR;AAED;;;;;GAKG;AACH,iBAAS,qBAAqB,CAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,iBAAiB,EAC9B,WAAW,EAAE,MAAM,UAapB;AAED,iBAAS,UAAU,CACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,iBAAiB;;;EAe/B;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CASlD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAU,WAGlE;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAU,WAG/D;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,SAAU,WAG/D;AAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,55 @@
1
+ function easeOut(progress) {
2
+ 'main thread';
3
+ return 1 - Math.pow(1 - progress, 3);
4
+ }
5
+ function limiter(offset, dataCount, size, spaceBetween, loop, offsetLimit) {
6
+ if (0 === dataCount) return 0;
7
+ if (!loop) {
8
+ if (offset >= -offsetLimit.startLimit) return -offsetLimit.startLimit;
9
+ else if (offset < -(size + spaceBetween) * (dataCount - 1) + spaceBetween + offsetLimit.endLimit) return -(size + spaceBetween) * (dataCount - 1) + spaceBetween + offsetLimit.startLimit;
10
+ }
11
+ return offset;
12
+ }
13
+ function limiterForFirstScreen(offset, dataCount, size, spaceBetween, loop, offsetLimit, alignOffset) {
14
+ return alignOffset + limiter(offset - alignOffset, dataCount, size, spaceBetween, loop, offsetLimit);
15
+ }
16
+ function limiterMTS(offset, dataCount, size, loop, offsetLimit) {
17
+ 'main thread';
18
+ let reachingLimit = false;
19
+ let finalOffset = offset;
20
+ if (!loop) {
21
+ if (offset >= offsetLimit.startLimit) {
22
+ reachingLimit = true;
23
+ finalOffset = offsetLimit.startLimit;
24
+ } else if (offset <= -size * (dataCount - 1) + offsetLimit.endLimit) {
25
+ reachingLimit = true;
26
+ finalOffset = -size * (dataCount - 1) + offsetLimit.endLimit;
27
+ }
28
+ }
29
+ return {
30
+ offset: finalOffset,
31
+ reachingLimit
32
+ };
33
+ }
34
+ const EPSILON = 1e-10;
35
+ function fixPrecisionMT(num) {
36
+ 'main thread';
37
+ const epsilon = 0.000001;
38
+ if (Math.abs(num - Math.round(num)) < epsilon) return Math.round(num);
39
+ return num;
40
+ }
41
+ function safeEqualMT(a, b, epsilon = EPSILON) {
42
+ 'main thread';
43
+ return Math.abs(a - b) < epsilon;
44
+ }
45
+ function eqOrGtMT(a, b, epsilon = EPSILON) {
46
+ 'main thread';
47
+ return Math.abs(a - b) < epsilon || a > b;
48
+ }
49
+ function eqOrLtMT(a, b, epsilon = EPSILON) {
50
+ 'main thread';
51
+ return Math.abs(a - b) < epsilon || a < b;
52
+ }
53
+ export { easeOut, eqOrGtMT, eqOrLtMT, fixPrecisionMT, limiter, limiterForFirstScreen, limiterMTS, safeEqualMT };
54
+
55
+ //# sourceMappingURL=index.jsx.map