@sheinx/hooks 3.4.4-beta.6 → 3.4.4-beta.8
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.
@@ -139,7 +139,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
139
139
|
}
|
140
140
|
var targetPosition = position;
|
141
141
|
var rootContainer = getContainer() || document.body;
|
142
|
-
var closestScrollContainer = (0, _element.getClosestScrollContainer)(parentElRef.current);
|
142
|
+
var closestScrollContainer = absolute ? null : (0, _element.getClosestScrollContainer)(parentElRef.current);
|
143
143
|
var containerRect = rootContainer.getBoundingClientRect();
|
144
144
|
var bodyRect = (document.documentElement || document.body).getBoundingClientRect();
|
145
145
|
var containerScrollBarWidth = rootContainer.offsetWidth - rootContainer.clientWidth;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":"AAkGA,eAAO,MAAM,WAAW,WACd,WAAW,GAAG,IAAI,2EAEpB,SAAS,GAAG,MAAM,GAAG,MAAM,UACzB,WAAW,gKAKpB,CAAC"}
|
package/cjs/utils/position.js
CHANGED
@@ -66,22 +66,23 @@ var getPopoverPosition = function getPopoverPosition(target) {
|
|
66
66
|
var popupRect = popup === null || popup === void 0 ? void 0 : popup.getBoundingClientRect();
|
67
67
|
if (verticalPoint > windowHeight / 2) position = 'top';else position = 'bottom';
|
68
68
|
|
69
|
+
// TODO: 暂时移除,另考虑方案
|
69
70
|
// 如果渲染了弹出内容,则根据弹出内容宽度计算是否自动调整位置
|
70
|
-
if (popupRect) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
} else {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
}
|
71
|
+
// if (popupRect && popupRect?.width) {
|
72
|
+
// if (popupRect?.width / 2 > rect.left) {
|
73
|
+
// position += '-left';
|
74
|
+
// }
|
75
|
+
// if (popupRect?.width / 2 > windowWidth - rect.right) {
|
76
|
+
// position += '-right';
|
77
|
+
// }
|
78
|
+
// } else {
|
79
|
+
// 兜底计算
|
80
|
+
if (horizontalPoint > windowWidth * 0.6) {
|
81
|
+
position += '-right';
|
82
|
+
} else if (horizontalPoint < windowWidth * 0.4) {
|
83
|
+
position += '-left';
|
84
84
|
}
|
85
|
+
// }
|
85
86
|
}
|
86
87
|
return position;
|
87
88
|
};
|
@@ -129,7 +129,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
129
129
|
}
|
130
130
|
var targetPosition = position;
|
131
131
|
var rootContainer = getContainer() || document.body;
|
132
|
-
var closestScrollContainer = getClosestScrollContainer(parentElRef.current);
|
132
|
+
var closestScrollContainer = absolute ? null : getClosestScrollContainer(parentElRef.current);
|
133
133
|
var containerRect = rootContainer.getBoundingClientRect();
|
134
134
|
var bodyRect = (document.documentElement || document.body).getBoundingClientRect();
|
135
135
|
var containerScrollBarWidth = rootContainer.offsetWidth - rootContainer.clientWidth;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"position.d.ts","sourceRoot":"","sources":["position.ts"],"names":[],"mappings":"AAkGA,eAAO,MAAM,WAAW,WACd,WAAW,GAAG,IAAI,2EAEpB,SAAS,GAAG,MAAM,GAAG,MAAM,UACzB,WAAW,gKAKpB,CAAC"}
|
package/esm/utils/position.js
CHANGED
@@ -60,22 +60,23 @@ var getPopoverPosition = function getPopoverPosition(target) {
|
|
60
60
|
var popupRect = popup === null || popup === void 0 ? void 0 : popup.getBoundingClientRect();
|
61
61
|
if (verticalPoint > windowHeight / 2) position = 'top';else position = 'bottom';
|
62
62
|
|
63
|
+
// TODO: 暂时移除,另考虑方案
|
63
64
|
// 如果渲染了弹出内容,则根据弹出内容宽度计算是否自动调整位置
|
64
|
-
if (popupRect) {
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
} else {
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
}
|
65
|
+
// if (popupRect && popupRect?.width) {
|
66
|
+
// if (popupRect?.width / 2 > rect.left) {
|
67
|
+
// position += '-left';
|
68
|
+
// }
|
69
|
+
// if (popupRect?.width / 2 > windowWidth - rect.right) {
|
70
|
+
// position += '-right';
|
71
|
+
// }
|
72
|
+
// } else {
|
73
|
+
// 兜底计算
|
74
|
+
if (horizontalPoint > windowWidth * 0.6) {
|
75
|
+
position += '-right';
|
76
|
+
} else if (horizontalPoint < windowWidth * 0.4) {
|
77
|
+
position += '-left';
|
78
78
|
}
|
79
|
+
// }
|
79
80
|
}
|
80
81
|
return position;
|
81
82
|
};
|