@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.
@@ -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: DirectionType[];
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
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useRef, forwardRef, useImperativeHandle, useEffect, useMemo, useState, useCallback } from 'react';
3
- import { cls, execRAF, getActualContainer, getScrollContainerRect } from '@arco-design/mobile-utils';
3
+ import { cls, execRAF, getActualContainer, getScrollContainerRect, safeGetComputedStyle, convertCssPropertyToNumber } from '@arco-design/mobile-utils';
4
4
  import { ContextLayout } from '../context-provider';
5
5
  import { useRefState } from '../_helpers';
6
6
  import Portal from '../portal';
@@ -76,9 +76,14 @@ var Sticky = /*#__PURE__*/forwardRef(function (props, ref) {
76
76
  var _getScrollContainerRe = getScrollContainerRect(scrollContainerRef.current),
77
77
  containerRect = _getScrollContainerRe.containerRect;
78
78
 
79
- var containerTop = containerRect.top,
80
- containerBottom = containerRect.bottom,
79
+ var rectTop = containerRect.top,
80
+ rectBottom = containerRect.bottom,
81
81
  containerHeight = containerRect.height;
82
+ var scrollStyle = safeGetComputedStyle(scrollContainerRef.current);
83
+ var borderTop = needTop ? convertCssPropertyToNumber(scrollStyle, 'borderTopWidth') : 0;
84
+ var borderBottom = needBottom ? convertCssPropertyToNumber(scrollStyle, 'borderBottomWidth') : 0;
85
+ var containerTop = rectTop + borderTop;
86
+ var containerBottom = rectBottom - borderBottom;
82
87
  var disFromTop = Math.round(placeholderClientRect.top - containerTop);
83
88
  var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
84
89
  var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -87,8 +92,32 @@ var Sticky = /*#__PURE__*/forwardRef(function (props, ref) {
87
92
  var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
88
93
  var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
89
94
  var newStickyState = isTopSticky || isBottomSticky;
90
- var cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
91
- var cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) + bottomOffset;
95
+ var stickyTop = containerTop;
96
+ var stickyBottom = window.innerHeight - containerBottom;
97
+ var stickyLeft = placeholderClientRect.left;
98
+
99
+ if (stickyStyle === 'absolute') {
100
+ var offsetParent = contentRef.current.offsetParent;
101
+
102
+ if (offsetParent) {
103
+ var _getScrollContainerRe2 = getScrollContainerRect(offsetParent),
104
+ parentRect = _getScrollContainerRe2.containerRect;
105
+
106
+ var parentStyle = safeGetComputedStyle(offsetParent);
107
+ var parentBorderTop = needTop ? convertCssPropertyToNumber(parentStyle, 'borderTopWidth') : 0;
108
+ var parentBorderBottom = needBottom ? convertCssPropertyToNumber(parentStyle, 'borderBottomWidth') : 0;
109
+ var parentBorderLeft = convertCssPropertyToNumber(parentStyle, 'borderLeftWidth');
110
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
111
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
112
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
113
+ } else {
114
+ stickyTop = 0;
115
+ stickyBottom = 0;
116
+ }
117
+ }
118
+
119
+ var cssTop = stickyTop + topOffset;
120
+ var cssBottom = stickyBottom + bottomOffset;
92
121
  var stickyCssStyle = {};
93
122
 
94
123
  if (newStickyState) {
@@ -102,7 +131,7 @@ var Sticky = /*#__PURE__*/forwardRef(function (props, ref) {
102
131
  } : {}, isBottomSticky ? {
103
132
  bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
104
133
  } : {}, {
105
- left: placeholderClientRect.left,
134
+ left: stickyLeft,
106
135
  width: placeholderClientRect.width
107
136
  }, userSetStickyCssStyle || {});
108
137
  }
@@ -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: DirectionType[];
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
@@ -1,5 +1,5 @@
1
1
  import React, { useRef, forwardRef, useImperativeHandle, useEffect, useMemo, useState, useCallback, } from 'react';
2
- import { cls, execRAF, getActualContainer, getScrollContainerRect, } from '@arco-design/mobile-utils';
2
+ import { cls, execRAF, getActualContainer, getScrollContainerRect, safeGetComputedStyle, convertCssPropertyToNumber, } from '@arco-design/mobile-utils';
3
3
  import { ContextLayout } from '../context-provider';
4
4
  import { useRefState } from '../_helpers';
5
5
  import Portal from '../portal';
@@ -33,7 +33,16 @@ const Sticky = forwardRef((props, ref) => {
33
33
  const calculatedHeight = contentClientRect.height;
34
34
  contentCalculateHeightRef.current = contentClientRect.height;
35
35
  const { containerRect } = getScrollContainerRect(scrollContainerRef.current);
36
- const { top: containerTop, bottom: containerBottom, height: containerHeight, } = containerRect;
36
+ const { top: rectTop, bottom: rectBottom, height: containerHeight } = containerRect;
37
+ const scrollStyle = safeGetComputedStyle(scrollContainerRef.current);
38
+ const borderTop = needTop
39
+ ? convertCssPropertyToNumber(scrollStyle, 'borderTopWidth')
40
+ : 0;
41
+ const borderBottom = needBottom
42
+ ? convertCssPropertyToNumber(scrollStyle, 'borderBottomWidth')
43
+ : 0;
44
+ const containerTop = rectTop + borderTop;
45
+ const containerBottom = rectBottom - borderBottom;
37
46
  const disFromTop = Math.round(placeholderClientRect.top - containerTop);
38
47
  const disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
39
48
  const topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -46,9 +55,32 @@ const Sticky = forwardRef((props, ref) => {
46
55
  ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset
47
56
  : false;
48
57
  const newStickyState = isTopSticky || isBottomSticky;
49
- const cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
50
- const cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) +
51
- bottomOffset;
58
+ let stickyTop = containerTop;
59
+ let stickyBottom = window.innerHeight - containerBottom;
60
+ let stickyLeft = placeholderClientRect.left;
61
+ if (stickyStyle === 'absolute') {
62
+ const offsetParent = contentRef.current.offsetParent;
63
+ if (offsetParent) {
64
+ const { containerRect: parentRect } = getScrollContainerRect(offsetParent);
65
+ const parentStyle = safeGetComputedStyle(offsetParent);
66
+ const parentBorderTop = needTop
67
+ ? convertCssPropertyToNumber(parentStyle, 'borderTopWidth')
68
+ : 0;
69
+ const parentBorderBottom = needBottom
70
+ ? convertCssPropertyToNumber(parentStyle, 'borderBottomWidth')
71
+ : 0;
72
+ const parentBorderLeft = convertCssPropertyToNumber(parentStyle, 'borderLeftWidth');
73
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
74
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
75
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
76
+ }
77
+ else {
78
+ stickyTop = 0;
79
+ stickyBottom = 0;
80
+ }
81
+ }
82
+ const cssTop = stickyTop + topOffset;
83
+ const cssBottom = stickyBottom + bottomOffset;
52
84
  let stickyCssStyle = {};
53
85
  if (newStickyState) {
54
86
  stickyCssStyle = {
@@ -68,7 +100,7 @@ const Sticky = forwardRef((props, ref) => {
68
100
  : cssBottom + bottomFollowDifference,
69
101
  }
70
102
  : {}),
71
- left: placeholderClientRect.left,
103
+ left: stickyLeft,
72
104
  width: placeholderClientRect.width,
73
105
  ...(userSetStickyCssStyle || {}),
74
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arco-design/mobile-react",
3
- "version": "2.35.0",
3
+ "version": "2.35.1",
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.20.2",
18
+ "@arco-design/mobile-utils": "2.20.3",
19
19
  "@arco-design/transformable": "^1.0.0",
20
20
  "@babel/runtime": "^7",
21
21
  "lodash.throttle": "^4.1.1",
@@ -47,5 +47,5 @@
47
47
  "publishConfig": {
48
48
  "access": "public"
49
49
  },
50
- "gitHead": "efb0db8d0e3ecdd787266dce595b2990e80bbefa"
50
+ "gitHead": "f80cdb93f0ea56337715dc7218c997fafa5af0a9"
51
51
  }
@@ -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: DirectionType[];
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
@@ -96,9 +96,14 @@
96
96
  var _getScrollContainerRe = (0, _mobileUtils.getScrollContainerRect)(scrollContainerRef.current),
97
97
  containerRect = _getScrollContainerRe.containerRect;
98
98
 
99
- var containerTop = containerRect.top,
100
- containerBottom = containerRect.bottom,
99
+ var rectTop = containerRect.top,
100
+ rectBottom = containerRect.bottom,
101
101
  containerHeight = containerRect.height;
102
+ var scrollStyle = (0, _mobileUtils.safeGetComputedStyle)(scrollContainerRef.current);
103
+ var borderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderTopWidth') : 0;
104
+ var borderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(scrollStyle, 'borderBottomWidth') : 0;
105
+ var containerTop = rectTop + borderTop;
106
+ var containerBottom = rectBottom - borderBottom;
102
107
  var disFromTop = Math.round(placeholderClientRect.top - containerTop);
103
108
  var disFromBottom = Math.round(placeholderClientRect.top + calculatedHeight - containerBottom);
104
109
  var topFollowDifference = followBottom - followOffset - calculatedHeight - topOffset - containerTop;
@@ -107,8 +112,32 @@
107
112
  var isTopSticky = needTop ? disFromTop <= topOffset && followBottom > containerTop + followOffset : false;
108
113
  var isBottomSticky = needBottom ? disFromBottom >= -bottomOffset && followTop < containerBottom - followOffset : false;
109
114
  var newStickyState = isTopSticky || isBottomSticky;
110
- var cssTop = (stickyStyle === 'absolute' ? 0 : containerTop) + topOffset;
111
- var cssBottom = (stickyStyle === 'absolute' ? 0 : window.innerHeight - containerBottom) + bottomOffset;
115
+ var stickyTop = containerTop;
116
+ var stickyBottom = window.innerHeight - containerBottom;
117
+ var stickyLeft = placeholderClientRect.left;
118
+
119
+ if (stickyStyle === 'absolute') {
120
+ var offsetParent = contentRef.current.offsetParent;
121
+
122
+ if (offsetParent) {
123
+ var _getScrollContainerRe2 = (0, _mobileUtils.getScrollContainerRect)(offsetParent),
124
+ parentRect = _getScrollContainerRe2.containerRect;
125
+
126
+ var parentStyle = (0, _mobileUtils.safeGetComputedStyle)(offsetParent);
127
+ var parentBorderTop = needTop ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderTopWidth') : 0;
128
+ var parentBorderBottom = needBottom ? (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderBottomWidth') : 0;
129
+ var parentBorderLeft = (0, _mobileUtils.convertCssPropertyToNumber)(parentStyle, 'borderLeftWidth');
130
+ stickyTop = containerTop - parentRect.top - parentBorderTop;
131
+ stickyBottom = parentRect.bottom - containerBottom - parentBorderBottom;
132
+ stickyLeft = placeholderClientRect.left - parentRect.left - parentBorderLeft;
133
+ } else {
134
+ stickyTop = 0;
135
+ stickyBottom = 0;
136
+ }
137
+ }
138
+
139
+ var cssTop = stickyTop + topOffset;
140
+ var cssBottom = stickyBottom + bottomOffset;
112
141
  var stickyCssStyle = {};
113
142
 
114
143
  if (newStickyState) {
@@ -122,7 +151,7 @@
122
151
  } : {}, isBottomSticky ? {
123
152
  bottom: bottomFollowDifference > 0 ? cssBottom : cssBottom + bottomFollowDifference
124
153
  } : {}, {
125
- left: placeholderClientRect.left,
154
+ left: stickyLeft,
126
155
  width: placeholderClientRect.width
127
156
  }, userSetStickyCssStyle || {});
128
157
  }