@arco-design/mobile-react 2.35.0 → 2.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/popup-swiper/index.d.ts +1 -1
- package/cjs/pull-refresh/android-pull-refresh.js +5 -8
- package/cjs/pull-refresh/model.d.ts +1 -0
- package/cjs/sticky/index.js +34 -5
- package/dist/index.js +64 -17
- package/dist/index.min.js +4 -4
- package/esm/popup-swiper/index.d.ts +1 -1
- package/esm/pull-refresh/android-pull-refresh.js +3 -7
- package/esm/pull-refresh/model.d.ts +1 -0
- package/esm/sticky/index.js +35 -6
- package/esnext/popup-swiper/index.d.ts +1 -1
- package/esnext/pull-refresh/android-pull-refresh.js +5 -6
- package/esnext/pull-refresh/model.d.ts +1 -0
- package/esnext/sticky/index.js +38 -6
- package/package.json +3 -3
- package/umd/popup-swiper/index.d.ts +1 -1
- package/umd/pull-refresh/android-pull-refresh.js +7 -12
- package/umd/pull-refresh/model.d.ts +1 -0
- package/umd/sticky/index.js +34 -5
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,28 @@
|
|
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.35.2](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.35.1...@arco-design/mobile-react@2.35.2) (2025-03-17)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* `PullRefresh` fix severe lagging in Android device ([#316](https://github.com/arco-design/arco-design-mobile/issues/316)) ([2b14461](https://github.com/arco-design/arco-design-mobile/commit/2b14461f787c42035e06c7a76b50955f22cadde2))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [2.35.1](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.35.0...@arco-design/mobile-react@2.35.1) (2025-02-26)
|
18
|
+
|
19
|
+
|
20
|
+
### Bug Fixes
|
21
|
+
|
22
|
+
* `Sticky` caculate with border style & offsetParent in absolute mode ([#314](https://github.com/arco-design/arco-design-mobile/issues/314)) ([1eff5fe](https://github.com/arco-design/arco-design-mobile/commit/1eff5fee0a010bbf236094a7d361f54f0e0bcb2a))
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
6
28
|
# [2.35.0](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.34.0...@arco-design/mobile-react@2.35.0) (2025-01-09)
|
7
29
|
|
8
30
|
|
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.
|
63
|
-
<script src="https://unpkg.com/@arco-design/mobile-react@2.
|
62
|
+
<link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.1/dist/style.min.css">
|
63
|
+
<script src="https://unpkg.com/@arco-design/mobile-react@2.35.1/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.
|
63
|
-
<script src="https://unpkg.com/@arco-design/mobile-react@2.
|
62
|
+
<link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.1/dist/style.min.css">
|
63
|
+
<script src="https://unpkg.com/@arco-design/mobile-react@2.35.1/dist/index.min.js"></script>
|
64
64
|
```
|
65
65
|
|
66
66
|
## 引入全部
|
@@ -26,7 +26,7 @@ export interface PopupSwiperProps extends PopupProps {
|
|
26
26
|
* @default direction 属性指定的方向性
|
27
27
|
* @default_en The value of direction property
|
28
28
|
*/
|
29
|
-
allowSwipeDirections
|
29
|
+
allowSwipeDirections?: DirectionType[];
|
30
30
|
/**
|
31
31
|
* 固定弹窗退出方向,默认跟随手势滑动方向
|
32
32
|
* @en Fixed the exit direction of the pop-up window, and the default sliding direction follows the gesture
|
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
12
12
|
var _mobileUtils = require("@arco-design/mobile-utils");
|
13
13
|
|
14
|
+
var _es6Promise = require("es6-promise");
|
15
|
+
|
14
16
|
var _loading = _interopRequireDefault(require("../loading"));
|
15
17
|
|
16
18
|
var _contextProvider = require("../context-provider");
|
@@ -122,8 +124,8 @@ var PullRefresh = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
122
124
|
}, ms ? {
|
123
125
|
transition: "all " + ms / 1000 + "s"
|
124
126
|
} : {}));
|
125
|
-
setTimeout(function () {
|
126
|
-
callback
|
127
|
+
callback && setTimeout(function () {
|
128
|
+
callback();
|
127
129
|
}, ms);
|
128
130
|
};
|
129
131
|
|
@@ -150,11 +152,6 @@ var PullRefresh = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
150
152
|
if (disabled || touchRef.current || loadingRef.current || !domRef.current) return;
|
151
153
|
if (!ifShouldHandle()) return;
|
152
154
|
setTouching(true);
|
153
|
-
|
154
|
-
if (domRef.current.scrollTop === 0) {
|
155
|
-
domRef.current.scrollTop = 1;
|
156
|
-
}
|
157
|
-
|
158
155
|
var _e$touches$ = e.touches[0],
|
159
156
|
pageX = _e$touches$.pageX,
|
160
157
|
pageY = _e$touches$.pageY;
|
@@ -173,7 +170,7 @@ var PullRefresh = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
173
170
|
}, [disabled, ifShouldHandle]);
|
174
171
|
|
175
172
|
var refresh = function refresh() {
|
176
|
-
return new Promise(function (resolve) {
|
173
|
+
return new _es6Promise.Promise(function (resolve) {
|
177
174
|
setStatus(_model.PullRefreshStatus.Loading);
|
178
175
|
(0, _mobileUtils.nextTick)(function () {
|
179
176
|
scroll(tipsHeight, 300);
|
package/cjs/sticky/index.js
CHANGED
@@ -92,9 +92,14 @@ var Sticky = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
92
92
|
var _getScrollContainerRe = (0, _mobileUtils.getScrollContainerRect)(scrollContainerRef.current),
|
93
93
|
containerRect = _getScrollContainerRe.containerRect;
|
94
94
|
|
95
|
-
var
|
96
|
-
|
95
|
+
var rectTop = containerRect.top,
|
96
|
+
rectBottom = containerRect.bottom,
|
97
97
|
containerHeight = containerRect.height;
|
98
|
+
var scrollStyle = (0, _mobileUtils.safeGetComputedStyle)(scrollContainerRef.current);
|
99
|
+
var borderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderTopWidth') : 0;
|
100
|
+
var borderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderBottomWidth') : 0;
|
101
|
+
var containerTop = rectTop + borderTop;
|
102
|
+
var containerBottom = rectBottom - borderBottom;
|
98
103
|
var disFromTop = Math.round(placeholderClientRect.top - containerTop);
|
99
104
|
var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
|
100
105
|
var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
|
@@ -103,8 +108,32 @@ var Sticky = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
103
108
|
var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
|
104
109
|
var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
|
105
110
|
var newStickyState = isTopSticky || isBottomSticky;
|
106
|
-
var
|
107
|
-
var
|
111
|
+
var stickyTop = containerTop;
|
112
|
+
var stickyBottom = window.innerHeight - containerBottom;
|
113
|
+
var stickyLeft = placeholderClientRect.left;
|
114
|
+
|
115
|
+
if (stickyStyle === 'absolute') {
|
116
|
+
var offsetParent = contentRef.current.offsetParent;
|
117
|
+
|
118
|
+
if (offsetParent) {
|
119
|
+
var _getScrollContainerRe2 = (0, _mobileUtils.getScrollContainerRect)(offsetParent),
|
120
|
+
parentRect = _getScrollContainerRe2.containerRect;
|
121
|
+
|
122
|
+
var parentStyle = (0, _mobileUtils.safeGetComputedStyle)(offsetParent);
|
123
|
+
var parentBorderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderTopWidth') : 0;
|
124
|
+
var parentBorderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderBottomWidth') : 0;
|
125
|
+
var parentBorderLeft = (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderLeftWidth');
|
126
|
+
stickyTop = containerTop - parentRect.top - parentBorderTop;
|
127
|
+
stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
|
128
|
+
stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
|
129
|
+
} else {
|
130
|
+
stickyTop = 0;
|
131
|
+
stickyBottom = 0;
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
var cssTop = stickyTop + topOffset;
|
136
|
+
var cssBottom = stickyBottom + bottomOffset;
|
108
137
|
var stickyCssStyle = {};
|
109
138
|
|
110
139
|
if (newStickyState) {
|
@@ -118,7 +147,7 @@ var Sticky = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
118
147
|
} : {}, isBottomSticky ? {
|
119
148
|
bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
|
120
149
|
} : {}, {
|
121
|
-
left:
|
150
|
+
left: stickyLeft,
|
122
151
|
width: placeholderClientRect.width
|
123
152
|
}, userSetStickyCssStyle || {});
|
124
153
|
}
|
package/dist/index.js
CHANGED
@@ -1299,7 +1299,7 @@
|
|
1299
1299
|
*/
|
1300
1300
|
|
1301
1301
|
function convertCssDuration(ele, property) {
|
1302
|
-
var timeout =
|
1302
|
+
var timeout = safeGetComputedStyle(ele)[property];
|
1303
1303
|
|
1304
1304
|
if (/ms$/.test(timeout)) {
|
1305
1305
|
return Number(timeout.replace('ms', '')) || 0;
|
@@ -1321,17 +1321,42 @@
|
|
1321
1321
|
* import { safeGetComputedStyle } from '@arco-design/mobile-utils';
|
1322
1322
|
*
|
1323
1323
|
* const element = document.querySelector("p");
|
1324
|
-
* const compStyle =safeGetComputedStyle(element);
|
1324
|
+
* const compStyle = safeGetComputedStyle(element);
|
1325
1325
|
* ```
|
1326
1326
|
*/
|
1327
1327
|
|
1328
1328
|
function safeGetComputedStyle(element) {
|
1329
|
+
var defaultValue = {};
|
1330
|
+
|
1329
1331
|
try {
|
1330
|
-
return window.getComputedStyle(element);
|
1332
|
+
return element ? window.getComputedStyle(element) : defaultValue;
|
1331
1333
|
} catch (e) {
|
1332
|
-
return
|
1334
|
+
return defaultValue;
|
1333
1335
|
}
|
1334
1336
|
}
|
1337
|
+
/**
|
1338
|
+
* 获取指定元素的样式属性数字值
|
1339
|
+
* @desc {en} Get the CSS style of the specified element and format it to number
|
1340
|
+
* @param computedStyle 要获取的样式属性对象
|
1341
|
+
* @param element {en} the computed style
|
1342
|
+
* @example
|
1343
|
+
* ```
|
1344
|
+
* import { safeGetComputedStyle, convertCssPropertyToNumber } from '@arco-design/mobile-utils';
|
1345
|
+
*
|
1346
|
+
* const computedStyle = safeGetComputedStyle(element);
|
1347
|
+
* const compStyle = convertCssPropertyToNumber(computedStyle, 'fontSize');
|
1348
|
+
* ```
|
1349
|
+
*/
|
1350
|
+
|
1351
|
+
function convertCssPropertyToNumber(computedStyle, property) {
|
1352
|
+
var value = computedStyle[property];
|
1353
|
+
|
1354
|
+
if (/px$/.test(value)) {
|
1355
|
+
return Number(value.replace('px', '')) || 0;
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
return 0;
|
1359
|
+
}
|
1335
1360
|
|
1336
1361
|
/* eslint-disable no-redeclare */
|
1337
1362
|
|
@@ -6898,9 +6923,14 @@
|
|
6898
6923
|
var calculatedHeight = contentClientRect.height;
|
6899
6924
|
contentCalculateHeightRef.current = contentClientRect.height;
|
6900
6925
|
var containerRect = getScrollContainerRect(scrollContainerRef.current).containerRect;
|
6901
|
-
var
|
6902
|
-
|
6926
|
+
var rectTop = containerRect.top,
|
6927
|
+
rectBottom = containerRect.bottom,
|
6903
6928
|
containerHeight = containerRect.height;
|
6929
|
+
var scrollStyle = safeGetComputedStyle(scrollContainerRef.current);
|
6930
|
+
var borderTop = needTop ? convertCssPropertyToNumber(scrollStyle, 'borderTopWidth') : 0;
|
6931
|
+
var borderBottom = needBottom ? convertCssPropertyToNumber(scrollStyle, 'borderBottomWidth') : 0;
|
6932
|
+
var containerTop = rectTop + borderTop;
|
6933
|
+
var containerBottom = rectBottom - borderBottom;
|
6904
6934
|
var disFromTop = Math.round(placeholderClientRect.top - containerTop);
|
6905
6935
|
var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
|
6906
6936
|
var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
|
@@ -6909,8 +6939,30 @@
|
|
6909
6939
|
var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
|
6910
6940
|
var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
|
6911
6941
|
var newStickyState = isTopSticky || isBottomSticky;
|
6912
|
-
var
|
6913
|
-
var
|
6942
|
+
var stickyTop = containerTop;
|
6943
|
+
var stickyBottom = window.innerHeight - containerBottom;
|
6944
|
+
var stickyLeft = placeholderClientRect.left;
|
6945
|
+
|
6946
|
+
if (stickyStyle === 'absolute') {
|
6947
|
+
var offsetParent = contentRef.current.offsetParent;
|
6948
|
+
|
6949
|
+
if (offsetParent) {
|
6950
|
+
var parentRect = getScrollContainerRect(offsetParent).containerRect;
|
6951
|
+
var parentStyle = safeGetComputedStyle(offsetParent);
|
6952
|
+
var parentBorderTop = needTop ? convertCssPropertyToNumber(parentStyle, 'borderTopWidth') : 0;
|
6953
|
+
var parentBorderBottom = needBottom ? convertCssPropertyToNumber(parentStyle, 'borderBottomWidth') : 0;
|
6954
|
+
var parentBorderLeft = convertCssPropertyToNumber(parentStyle, 'borderLeftWidth');
|
6955
|
+
stickyTop = containerTop - parentRect.top - parentBorderTop;
|
6956
|
+
stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
|
6957
|
+
stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
|
6958
|
+
} else {
|
6959
|
+
stickyTop = 0;
|
6960
|
+
stickyBottom = 0;
|
6961
|
+
}
|
6962
|
+
}
|
6963
|
+
|
6964
|
+
var cssTop = stickyTop + topOffset;
|
6965
|
+
var cssBottom = stickyBottom + bottomOffset;
|
6914
6966
|
var stickyCssStyle = {};
|
6915
6967
|
|
6916
6968
|
if (newStickyState) {
|
@@ -6924,7 +6976,7 @@
|
|
6924
6976
|
} : {}), isBottomSticky ? {
|
6925
6977
|
bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
|
6926
6978
|
} : {}), {
|
6927
|
-
left:
|
6979
|
+
left: stickyLeft,
|
6928
6980
|
width: placeholderClientRect.width
|
6929
6981
|
}), userSetStickyCssStyle || {});
|
6930
6982
|
}
|
@@ -26114,8 +26166,8 @@
|
|
26114
26166
|
}, ms ? {
|
26115
26167
|
transition: "all " + ms / 1000 + "s"
|
26116
26168
|
} : {}));
|
26117
|
-
setTimeout(function () {
|
26118
|
-
callback
|
26169
|
+
callback && setTimeout(function () {
|
26170
|
+
callback();
|
26119
26171
|
}, ms);
|
26120
26172
|
};
|
26121
26173
|
|
@@ -26144,11 +26196,6 @@
|
|
26144
26196
|
if (disabled || touchRef.current || loadingRef.current || !domRef.current) return;
|
26145
26197
|
if (!ifShouldHandle()) return;
|
26146
26198
|
setTouching(true);
|
26147
|
-
|
26148
|
-
if (domRef.current.scrollTop === 0) {
|
26149
|
-
domRef.current.scrollTop = 1;
|
26150
|
-
}
|
26151
|
-
|
26152
26199
|
var _b = e.touches[0],
|
26153
26200
|
pageX = _b.pageX,
|
26154
26201
|
pageY = _b.pageY;
|
@@ -26165,7 +26212,7 @@
|
|
26165
26212
|
}, [disabled, ifShouldHandle]);
|
26166
26213
|
|
26167
26214
|
var refresh = function refresh() {
|
26168
|
-
return new Promise(function (resolve) {
|
26215
|
+
return new es6Promise.Promise(function (resolve) {
|
26169
26216
|
setStatus(PullRefreshStatus.Loading);
|
26170
26217
|
nextTick(function () {
|
26171
26218
|
scroll(tipsHeight, 300);
|