@arco-design/mobile-react 2.27.1 → 2.27.3

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 (59) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/_helpers/index.d.ts +1 -0
  5. package/cjs/_helpers/index.js +10 -0
  6. package/cjs/index-bar/type.d.ts +3 -3
  7. package/cjs/load-more/index.js +4 -1
  8. package/cjs/nav-bar/index.js +2 -2
  9. package/cjs/show-monitor/index.js +112 -38
  10. package/cjs/swipe-load/demo/style/css/mobile.css +3 -0
  11. package/cjs/swipe-load/demo/style/mobile.less +11 -0
  12. package/cjs/swipe-load/index.js +86 -32
  13. package/cjs/swipe-load/style/css/index.css +3 -0
  14. package/cjs/swipe-load/style/index.less +7 -0
  15. package/cjs/swipe-load/type.d.ts +29 -0
  16. package/cjs/tabs/index.js +6 -2
  17. package/cjs/tabs/style/css/index.css +4 -0
  18. package/cjs/tabs/style/index.less +5 -0
  19. package/cjs/tabs/tab-pane.js +49 -12
  20. package/cjs/tabs/type.d.ts +7 -1
  21. package/dist/index.js +297 -119
  22. package/dist/index.min.js +5 -5
  23. package/dist/style.css +7 -0
  24. package/dist/style.min.css +1 -1
  25. package/esm/_helpers/index.d.ts +1 -0
  26. package/esm/_helpers/index.js +7 -0
  27. package/esm/index-bar/type.d.ts +3 -3
  28. package/esm/load-more/index.js +4 -1
  29. package/esm/nav-bar/index.js +2 -2
  30. package/esm/show-monitor/index.js +112 -38
  31. package/esm/swipe-load/demo/style/css/mobile.css +3 -0
  32. package/esm/swipe-load/demo/style/mobile.less +11 -0
  33. package/esm/swipe-load/index.js +85 -32
  34. package/esm/swipe-load/style/css/index.css +3 -0
  35. package/esm/swipe-load/style/index.less +7 -0
  36. package/esm/swipe-load/type.d.ts +29 -0
  37. package/esm/tabs/index.js +6 -2
  38. package/esm/tabs/style/css/index.css +4 -0
  39. package/esm/tabs/style/index.less +5 -0
  40. package/esm/tabs/tab-pane.js +49 -11
  41. package/esm/tabs/type.d.ts +7 -1
  42. package/package.json +3 -3
  43. package/umd/_helpers/index.d.ts +1 -0
  44. package/umd/_helpers/index.js +10 -0
  45. package/umd/index-bar/type.d.ts +3 -3
  46. package/umd/load-more/index.js +4 -1
  47. package/umd/nav-bar/index.js +2 -2
  48. package/umd/show-monitor/index.js +112 -38
  49. package/umd/swipe-load/demo/style/css/mobile.css +3 -0
  50. package/umd/swipe-load/demo/style/mobile.less +11 -0
  51. package/umd/swipe-load/index.js +88 -36
  52. package/umd/swipe-load/style/css/index.css +3 -0
  53. package/umd/swipe-load/style/index.less +7 -0
  54. package/umd/swipe-load/type.d.ts +29 -0
  55. package/umd/tabs/index.js +6 -2
  56. package/umd/tabs/style/css/index.css +4 -0
  57. package/umd/tabs/style/index.less +5 -0
  58. package/umd/tabs/tab-pane.js +49 -12
  59. package/umd/tabs/type.d.ts +7 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.27.3](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.27.2...@arco-design/mobile-react@2.27.3) (2023-05-16)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `Tabs` support swipe energy-saving mode ([50a440b](https://github.com/arco-design/arco-design-mobile/commit/50a440bc808c418a01160d8dcbaa2a870a5a4b97))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.27.2](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.27.1...@arco-design/mobile-react@2.27.2) (2023-05-10)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * `LoadMore` status reset time for controlled mode ([#121](https://github.com/arco-design/arco-design-mobile/issues/121)) ([f141e7f](https://github.com/arco-design/arco-design-mobile/commit/f141e7f8e91944f5d68bb5fbf59238d5d48b8eda))
23
+ * `NavBar` fix warning in nextjs ssr ([#118](https://github.com/arco-design/arco-design-mobile/issues/118)) ([57c2838](https://github.com/arco-design/arco-design-mobile/commit/57c283852f26e06fb4d38dc8753cff7a34232a98))
24
+ * `ShowMonitor` support observer singleton ([#113](https://github.com/arco-design/arco-design-mobile/issues/113)) ([7099b30](https://github.com/arco-design/arco-design-mobile/commit/7099b307935357e496b902f6148ea0854da2912a))
25
+ * `SwipeLoad` support bounce animate ([#29](https://github.com/arco-design/arco-design-mobile/issues/29)) ([cad1a6b](https://github.com/arco-design/arco-design-mobile/commit/cad1a6ba19e6d45a33233281fba863434f553ce2))
26
+ * `Tabs` enable auto scroll when activeTab changed in scroll mode ([#116](https://github.com/arco-design/arco-design-mobile/issues/116)) ([07374f1](https://github.com/arco-design/arco-design-mobile/commit/07374f105f99418d447fc494c90d99d876601f9b))
27
+
28
+
29
+
30
+
31
+
6
32
  ## [2.27.1](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.27.0...@arco-design/mobile-react@2.27.1) (2023-04-26)
7
33
 
8
34
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.27.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.27.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.27.2/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.27.2/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.27.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.27.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.27.2/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.27.2/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -7,6 +7,7 @@ export * from './hooks';
7
7
  export * from './type';
8
8
  export * from './react-dom';
9
9
  export declare function getStyleWithVendor(style: CSSProperties): CSSProperties;
10
+ export declare function setStyleWithVendor(dom: HTMLElement, style: CSSProperties): void;
10
11
  /**
11
12
  * 计算默认值,仅未定义时使用默认值
12
13
  * @desc {en} Calculate the default value, use default value only if undefined
@@ -5,10 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  var _exportNames = {
7
7
  getStyleWithVendor: true,
8
+ setStyleWithVendor: true,
8
9
  getDefaultValue: true
9
10
  };
10
11
  exports.getDefaultValue = void 0;
11
12
  exports.getStyleWithVendor = getStyleWithVendor;
13
+ exports.setStyleWithVendor = setStyleWithVendor;
12
14
 
13
15
  var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
16
 
@@ -55,6 +57,14 @@ function getStyleWithVendor(style) {
55
57
  }, {});
56
58
  return newStyle;
57
59
  }
60
+
61
+ function setStyleWithVendor(dom, style) {
62
+ var vendorStyle = getStyleWithVendor(style);
63
+
64
+ for (var key in vendorStyle) {
65
+ dom.style[key] = vendorStyle[key];
66
+ }
67
+ }
58
68
  /**
59
69
  * 计算默认值,仅未定义时使用默认值
60
70
  * @desc {en} Calculate the default value, use default value only if undefined
@@ -9,7 +9,7 @@ export interface IndexBarBaseData {
9
9
  */
10
10
  content: ReactNode;
11
11
  }
12
- interface IndexBarGroupItem<Data extends IndexBarBaseData> {
12
+ interface IndexBarGroupItem<Data extends IndexBarBaseData = IndexBarBaseData> {
13
13
  /**
14
14
  * IndexBarGroup对应的索引
15
15
  * @en Index corresponding to IndexBarGroup
@@ -39,7 +39,7 @@ export interface IndexBarSideBarProps {
39
39
  renderSideBar?: (Content: ReactNode) => ReactElement;
40
40
  renderTip?: (index: IndexBarIndexType) => ReactNode;
41
41
  }
42
- export interface IndexBarGroupProps<Data extends IndexBarBaseData> extends IndexBarGroupItem<Data> {
42
+ export interface IndexBarGroupProps<Data extends IndexBarBaseData = IndexBarBaseData> extends IndexBarGroupItem<Data> {
43
43
  /**
44
44
  * 自定义类名
45
45
  * @en Custom classname
@@ -78,7 +78,7 @@ export interface IndexBarGroupProps<Data extends IndexBarBaseData> extends Index
78
78
  }
79
79
  export interface IndexBarGroupRef extends BaseRef {
80
80
  }
81
- export interface IndexBarProps<Data extends IndexBarBaseData> {
81
+ export interface IndexBarProps<Data extends IndexBarBaseData = IndexBarBaseData> {
82
82
  /**
83
83
  * 自定义类名
84
84
  * @en Custom classname
@@ -75,11 +75,14 @@ var LoadMore = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
75
75
 
76
76
  changeStatus('loading', scene);
77
77
  getData == null ? void 0 : getData(function (st) {
78
- lastScrollEndRef.current = false;
79
78
  changeStatus(st, 'manual');
80
79
  });
81
80
  }, [blockWhenLoading, changeStatus, getData]);
82
81
  (0, _react.useEffect)(function () {
82
+ if (!blockWhenLoading || nowStatus !== 'loading') {
83
+ lastScrollEndRef.current = false;
84
+ }
85
+
83
86
  statusRef.current = nowStatus;
84
87
  }, [nowStatus]);
85
88
  (0, _helpers.useUpdateEffect)(function () {
@@ -146,7 +146,7 @@ var NavBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
146
146
  ref: navBarRef,
147
147
  className: (0, _mobileUtils.cls)(wrapClass, prefixCls + "-nav-bar", (_cls = {}, _cls[prefixCls + "-nav-bar-fixed"] = fixed, _cls[prefixCls + "-nav-bar-float"] = !placeholder, _cls[prefixCls + "-nav-bar-hide"] = scrollToggleHide, _cls)),
148
148
  style: (0, _extends2.default)({
149
- paddingTop: fixed && statusBarHeight ? statusBarHeight + "px" : ''
149
+ paddingTop: fixed && statusBarHeight ? statusBarHeight + "px" : '0px'
150
150
  }, style || {}, relBackground ? {
151
151
  background: relBackground
152
152
  } : {}),
@@ -155,7 +155,7 @@ var NavBar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
155
155
  }, /*#__PURE__*/_react.default.createElement("div", {
156
156
  className: (0, _mobileUtils.cls)(className, system, prefixCls + "-nav-bar-wrapper", (_cls2 = {}, _cls2[prefixCls + "-nav-bar-wrapper-fixed"] = fixed, _cls2[prefixCls + "-nav-bar-wrapper-border"] = hasBottomLine, _cls2)),
157
157
  style: (0, _extends2.default)({
158
- paddingTop: statusBarHeight ? statusBarHeight + "px" : ''
158
+ paddingTop: statusBarHeight ? statusBarHeight + "px" : '0px'
159
159
  }, customStyle)
160
160
  }, /*#__PURE__*/_react.default.createElement("div", {
161
161
  className: prefixCls + "-nav-bar-inner all-border-box"
@@ -31,6 +31,18 @@ var wrapperNodeList = [];
31
31
 
32
32
  var listeners = {};
33
33
  var onOnceEmittedListeners = {};
34
+ /**
35
+ * Intersection Observer 同一 root 节点下的监听队列
36
+ * @en Intersection Observer Listening queue under the same root node
37
+ */
38
+
39
+ var ioListeners = [];
40
+ /**
41
+ * Intersection Observer 监听 visible 状态队列
42
+ * @en Intersection Observer listens to the visible status queue
43
+ */
44
+
45
+ var ioVisibleList = [];
34
46
  var throttlingVisibleChange;
35
47
  /**
36
48
  * 通过滚动事件监测 children 是否进入视口或离开视口。
@@ -78,12 +90,6 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
78
90
  */
79
91
 
80
92
  var domRefParent = (0, _react.useRef)(null);
81
- /**
82
- * 当前元素是否在可视区域内
83
- * @en Whether the current element is in the visible area
84
- */
85
-
86
- var isVisible = (0, _react.useRef)(false);
87
93
  /**
88
94
  * 保存当前节点信息,类似于 class component 中 this
89
95
  * @en Save current node information, similar to this in class component
@@ -130,10 +136,8 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
130
136
  * @en Reset the initial visible state of the element to false, and re-detect the visibility of the element, the priority is lower than 'disabled'(Usually used to re-listen when elements inside ShowMonitor change)
131
137
  */
132
138
  flushVisibleStatus: function flushVisibleStatus() {
133
- isVisible.current = false;
134
-
135
- if (isSupportNativeApi && io.current && domRef.current) {
136
- disabled ? io.current.unobserve(domRef.current) : io.current.observe(domRef.current);
139
+ if (isSupportNativeApi) {
140
+ disabled ? ioUnobserve() : ioObserve();
137
141
  } else if (listener.current) {
138
142
  var _key = wrapperKey.current;
139
143
 
@@ -197,7 +201,7 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
197
201
  */
198
202
 
199
203
 
200
- curVisible !== preVisible.current && handleCheckChildrenExist() && onCompVisibleChange(curVisible, node);
204
+ curVisible !== preVisible && handleCheckChildrenExist() && onCompVisibleChange(curVisible, node);
201
205
  var key = wrapperKey.current;
202
206
  /**
203
207
  * 监听一次后加入 pendingList 队列,随后被 listeners 过滤掉
@@ -213,8 +217,7 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
213
217
  */
214
218
 
215
219
 
216
- curVisible && !preVisible.current && compOnce && onOnceEmittedListeners[key].push(component);
217
- preVisible.current = curVisible;
220
+ curVisible && !preVisible && compOnce && onOnceEmittedListeners[key].push(component);
218
221
  }
219
222
 
220
223
  var checkVisibleHandler = (0, _react.useCallback)(function () {
@@ -234,22 +237,98 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
234
237
  }
235
238
 
236
239
  function handleObserverStatusChange(entries) {
237
- var _io$current;
240
+ entries.forEach(function (entry) {
241
+ var isIntersecting = entry.isIntersecting,
242
+ target = entry.target;
243
+ var visibleItem = ioVisibleList.find(function (item) {
244
+ return item.node === target;
245
+ });
238
246
 
239
- var isIntersecting = entries[0].isIntersecting;
240
- /**
241
- * 当前元素 visible 对比之前发生改变,触发回调函数
242
- * @en Callback when the visible status of current element changes before the comparison
243
- */
247
+ if (visibleItem) {
248
+ var curVisible = visibleItem.isVisible,
249
+ onCompVisibleChange = visibleItem.onVisibleChange,
250
+ onceEmit = visibleItem.once;
251
+ /**
252
+ * 当前元素 visible 对比之前发生改变,触发回调函数
253
+ * @en Callback when the visible status of current element changes before the comparison
254
+ */
255
+
256
+ isIntersecting !== curVisible && handleCheckChildrenExist() && onCompVisibleChange(isIntersecting, target);
257
+ /**
258
+ * 当前元素状态由不可见变为可见,且只触发一次
259
+ * @en The current element is invisible -> visible, and once, triggers the callback
260
+ */
261
+
262
+ isIntersecting && !curVisible && onceEmit && target && ioUnobserve(target);
263
+ visibleItem.isVisible = isIntersecting;
264
+ }
265
+ });
266
+ }
267
+ /**
268
+ * 获取 io 单例
269
+ * @en Get the io singleton
270
+ */
244
271
 
245
- isIntersecting !== isVisible.current && handleCheckChildrenExist() && onVisibleChange(isIntersecting, domRef.current);
246
- /**
247
- * 当前元素不可见 -> 可见,且 once, 触发回调函数
248
- * @en The current element is invisible -> visible, and once, triggers the callback
249
- */
250
272
 
251
- isIntersecting && !isVisible.current && once && domRef.current && ((_io$current = io.current) == null ? void 0 : _io$current.unobserve(domRef.current));
252
- isVisible.current = isIntersecting;
273
+ function getIOSingleton(ioOptions) {
274
+ var root = ioOptions.root,
275
+ rootMargin = ioOptions.rootMargin,
276
+ ioThreshold = ioOptions.threshold;
277
+ var ioKey = JSON.stringify({
278
+ rootMargin: rootMargin,
279
+ threshold: ioThreshold
280
+ });
281
+
282
+ var _ioListener = ioListeners.find(function (ioListener) {
283
+ return ioListener.root === root && ioListener.key === ioKey;
284
+ });
285
+
286
+ if (!_ioListener) {
287
+ ioListeners.push({
288
+ root: root,
289
+ key: ioKey,
290
+ listener: io.current = new IntersectionObserver(handleObserverStatusChange, ioOptions)
291
+ });
292
+ } else {
293
+ io.current = _ioListener.listener;
294
+ }
295
+ }
296
+
297
+ function ioObserve() {
298
+ if (domRef.current && io.current) {
299
+ var curIdx = ioVisibleList.findIndex(function (ioVisibleItem) {
300
+ return ioVisibleItem.node === domRef.current;
301
+ });
302
+
303
+ if (curIdx !== -1) {
304
+ ioVisibleList[curIdx].isVisible = false;
305
+ } else {
306
+ ioVisibleList.push({
307
+ node: domRef.current,
308
+ isVisible: false,
309
+ once: once,
310
+ onVisibleChange: onVisibleChange
311
+ });
312
+ }
313
+
314
+ io.current.observe(domRef.current);
315
+ }
316
+ }
317
+
318
+ function ioUnobserve(target) {
319
+ var targetNode = target || domRef.current;
320
+
321
+ if (io.current && targetNode) {
322
+ var curIdx = ioVisibleList.findIndex(function (ioVisibleItem) {
323
+ return ioVisibleItem.node === targetNode;
324
+ });
325
+
326
+ if (curIdx !== -1) {
327
+ ioVisibleList.splice(curIdx, 1);
328
+ }
329
+
330
+ io.current.unobserve(targetNode);
331
+ }
253
332
  }
254
333
  /**
255
334
  * 非首次下disabled变化时,重新监听元素
@@ -259,14 +338,11 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
259
338
 
260
339
  (0, _react.useEffect)(function () {
261
340
  if (isSupportNativeApi) {
262
- // 非首次下
341
+ // 非首次 render 下
263
342
  // @en Not for the first time
264
- if (io.current && domRef.current) {
265
- // 禁用监听 || 监听
266
- disabled ? io.current.unobserve(domRef.current) : io.current.observe(domRef.current);
267
- }
343
+ disabled ? ioUnobserve() : ioObserve();
268
344
  } else {
269
- // 非首次下
345
+ // 非首次 render 下
270
346
  // @en Not for the first time
271
347
  if (wrapperKey.current !== -1 && listener.current && listeners[wrapperKey.current]) {
272
348
  // 禁用监听,找到对应listener并删除
@@ -330,12 +406,12 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
330
406
  rootMargin = offset + "px";
331
407
  }
332
408
 
333
- io.current = new IntersectionObserver(handleObserverStatusChange, {
409
+ getIOSingleton({
334
410
  root: root,
335
411
  rootMargin: rootMargin,
336
412
  threshold: threshold
337
413
  });
338
- !disabled && io.current.observe(domRef.current);
414
+ !disabled && ioObserve();
339
415
  }
340
416
  } else {
341
417
  // 节流后回调函数
@@ -379,7 +455,7 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
379
455
 
380
456
  listener.current = {
381
457
  node: domRef.current,
382
- isVisible: isVisible,
458
+ isVisible: false,
383
459
  overflow: overflow,
384
460
  once: once,
385
461
  offset: offset,
@@ -396,9 +472,7 @@ var ShowMonitor = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
396
472
  (0, _react.useEffect)(function () {
397
473
  return function () {
398
474
  if (isSupportNativeApi) {
399
- var _io$current2;
400
-
401
- domRef.current && ((_io$current2 = io.current) == null ? void 0 : _io$current2.unobserve(domRef.current));
475
+ ioUnobserve();
402
476
  } else {
403
477
  if (overflow) {
404
478
  var parent = domRefParent.current;
@@ -2,6 +2,9 @@
2
2
  width: 100%;
3
3
  background: #e5e6eb ;
4
4
  }
5
+ #demo-swipe-load .list-container::-webkit-scrollbar {
6
+ display: none;
7
+ }
5
8
  #demo-swipe-load .course-list {
6
9
  display: -webkit-inline-box;
7
10
  display: -webkit-inline-flex;
@@ -4,36 +4,47 @@
4
4
  .list-container {
5
5
  width: 100%;
6
6
  .use-var(background, line-color);
7
+
8
+ &::-webkit-scrollbar {
9
+ display: none;
10
+ }
7
11
  }
12
+
8
13
  .course-list {
9
14
  display: inline-flex;
10
15
  align-items: flex-start;
11
16
  padding: 12px 0;
12
17
  }
18
+
13
19
  .list-item,
14
20
  .list-item-color {
15
21
  height: 72px;
16
22
  margin-right: 10px;
17
23
  .use-var(background, background-color);
18
24
  }
25
+
19
26
  .list-item-color {
20
27
  .use-var(background, primary-disabled-color);
21
28
  }
29
+
22
30
  .mylabel-start,
23
31
  .mylabel-end {
24
32
  width: 100px;
25
33
  height: 96px;
26
34
  transition: background 0.2s;
27
35
  .use-var(background, background-color);
36
+
28
37
  &.end {
29
38
  .use-var(background, line-color);
30
39
  }
31
40
  }
41
+
32
42
  .mylabel-single {
33
43
  width: 100px;
34
44
  height: 88px;
35
45
  .use-var(background, primary-disabled-color);
36
46
  }
47
+
37
48
  .single-element {
38
49
  height: 88px;
39
50
  .use-var(background, primary-disabled-color);
@@ -10,6 +10,8 @@ var _mobileUtils = require("@arco-design/mobile-utils");
10
10
 
11
11
  var _contextProvider = require("../context-provider");
12
12
 
13
+ var _helpers = require("../_helpers");
14
+
13
15
  var _hooks = require("../_helpers/hooks");
14
16
 
15
17
  var _type = require("./type");
@@ -57,7 +59,22 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
57
59
  _props$activeText = props.activeText,
58
60
  activeText = _props$activeText === void 0 ? '' : _props$activeText,
59
61
  _props$initPos = props.initPos,
60
- initPos = _props$initPos === void 0 ? 0 : _props$initPos;
62
+ initPos = _props$initPos === void 0 ? 0 : _props$initPos,
63
+ _props$bounceWhenBump = props.bounceWhenBumpBoundary,
64
+ bounceWhenBumpBoundary = _props$bounceWhenBump === void 0 ? false : _props$bounceWhenBump,
65
+ _props$bounceDampRate = props.bounceDampRate,
66
+ bounceDampRate = _props$bounceDampRate === void 0 ? 3 : _props$bounceDampRate,
67
+ _props$bounceAnimateD = props.bounceAnimateDuration,
68
+ bounceAnimateDuration = _props$bounceAnimateD === void 0 ? 300 : _props$bounceAnimateD,
69
+ damping = props.damping,
70
+ bounceDistanceProcessor = props.bounceDistanceProcessor,
71
+ getScrollContainer = props.getScrollContainer,
72
+ getBounceContainer = props.getBounceContainer,
73
+ onTouchStart = props.onTouchStart,
74
+ onTouchEnd = props.onTouchEnd,
75
+ onTouchCancel = props.onTouchCancel,
76
+ onTouchMove = props.onTouchMove,
77
+ renderLabel = props.renderLabel;
61
78
 
62
79
  var _useContext = (0, _react.useContext)(_contextProvider.GlobalContext),
63
80
  _useContext$locale = _useContext.locale,
@@ -76,13 +93,14 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
76
93
  var loadingLabelRef = (0, _react.useRef)(null);
77
94
  var showLoadMoreRef = (0, _react.useRef)(false);
78
95
  var ifToRightRef = (0, _react.useRef)(false);
96
+ var bouncingRef = (0, _react.useRef)(false);
79
97
  var offsetRef = (0, _react.useRef)(0);
80
98
  var domRef = (0, _react.useRef)(null);
81
99
  var wrapperEl = domRef.current;
82
- (0, _hooks.useAddListener)(wrapperEl, 'touchstart', props.onTouchStart);
83
- (0, _hooks.useAddListener)(wrapperEl, 'touchend', props.onTouchEnd);
84
- (0, _hooks.useAddListener)(wrapperEl, 'touchcancel', props.onTouchCancel);
85
- (0, _hooks.useAddListener)(wrapperEl, 'touchmove', props.onTouchMove);
100
+ (0, _hooks.useAddListener)(wrapperEl, 'touchstart', onTouchStart);
101
+ (0, _hooks.useAddListener)(wrapperEl, 'touchend', onTouchEnd);
102
+ (0, _hooks.useAddListener)(wrapperEl, 'touchcancel', onTouchCancel);
103
+ (0, _hooks.useAddListener)(wrapperEl, 'touchmove', onTouchMove);
86
104
  (0, _react.useEffect)(function () {
87
105
  if (disabled || !containerRef.current || disableState) {
88
106
  return;
@@ -96,13 +114,11 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
96
114
  // @en If no child element is passed in, component will be disabled
97
115
  setDisableState(true);
98
116
  } else if (containerRef.current.childNodes.length === 1) {
117
+ var _getScrollContainer;
118
+
99
119
  // 传入一个子元素 滑动单个元素
100
120
  // @en Pass in a child element swipe the single element
101
- if (props.getScrollContainer) {
102
- scrollContainer = props.getScrollContainer();
103
- } else {
104
- scrollContainer = containerRef.current.firstChild;
105
- }
121
+ scrollContainer = (_getScrollContainer = getScrollContainer == null ? void 0 : getScrollContainer()) != null ? _getScrollContainer : containerRef.current.firstChild;
106
122
  } else {
107
123
  // 传入多个子元素(列表元素为例) 组件控制自行滑动 不推荐
108
124
  // @en Pass in multiple sub-elements (list elements as an example) Component control slides by itself which is not recommended
@@ -122,17 +138,20 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
122
138
 
123
139
  if (!loadingCurrent) {
124
140
  return;
125
- } // 初始不显示标签
126
- // @en Initially no labels are displayed
141
+ }
127
142
 
143
+ var bounceScrollContainer = (getBounceContainer == null ? void 0 : getBounceContainer()) || scrollContainer; // 初始不显示标签
144
+ // @en Initially no labels are displayed
128
145
 
129
146
  loadingCurrent.style.display = 'none';
130
147
  var startX = 0;
131
- var endX = 0; // 触摸页面确定X起始坐标
148
+ var endX = 0;
149
+ var bounceDistance = 0; // 触摸页面确定X起始坐标
132
150
  // @en Determine the X starting coordinate on touchstart
133
151
 
134
152
  var touchstart = function touchstart(e) {
135
- startX = e.touches[0].pageX;
153
+ var evt = e.touches[0];
154
+ startX = evt.clientX || 0;
136
155
  }; // 页面滑动确定X终止坐标,更新手指的X坐标,改变loading中的文字和大小
137
156
  // @en Determine the X end coordinate, update the X coordinate of the finger, change the text and size in the loading on touchmove
138
157
 
@@ -144,12 +163,30 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
144
163
  scrollContainer.scrollLeft = 1;
145
164
  }
146
165
 
147
- endX = e.touches[0].pageX;
166
+ endX = e.touches[0].clientX || 0;
148
167
  var diff = endX - startX;
149
168
  offsetRef.current = diff;
150
- var labelDiff = (0, _mobileUtils.fingerDisToLabelDis)(Math.abs(diff), props.damping); // 向左滑动到尽头 '更多'标签加载 根据scrollLeft判断 滚动容器到达边缘触发 非滚动容器不判断
169
+ var labelDiff = (0, _mobileUtils.fingerDisToLabelDis)(Math.abs(diff), damping); // 滑动到最左侧,处理回弹效果
170
+ // @en Swipe to the far left to handle the rebound effect
171
+
172
+ if (diff > 0 && scrollContainer.scrollLeft <= 1 && bounceWhenBumpBoundary) {
173
+ e.stopPropagation();
174
+ e.cancelBubble && e.preventDefault();
175
+ bouncingRef.current = true;
176
+
177
+ var processor = bounceDistanceProcessor || function (dis) {
178
+ return Math.min(dis, bounceScrollContainer.offsetWidth) / bounceDampRate;
179
+ };
180
+
181
+ bounceDistance = processor(diff);
182
+ (0, _helpers.setStyleWithVendor)(bounceScrollContainer, {
183
+ transition: 'none',
184
+ transform: "translateX(" + bounceDistance + "px) translateZ(0)"
185
+ });
186
+ } // 向左滑动到尽头 '更多'标签加载 根据scrollLeft判断 滚动容器到达边缘触发 非滚动容器不判断
151
187
  // @en Swipe left to the end and the 'more' label is loaded. Judging by scrollLeft, the scroll container reaches the edge and the non-scroll container does not judge
152
188
 
189
+
153
190
  if (diff < 0 && (scrollContainer.scrollLeft + scrollContainer.clientWidth >= scrollContainer.scrollWidth - 1 || !scrollContainer.scrollLeft) && !ifToRightRef.current) {
154
191
  showLoadMoreRef.current = true;
155
192
  loadingCurrent.style.display = 'flex';
@@ -175,12 +212,14 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
175
212
  loadingLabelCurrent.innerHTML = labelDiff >= minConfirmOffset ? activeText || locale.SwipeLoad.activeText : normalText || locale.SwipeLoad.normalText;
176
213
  }
177
214
 
178
- loadingCurrent.style.transition = 'all 0.02s';
179
- loadingCurrent.style.webkitTransform = "translateX(-" + labelRightMargin + "px)";
180
- loadingCurrent.style.transform = "translateX(-" + labelRightMargin + "px)";
181
- scrollContainer.style.transition = 'all 0.03s';
182
- scrollContainer.style.webkitTransform = "translateX(-" + listRightMargin + "px)";
183
- scrollContainer.style.transform = "translateX(-" + listRightMargin + "px)";
215
+ (0, _helpers.setStyleWithVendor)(loadingCurrent, {
216
+ transition: 'none',
217
+ transform: "translateX(-" + labelRightMargin + "px) translateZ(0)"
218
+ });
219
+ (0, _helpers.setStyleWithVendor)(scrollContainer, {
220
+ transition: 'none',
221
+ transform: "translateX(-" + listRightMargin + "px) translateZ(0)"
222
+ });
184
223
  }
185
224
 
186
225
  if (diff > 0 && scrollContainer.scrollLeft + scrollContainer.clientWidth <= scrollContainer.scrollWidth - 1) {
@@ -205,13 +244,28 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
205
244
  var labelDiff = (0, _mobileUtils.fingerDisToLabelDis)(Math.abs(diff));
206
245
 
207
246
  var resumeAnimation = function resumeAnimation() {
208
- scrollContainer.style.transition = "all " + labelAnimationDuration + "ms " + labelAnimationFunction;
209
- scrollContainer.style.webkitTransform = 'translateX(0px)';
210
- scrollContainer.style.transform = 'translateX(0px)';
211
- loadingCurrent.style.transition = "all " + labelAnimationDuration + "ms " + labelAnimationFunction;
212
- loadingCurrent.style.webkitTransform = 'translateX(0px)';
213
- loadingCurrent.style.transform = 'translateX(0px)';
214
- showLoadMoreRef.current = false;
247
+ if (showLoadMoreRef.current) {
248
+ showLoadMoreRef.current = false;
249
+ var scrollTransitionCssStyle = "all " + labelAnimationDuration + "ms " + labelAnimationFunction;
250
+ var scrollTransformCssStyle = 'translateX(0px) translateZ(0)';
251
+ (0, _helpers.setStyleWithVendor)(scrollContainer, {
252
+ transition: scrollTransitionCssStyle,
253
+ transform: scrollTransformCssStyle
254
+ });
255
+ (0, _helpers.setStyleWithVendor)(loadingCurrent, {
256
+ transition: scrollTransitionCssStyle,
257
+ transform: scrollTransformCssStyle
258
+ });
259
+ }
260
+
261
+ if (bouncingRef.current) {
262
+ bouncingRef.current = false;
263
+ (0, _helpers.setStyleWithVendor)(bounceScrollContainer, {
264
+ transition: "all " + bounceAnimateDuration + "ms",
265
+ transform: 'translateX(0px) translateZ(0)'
266
+ });
267
+ }
268
+
215
269
  ifToRightRef.current = false;
216
270
  setTimeout(function () {
217
271
  loadingCurrent.style.display = 'none';
@@ -241,7 +295,7 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
241
295
  scrollContainer.removeEventListener('touchmove', touchmove);
242
296
  scrollContainer.removeEventListener('touchend', touchend);
243
297
  };
244
- }, [disabled]);
298
+ }, [disabled, getScrollContainer, getBounceContainer, bounceWhenBumpBoundary, bounceDampRate, bounceAnimateDuration]);
245
299
  (0, _react.useImperativeHandle)(ref, function () {
246
300
  return {
247
301
  dom: domRef.current
@@ -255,14 +309,14 @@ var SwipeLoad = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
255
309
  }, /*#__PURE__*/_react.default.createElement("div", {
256
310
  className: (0, _mobileUtils.cls)(prefixCls + "-list-area"),
257
311
  ref: containerRef
258
- }, children), props.renderLabel ? /*#__PURE__*/_react.default.createElement("div", {
312
+ }, children), renderLabel ? /*#__PURE__*/_react.default.createElement("div", {
259
313
  className: (0, _mobileUtils.cls)(prefixCls + "-custom-loading-area"),
260
314
  ref: loadingRef,
261
315
  style: {
262
316
  position: 'absolute',
263
317
  right: initPos + "px"
264
318
  }
265
- }, props.renderLabel.length ? props.renderLabel(labelOffsetState) : props.renderLabel()) : /*#__PURE__*/_react.default.createElement("div", {
319
+ }, renderLabel.length ? renderLabel(labelOffsetState) : renderLabel()) : /*#__PURE__*/_react.default.createElement("div", {
266
320
  className: (0, _mobileUtils.cls)(prefixCls + "-loading-area"),
267
321
  ref: loadingRef,
268
322
  style: {
@@ -9,6 +9,9 @@
9
9
  position: relative;
10
10
  width: 100%;
11
11
  }
12
+ .arco-swipe-load .arco-list-area::-webkit-scrollbar {
13
+ display: none;
14
+ }
12
15
  .arco-swipe-load .arco-loading-area {
13
16
  background-color: #f8f8f8 ;
14
17
  margin-top: 0;