@arco-design/mobile-react 2.22.2 → 2.22.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.
@@ -66,6 +66,12 @@ export interface CarouselProps {
66
66
  * @default true
67
67
  */
68
68
  autoPlay?: boolean;
69
+ /**
70
+ * 自动播放方向
71
+ * @en Direction when playing auto
72
+ * @default "normal"
73
+ */
74
+ autoPlayDirection?: 'normal' | 'reverse';
69
75
  /**
70
76
  * 是否响应手势滑动
71
77
  * @en Whether to respond to gesture swipe
@@ -27,6 +27,8 @@ var Carousel = /*#__PURE__*/forwardRef(function (props, ref) {
27
27
  loop = _props$loop === void 0 ? true : _props$loop,
28
28
  _props$autoPlay = props.autoPlay,
29
29
  autoPlay = _props$autoPlay === void 0 ? true : _props$autoPlay,
30
+ _props$autoPlayDirect = props.autoPlayDirection,
31
+ autoPlayDirection = _props$autoPlayDirect === void 0 ? 'normal' : _props$autoPlayDirect,
30
32
  _props$swipeable = props.swipeable,
31
33
  swipeable = _props$swipeable === void 0 ? true : _props$swipeable,
32
34
  _props$stayDuration = props.stayDuration,
@@ -149,7 +151,7 @@ var Carousel = /*#__PURE__*/forwardRef(function (props, ref) {
149
151
  transformsRef = _useRefState4[1],
150
152
  setTransforms = _useRefState4[2];
151
153
 
152
- var _useRefState5 = useRefState('left'),
154
+ var _useRefState5 = useRefState(autoPlayDirection === 'reverse' && autoPlay ? 'right' : 'left'),
153
155
  direction = _useRefState5[0],
154
156
  directionRef = _useRefState5[1],
155
157
  setStateDirection = _useRefState5[2];
@@ -386,7 +388,7 @@ var Carousel = /*#__PURE__*/forwardRef(function (props, ref) {
386
388
  return function () {
387
389
  clear();
388
390
  };
389
- }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval]);
391
+ }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval, autoPlayDirection]);
390
392
  useUpdateEffect(function () {
391
393
  if (currentIndex !== void 0) {
392
394
  jumpTo(currentIndex);
@@ -526,7 +528,7 @@ var Carousel = /*#__PURE__*/forwardRef(function (props, ref) {
526
528
  var changedIndex = newIndex !== oldIndex ? getShownIndex(newIndex) : -1;
527
529
 
528
530
  if (autoJump) {
529
- setDirection('left');
531
+ setDirection(autoPlayDirection === 'reverse' ? 'right' : 'left');
530
532
  } else if (newIndex === indexRef.current) {
531
533
  setDirection(distanceRef.current > 0 ? 'right' : 'left');
532
534
  } else {
@@ -580,7 +582,7 @@ var Carousel = /*#__PURE__*/forwardRef(function (props, ref) {
580
582
  }
581
583
 
582
584
  timerRef.current = delayTimeout(function () {
583
- jumpTo(indexRef.current + 1);
585
+ jumpTo(autoPlayDirection === 'reverse' ? indexRef.current - 1 : indexRef.current + 1);
584
586
  }, stayDuration);
585
587
  }
586
588
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.22.2",
3
+ "version": "2.22.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.12.6",
18
+ "@arco-design/mobile-utils": "^2.12.7",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "es6-promise": "^4.2.8",
21
21
  "lodash.throttle": "^4.1.1",
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "52a29775d16e5e7d2b7645086644cf03aac6d71f"
39
+ "gitHead": "2d9f52e4a749a50a0b6248b14ab8f8d02f2f0e1e"
40
40
  }
package/tools/flexible.js CHANGED
@@ -1,82 +1,101 @@
1
- "use strict";
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["exports"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(exports);
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(mod.exports);
11
+ global.setRootPixel = mod.exports.default;
12
+ }
13
+ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) {
14
+
15
+ "use strict";
2
16
 
3
- function setRootPixel(base, sketch, max) {
4
- var baseFontSize = base || 50;
5
- var sketchWidth = sketch || 375;
6
- var maxFontSize = max || 64;
7
- var defaultFontSize = 0;
17
+ _exports.__esModule = true;
18
+ _exports.default = void 0;
8
19
 
9
- function getDefaultFontSize() {
10
- if (defaultFontSize) {
20
+ function setRootPixel(base, sketch, max) {
21
+ var baseFontSize = base || 50;
22
+ var sketchWidth = sketch || 375;
23
+ var maxFontSize = max || 64;
24
+ var defaultFontSize = 0;
25
+
26
+ function getDefaultFontSize() {
27
+ if (defaultFontSize) {
28
+ return defaultFontSize;
29
+ }
30
+
31
+ document.documentElement.style.fontSize = '';
32
+ var temp = document.createElement('div');
33
+ temp.style.cssText = 'width:1rem;display:none';
34
+ document.head.appendChild(temp);
35
+ defaultFontSize = +window.getComputedStyle(temp, null).getPropertyValue('width').replace('px', '') || 16;
36
+ document.head.removeChild(temp);
11
37
  return defaultFontSize;
12
38
  }
13
39
 
14
- document.documentElement.style.fontSize = '';
15
- var temp = document.createElement('div');
16
- temp.style.cssText = 'width:1rem;display:none';
17
- document.head.appendChild(temp);
18
- defaultFontSize = +window.getComputedStyle(temp, null).getPropertyValue('width').replace('px', '') || 16;
19
- document.head.removeChild(temp);
20
- return defaultFontSize;
21
- }
40
+ function getQuery(name) {
41
+ return (new RegExp("[?&]".concat(name, "=([^&#\\b]+)")).exec(location.search || '') || [])[1];
42
+ }
22
43
 
23
- function getQuery(name) {
24
- return (new RegExp("[?&]".concat(name, "=([^&#\\b]+)")).exec(location.search || '') || [])[1];
25
- }
44
+ function setRootFontSize() {
45
+ var widthQueryKey = '';
46
+ var rem2px = baseFontSize;
47
+ var clientWidth;
26
48
 
27
- function setRootFontSize() {
28
- var widthQueryKey = '';
29
- var rem2px = baseFontSize;
30
- var clientWidth;
31
-
32
- if (widthQueryKey && +getQuery(widthQueryKey)) {
33
- clientWidth = +getQuery(widthQueryKey);
34
- } else {
35
- clientWidth = window.innerWidth && document.documentElement.clientWidth
36
- ? Math.min(window.innerWidth, document.documentElement.clientWidth)
37
- : window.innerWidth
38
- || document.documentElement.clientWidth
39
- || document.body && document.body.clientWidth
40
- || sketchWidth;
49
+ if (widthQueryKey && +getQuery(widthQueryKey)) {
50
+ clientWidth = +getQuery(widthQueryKey);
51
+ } else {
52
+ clientWidth = window.innerWidth && document.documentElement.clientWidth
53
+ ? Math.min(window.innerWidth, document.documentElement.clientWidth)
54
+ : window.innerWidth
55
+ || document.documentElement.clientWidth
56
+ || document.body && document.body.clientWidth
57
+ || sketchWidth;
58
+ }
59
+ var htmlFontSizePx = clientWidth / sketchWidth * rem2px;
60
+ htmlFontSizePx = Math.min(htmlFontSizePx, maxFontSize);
61
+ window.ROOT_FONT_SIZE = htmlFontSizePx;
62
+ document.documentElement.style.fontSize = "".concat(htmlFontSizePx / getDefaultFontSize() * 100, "%");
41
63
  }
42
- var htmlFontSizePx = clientWidth / sketchWidth * rem2px;
43
- htmlFontSizePx = Math.min(htmlFontSizePx, maxFontSize);
44
- window.ROOT_FONT_SIZE = htmlFontSizePx;
45
- document.documentElement.style.fontSize = "".concat(htmlFontSizePx / getDefaultFontSize() * 100, "%");
46
- }
47
64
 
48
- function adjust(immediate) {
49
- if (immediate) {
50
- setRootFontSize();
51
- return;
65
+ function adjust(immediate) {
66
+ if (immediate) {
67
+ setRootFontSize();
68
+ return;
69
+ }
70
+
71
+ setTimeout(setRootFontSize, 30);
52
72
  }
53
73
 
54
- setTimeout(setRootFontSize, 30);
55
- }
74
+ function removeRootPixel() {
75
+ document.documentElement.style.fontSize = '';
76
+ window.removeEventListener('resize', adjust, false);
77
+ if ('onorientationchange' in window) {
78
+ window.removeEventListener('orientationchange', adjust, false);
79
+ }
80
+ }
56
81
 
57
- function removeRootPixel() {
58
- document.documentElement.style.fontSize = '';
59
- window.removeEventListener('resize', adjust, false);
60
- if ('onorientationchange' in window) {
61
- window.removeEventListener('orientationchange', adjust, false);
82
+ if (window.isResponsive === false) {
83
+ document.documentElement.style.fontSize = "".concat(baseFontSize, "px");
84
+ return function () {
85
+ document.documentElement.style.fontSize = '';
86
+ };
62
87
  }
63
- }
64
88
 
65
- if (window.isResponsive === false) {
66
- document.documentElement.style.fontSize = "".concat(baseFontSize, "px");
67
- return function () {
68
- document.documentElement.style.fontSize = '';
69
- };
70
- }
89
+ adjust(true);
90
+ window.addEventListener('resize', adjust, false);
71
91
 
72
- adjust(true);
73
- window.addEventListener('resize', adjust, false);
92
+ if ('onorientationchange' in window) {
93
+ window.addEventListener('orientationchange', adjust, false);
94
+ }
74
95
 
75
- if ('onorientationchange' in window) {
76
- window.addEventListener('orientationchange', adjust, false);
96
+ return removeRootPixel;
77
97
  }
78
98
 
79
- return removeRootPixel;
80
- }
99
+ _exports.default = setRootPixel;
81
100
 
82
- module.exports = setRootPixel;
101
+ });
@@ -66,6 +66,12 @@ export interface CarouselProps {
66
66
  * @default true
67
67
  */
68
68
  autoPlay?: boolean;
69
+ /**
70
+ * 自动播放方向
71
+ * @en Direction when playing auto
72
+ * @default "normal"
73
+ */
74
+ autoPlayDirection?: 'normal' | 'reverse';
69
75
  /**
70
76
  * 是否响应手势滑动
71
77
  * @en Whether to respond to gesture swipe
@@ -47,6 +47,8 @@
47
47
  loop = _props$loop === void 0 ? true : _props$loop,
48
48
  _props$autoPlay = props.autoPlay,
49
49
  autoPlay = _props$autoPlay === void 0 ? true : _props$autoPlay,
50
+ _props$autoPlayDirect = props.autoPlayDirection,
51
+ autoPlayDirection = _props$autoPlayDirect === void 0 ? 'normal' : _props$autoPlayDirect,
50
52
  _props$swipeable = props.swipeable,
51
53
  swipeable = _props$swipeable === void 0 ? true : _props$swipeable,
52
54
  _props$stayDuration = props.stayDuration,
@@ -169,7 +171,7 @@
169
171
  transformsRef = _useRefState4[1],
170
172
  setTransforms = _useRefState4[2];
171
173
 
172
- var _useRefState5 = (0, _helpers.useRefState)('left'),
174
+ var _useRefState5 = (0, _helpers.useRefState)(autoPlayDirection === 'reverse' && autoPlay ? 'right' : 'left'),
173
175
  direction = _useRefState5[0],
174
176
  directionRef = _useRefState5[1],
175
177
  setStateDirection = _useRefState5[2];
@@ -406,7 +408,7 @@
406
408
  return function () {
407
409
  clear();
408
410
  };
409
- }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval]);
411
+ }, [userSetBoxWidth, userSetBoxHeight, childWidth, childHeight, stayDuration, noInterval, autoPlayDirection]);
410
412
  (0, _helpers.useUpdateEffect)(function () {
411
413
  if (currentIndex !== void 0) {
412
414
  jumpTo(currentIndex);
@@ -546,7 +548,7 @@
546
548
  var changedIndex = newIndex !== oldIndex ? getShownIndex(newIndex) : -1;
547
549
 
548
550
  if (autoJump) {
549
- setDirection('left');
551
+ setDirection(autoPlayDirection === 'reverse' ? 'right' : 'left');
550
552
  } else if (newIndex === indexRef.current) {
551
553
  setDirection(distanceRef.current > 0 ? 'right' : 'left');
552
554
  } else {
@@ -600,7 +602,7 @@
600
602
  }
601
603
 
602
604
  timerRef.current = delayTimeout(function () {
603
- jumpTo(indexRef.current + 1);
605
+ jumpTo(autoPlayDirection === 'reverse' ? indexRef.current - 1 : indexRef.current + 1);
604
606
  }, stayDuration);
605
607
  }
606
608