@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
@@ -34,6 +34,7 @@ var TabPane = /*#__PURE__*/forwardRef(function (props, ref) {
34
34
  translateZ = props.translateZ,
35
35
  fullScreen = props.fullScreen,
36
36
  autoHeight = props.autoHeight,
37
+ swipeEnergySaving = props.swipeEnergySaving,
37
38
  changeIndex = props.changeIndex,
38
39
  onScroll = props.onScroll;
39
40
  var domRef = useRef(null);
@@ -45,12 +46,16 @@ var TabPane = /*#__PURE__*/forwardRef(function (props, ref) {
45
46
  shownIndexes = _useState[0],
46
47
  setShownIndexes = _useState[1];
47
48
 
49
+ var _useState2 = useState(activeIndex),
50
+ shownActiveIndex = _useState2[0],
51
+ setShownActiveIndex = _useState2[1];
52
+
48
53
  var prefix = prefixCls + "-tab-pane";
49
54
  var handleTouchEnd = swipeable ? handlePaneTouchEnd : void 0;
50
55
 
51
- var _useState2 = useState('auto'),
52
- currentPaneHeight = _useState2[0],
53
- setCurrentPaneHeight = _useState2[1];
56
+ var _useState3 = useState('auto'),
57
+ currentPaneHeight = _useState3[0],
58
+ setCurrentPaneHeight = _useState3[1];
54
59
 
55
60
  useImperativeHandle(ref, function () {
56
61
  return {
@@ -136,6 +141,8 @@ var TabPane = /*#__PURE__*/forwardRef(function (props, ref) {
136
141
  }
137
142
 
138
143
  function calcShownIndexes() {
144
+ setShownActiveIndex(activeIndex);
145
+
139
146
  if (typeof lazyloadCount === 'number') {
140
147
  setShownIndexes([activeIndex - lazyloadCount, activeIndex + lazyloadCount]);
141
148
  return;
@@ -236,11 +243,35 @@ var TabPane = /*#__PURE__*/forwardRef(function (props, ref) {
236
243
  var heightStyle = currentPaneHeight && currentPaneHeight !== 'auto' ? {
237
244
  height: currentPaneHeight
238
245
  } : {};
239
- return getStyleWithVendor(_extends({}, sizeStyle, {
246
+ return getStyleWithVendor(_extends({}, swipeEnergySaving ? {} : sizeStyle, {
240
247
  transitionDuration: getTransition() + "ms"
241
248
  }, heightStyle, commonStyle));
242
249
  }
243
250
 
251
+ function getEnergySavingPaneStyle(index) {
252
+ if (mode === 'scroll' || !swipeEnergySaving) {
253
+ return undefined;
254
+ }
255
+
256
+ if (index !== shownActiveIndex) {
257
+ return {
258
+ position: 'absolute',
259
+ left: '-100%',
260
+ top: '-100%'
261
+ };
262
+ }
263
+
264
+ var translateStr = translateZ ? ' translateZ(0)' : '';
265
+ var sizeStyle = tabDirection === 'vertical' ? {
266
+ transform: "translateX(" + (distance - wrapWidth * (activeIndex - index)) + "px)" + translateStr
267
+ } : {
268
+ transform: "translateY(" + (distance - wrapHeight * (activeIndex - index)) + "px)" + translateStr
269
+ };
270
+ return getStyleWithVendor(_extends({}, sizeStyle, {
271
+ transitionDuration: getTransition() + "ms"
272
+ }));
273
+ }
274
+
244
275
  function renderContent(pane, index) {
245
276
  var contentProps = {
246
277
  key: index,
@@ -250,32 +281,39 @@ var TabPane = /*#__PURE__*/forwardRef(function (props, ref) {
250
281
  ref: function ref(r) {
251
282
  return panesRef.current[index] = r;
252
283
  }
253
- }; // 是滚动模式或在加载范围内,直接渲染
284
+ };
285
+ var energySavingStyle = getEnergySavingPaneStyle(index); // 是滚动模式或在加载范围内,直接渲染
254
286
  // @en Render directly when in scroll mode or in loading scope
255
287
 
256
288
  if (mode === 'scroll' || index >= shownIndexes[0] && index <= shownIndexes[1]) {
257
- return /*#__PURE__*/React.createElement("div", contentProps, pane);
258
- } // 不在加载范围内,视renderHideContent和hideContentStyle情况而定
289
+ return /*#__PURE__*/React.createElement("div", _extends({}, contentProps, {
290
+ style: energySavingStyle
291
+ }), pane);
292
+ }
293
+
294
+ var energySavingHideStyle = _extends({}, energySavingStyle, hideContentStyle || {}); // 不在加载范围内,视renderHideContent和hideContentStyle情况而定
259
295
  // @en Not in the loading range, depending on renderHideContent and hideContentStyle
260
296
 
261
297
 
262
298
  if (renderHideContent) {
263
299
  return /*#__PURE__*/React.createElement("div", _extends({}, contentProps, {
264
- style: hideContentStyle || {}
300
+ style: energySavingHideStyle
265
301
  }), renderHideContent(index, pane));
266
302
  }
267
303
 
268
304
  if (hideContentStyle === null) {
269
- return /*#__PURE__*/React.createElement("div", contentProps);
305
+ return /*#__PURE__*/React.createElement("div", _extends({}, contentProps, {
306
+ style: energySavingStyle
307
+ }));
270
308
  }
271
309
 
272
310
  return /*#__PURE__*/React.createElement("div", _extends({}, contentProps, {
273
- style: hideContentStyle
311
+ style: energySavingHideStyle
274
312
  }), pane);
275
313
  }
276
314
 
277
315
  return /*#__PURE__*/React.createElement("div", {
278
- className: cls(prefix + "-container", tabDirection, "mode-" + mode, tabPaneClass, {
316
+ className: cls(prefix + "-container", tabDirection, swipeEnergySaving ? "mode-" + mode + "-energy-saving" : "mode-" + mode, tabPaneClass, {
279
317
  'full-screen': fullScreen
280
318
  }, (_cls = {}, _cls["mode-scroll-" + (scrollVertical ? 'vertical' : 'horizontal')] = mode === 'scroll', _cls)),
281
319
  style: getPaneStyle(),
@@ -322,6 +322,12 @@ export interface TabsProps {
322
322
  * @default true
323
323
  */
324
324
  translateZ?: boolean;
325
+ /**
326
+ * 是否启用滑动节能模式,开启后TabPane外层容器不会随panes数量撑开并提升为合成层,仅滑动当前选中的pane,其他pane在选中前将被隐藏
327
+ * @en Whether to enable the energy-saving sliding mode. After opening, the outer container of the TabPane will not expand with the number of panes and be promoted to a composite layer. Only the currently selected pane will be slid, and other panes will be hidden before being selected.
328
+ * @default false
329
+ */
330
+ swipeEnergySaving?: boolean;
325
331
  /**
326
332
  * 当滑到第一页或最后一页,还想再滑动时触发
327
333
  * @en Triggered when swiping to the first or last page and want to swipe again
@@ -560,7 +566,7 @@ export interface TabCellRef {
560
566
  */
561
567
  resetUnderlineStyle: () => void;
562
568
  }
563
- export interface TabPaneProps extends Pick<TabsProps, 'duration' | 'transitionDuration' | 'lazyloadCount' | 'hideContentStyle' | 'renderHideContent' | 'mode' | 'tabPaneClass' | 'tabPaneStyle' | 'tabPaneExtra' | 'getScrollContainer' | 'scrollThrottle' | 'scrollOffset' | 'goLastWhenScrollBottom' | 'scrollVertical' | 'translateZ' | 'fullScreen' | 'autoHeight' | 'onScroll'> {
569
+ export interface TabPaneProps extends Pick<TabsProps, 'duration' | 'transitionDuration' | 'lazyloadCount' | 'hideContentStyle' | 'renderHideContent' | 'mode' | 'tabPaneClass' | 'tabPaneStyle' | 'tabPaneExtra' | 'getScrollContainer' | 'scrollThrottle' | 'scrollOffset' | 'goLastWhenScrollBottom' | 'scrollVertical' | 'translateZ' | 'fullScreen' | 'autoHeight' | 'onScroll' | 'swipeEnergySaving'> {
564
570
  prefixCls?: string;
565
571
  panes: ReactNodeArray;
566
572
  activeIndex: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.27.1",
3
+ "version": "2.27.3",
4
4
  "description": "",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -15,7 +15,7 @@
15
15
  "author": "taoyiyue@bytedance.com",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@arco-design/mobile-utils": "2.15.1",
18
+ "@arco-design/mobile-utils": "2.15.3",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "lodash.throttle": "^4.1.1",
21
21
  "resize-observer-polyfill": "^1.5.1"
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "9c06acb2cc9341ee12843d1720e9b796cbbc2ac5"
38
+ "gitHead": "0898d28c77d803b648e4c4e48ac7c9969ad161f0"
39
39
  }
@@ -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
@@ -18,10 +18,12 @@
18
18
  _exports.__esModule = true;
19
19
  var _exportNames = {
20
20
  getStyleWithVendor: true,
21
+ setStyleWithVendor: true,
21
22
  getDefaultValue: true
22
23
  };
23
24
  _exports.getDefaultValue = void 0;
24
25
  _exports.getStyleWithVendor = getStyleWithVendor;
26
+ _exports.setStyleWithVendor = setStyleWithVendor;
25
27
  _extends3 = _interopRequireDefault(_extends3);
26
28
  Object.keys(_hooks).forEach(function (key) {
27
29
  if (key === "default" || key === "__esModule") return;
@@ -58,6 +60,14 @@
58
60
  }, {});
59
61
  return newStyle;
60
62
  }
63
+
64
+ function setStyleWithVendor(dom, style) {
65
+ var vendorStyle = getStyleWithVendor(style);
66
+
67
+ for (var key in vendorStyle) {
68
+ dom.style[key] = vendorStyle[key];
69
+ }
70
+ }
61
71
  /**
62
72
  * 计算默认值,仅未定义时使用默认值
63
73
  * @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
@@ -80,11 +80,14 @@
80
80
 
81
81
  changeStatus('loading', scene);
82
82
  getData == null ? void 0 : getData(function (st) {
83
- lastScrollEndRef.current = false;
84
83
  changeStatus(st, 'manual');
85
84
  });
86
85
  }, [blockWhenLoading, changeStatus, getData]);
87
86
  (0, _react.useEffect)(function () {
87
+ if (!blockWhenLoading || nowStatus !== 'loading') {
88
+ lastScrollEndRef.current = false;
89
+ }
90
+
88
91
  statusRef.current = nowStatus;
89
92
  }, [nowStatus]);
90
93
  (0, _helpers.useUpdateEffect)(function () {
@@ -150,7 +150,7 @@
150
150
  ref: navBarRef,
151
151
  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)),
152
152
  style: (0, _extends2.default)({
153
- paddingTop: fixed && statusBarHeight ? statusBarHeight + "px" : ''
153
+ paddingTop: fixed && statusBarHeight ? statusBarHeight + "px" : '0px'
154
154
  }, style || {}, relBackground ? {
155
155
  background: relBackground
156
156
  } : {}),
@@ -159,7 +159,7 @@
159
159
  }, /*#__PURE__*/_react.default.createElement("div", {
160
160
  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)),
161
161
  style: (0, _extends2.default)({
162
- paddingTop: statusBarHeight ? statusBarHeight + "px" : ''
162
+ paddingTop: statusBarHeight ? statusBarHeight + "px" : '0px'
163
163
  }, customStyle)
164
164
  }, /*#__PURE__*/_react.default.createElement("div", {
165
165
  className: prefixCls + "-nav-bar-inner all-border-box"
@@ -38,6 +38,18 @@
38
38
 
39
39
  var listeners = {};
40
40
  var onOnceEmittedListeners = {};
41
+ /**
42
+ * Intersection Observer 同一 root 节点下的监听队列
43
+ * @en Intersection Observer Listening queue under the same root node
44
+ */
45
+
46
+ var ioListeners = [];
47
+ /**
48
+ * Intersection Observer 监听 visible 状态队列
49
+ * @en Intersection Observer listens to the visible status queue
50
+ */
51
+
52
+ var ioVisibleList = [];
41
53
  var throttlingVisibleChange;
42
54
  /**
43
55
  * 通过滚动事件监测 children 是否进入视口或离开视口。
@@ -85,12 +97,6 @@
85
97
  */
86
98
 
87
99
  var domRefParent = (0, _react.useRef)(null);
88
- /**
89
- * 当前元素是否在可视区域内
90
- * @en Whether the current element is in the visible area
91
- */
92
-
93
- var isVisible = (0, _react.useRef)(false);
94
100
  /**
95
101
  * 保存当前节点信息,类似于 class component 中 this
96
102
  * @en Save current node information, similar to this in class component
@@ -137,10 +143,8 @@
137
143
  * @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)
138
144
  */
139
145
  flushVisibleStatus: function flushVisibleStatus() {
140
- isVisible.current = false;
141
-
142
- if (isSupportNativeApi && io.current && domRef.current) {
143
- disabled ? io.current.unobserve(domRef.current) : io.current.observe(domRef.current);
146
+ if (isSupportNativeApi) {
147
+ disabled ? ioUnobserve() : ioObserve();
144
148
  } else if (listener.current) {
145
149
  var _key = wrapperKey.current;
146
150
 
@@ -204,7 +208,7 @@
204
208
  */
205
209
 
206
210
 
207
- curVisible !== preVisible.current && handleCheckChildrenExist() && onCompVisibleChange(curVisible, node);
211
+ curVisible !== preVisible && handleCheckChildrenExist() && onCompVisibleChange(curVisible, node);
208
212
  var key = wrapperKey.current;
209
213
  /**
210
214
  * 监听一次后加入 pendingList 队列,随后被 listeners 过滤掉
@@ -220,8 +224,7 @@
220
224
  */
221
225
 
222
226
 
223
- curVisible && !preVisible.current && compOnce && onOnceEmittedListeners[key].push(component);
224
- preVisible.current = curVisible;
227
+ curVisible && !preVisible && compOnce && onOnceEmittedListeners[key].push(component);
225
228
  }
226
229
 
227
230
  var checkVisibleHandler = (0, _react.useCallback)(function () {
@@ -241,22 +244,98 @@
241
244
  }
242
245
 
243
246
  function handleObserverStatusChange(entries) {
244
- var _io$current;
247
+ entries.forEach(function (entry) {
248
+ var isIntersecting = entry.isIntersecting,
249
+ target = entry.target;
250
+ var visibleItem = ioVisibleList.find(function (item) {
251
+ return item.node === target;
252
+ });
245
253
 
246
- var isIntersecting = entries[0].isIntersecting;
247
- /**
248
- * 当前元素 visible 对比之前发生改变,触发回调函数
249
- * @en Callback when the visible status of current element changes before the comparison
250
- */
254
+ if (visibleItem) {
255
+ var curVisible = visibleItem.isVisible,
256
+ onCompVisibleChange = visibleItem.onVisibleChange,
257
+ onceEmit = visibleItem.once;
258
+ /**
259
+ * 当前元素 visible 对比之前发生改变,触发回调函数
260
+ * @en Callback when the visible status of current element changes before the comparison
261
+ */
262
+
263
+ isIntersecting !== curVisible && handleCheckChildrenExist() && onCompVisibleChange(isIntersecting, target);
264
+ /**
265
+ * 当前元素状态由不可见变为可见,且只触发一次
266
+ * @en The current element is invisible -> visible, and once, triggers the callback
267
+ */
268
+
269
+ isIntersecting && !curVisible && onceEmit && target && ioUnobserve(target);
270
+ visibleItem.isVisible = isIntersecting;
271
+ }
272
+ });
273
+ }
274
+ /**
275
+ * 获取 io 单例
276
+ * @en Get the io singleton
277
+ */
251
278
 
252
- isIntersecting !== isVisible.current && handleCheckChildrenExist() && onVisibleChange(isIntersecting, domRef.current);
253
- /**
254
- * 当前元素不可见 -> 可见,且 once, 触发回调函数
255
- * @en The current element is invisible -> visible, and once, triggers the callback
256
- */
257
279
 
258
- isIntersecting && !isVisible.current && once && domRef.current && ((_io$current = io.current) == null ? void 0 : _io$current.unobserve(domRef.current));
259
- isVisible.current = isIntersecting;
280
+ function getIOSingleton(ioOptions) {
281
+ var root = ioOptions.root,
282
+ rootMargin = ioOptions.rootMargin,
283
+ ioThreshold = ioOptions.threshold;
284
+ var ioKey = JSON.stringify({
285
+ rootMargin: rootMargin,
286
+ threshold: ioThreshold
287
+ });
288
+
289
+ var _ioListener = ioListeners.find(function (ioListener) {
290
+ return ioListener.root === root && ioListener.key === ioKey;
291
+ });
292
+
293
+ if (!_ioListener) {
294
+ ioListeners.push({
295
+ root: root,
296
+ key: ioKey,
297
+ listener: io.current = new IntersectionObserver(handleObserverStatusChange, ioOptions)
298
+ });
299
+ } else {
300
+ io.current = _ioListener.listener;
301
+ }
302
+ }
303
+
304
+ function ioObserve() {
305
+ if (domRef.current && io.current) {
306
+ var curIdx = ioVisibleList.findIndex(function (ioVisibleItem) {
307
+ return ioVisibleItem.node === domRef.current;
308
+ });
309
+
310
+ if (curIdx !== -1) {
311
+ ioVisibleList[curIdx].isVisible = false;
312
+ } else {
313
+ ioVisibleList.push({
314
+ node: domRef.current,
315
+ isVisible: false,
316
+ once: once,
317
+ onVisibleChange: onVisibleChange
318
+ });
319
+ }
320
+
321
+ io.current.observe(domRef.current);
322
+ }
323
+ }
324
+
325
+ function ioUnobserve(target) {
326
+ var targetNode = target || domRef.current;
327
+
328
+ if (io.current && targetNode) {
329
+ var curIdx = ioVisibleList.findIndex(function (ioVisibleItem) {
330
+ return ioVisibleItem.node === targetNode;
331
+ });
332
+
333
+ if (curIdx !== -1) {
334
+ ioVisibleList.splice(curIdx, 1);
335
+ }
336
+
337
+ io.current.unobserve(targetNode);
338
+ }
260
339
  }
261
340
  /**
262
341
  * 非首次下disabled变化时,重新监听元素
@@ -266,14 +345,11 @@
266
345
 
267
346
  (0, _react.useEffect)(function () {
268
347
  if (isSupportNativeApi) {
269
- // 非首次下
348
+ // 非首次 render 下
270
349
  // @en Not for the first time
271
- if (io.current && domRef.current) {
272
- // 禁用监听 || 监听
273
- disabled ? io.current.unobserve(domRef.current) : io.current.observe(domRef.current);
274
- }
350
+ disabled ? ioUnobserve() : ioObserve();
275
351
  } else {
276
- // 非首次下
352
+ // 非首次 render 下
277
353
  // @en Not for the first time
278
354
  if (wrapperKey.current !== -1 && listener.current && listeners[wrapperKey.current]) {
279
355
  // 禁用监听,找到对应listener并删除
@@ -337,12 +413,12 @@
337
413
  rootMargin = offset + "px";
338
414
  }
339
415
 
340
- io.current = new IntersectionObserver(handleObserverStatusChange, {
416
+ getIOSingleton({
341
417
  root: root,
342
418
  rootMargin: rootMargin,
343
419
  threshold: threshold
344
420
  });
345
- !disabled && io.current.observe(domRef.current);
421
+ !disabled && ioObserve();
346
422
  }
347
423
  } else {
348
424
  // 节流后回调函数
@@ -386,7 +462,7 @@
386
462
 
387
463
  listener.current = {
388
464
  node: domRef.current,
389
- isVisible: isVisible,
465
+ isVisible: false,
390
466
  overflow: overflow,
391
467
  once: once,
392
468
  offset: offset,
@@ -403,9 +479,7 @@
403
479
  (0, _react.useEffect)(function () {
404
480
  return function () {
405
481
  if (isSupportNativeApi) {
406
- var _io$current2;
407
-
408
- domRef.current && ((_io$current2 = io.current) == null ? void 0 : _io$current2.unobserve(domRef.current));
482
+ ioUnobserve();
409
483
  } else {
410
484
  if (overflow) {
411
485
  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);