@arco-design/mobile-react 2.35.0 → 2.35.1
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 +11 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/popup-swiper/index.d.ts +1 -1
- package/cjs/sticky/index.js +34 -5
- package/dist/index.js +61 -9
- package/dist/index.min.js +4 -4
- package/esm/popup-swiper/index.d.ts +1 -1
- package/esm/sticky/index.js +35 -6
- package/esnext/popup-swiper/index.d.ts +1 -1
- package/esnext/sticky/index.js +38 -6
- package/package.json +3 -3
- package/umd/popup-swiper/index.d.ts +1 -1
- package/umd/sticky/index.js +34 -5
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,17 @@
|
|
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.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)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* `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))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
6
17
|
# [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
18
|
|
8
19
|
|
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.0/dist/style.min.css">
|
63
|
+
<script src="https://unpkg.com/@arco-design/mobile-react@2.35.0/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.0/dist/style.min.css">
|
63
|
+
<script src="https://unpkg.com/@arco-design/mobile-react@2.35.0/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
|
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,16 +1321,41 @@
|
|
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;
|
1335
|
+
}
|
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;
|
1333
1356
|
}
|
1357
|
+
|
1358
|
+
return 0;
|
1334
1359
|
}
|
1335
1360
|
|
1336
1361
|
/* eslint-disable no-redeclare */
|
@@ -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
|
}
|