plain-design 1.0.0-beta.91 → 1.0.0-beta.92
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +1 -1
- package/src/packages/components/usePopup/refresh/MaxMinTopLeft.ts +38 -0
- package/src/packages/components/usePopup/refresh/calcPosition.ts +2 -18
- package/src/packages/components/usePopup/refresh/refreshPopup.ts +3 -1
package/package.json
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
import {iPopupRefreshBuildParams} from "../utils/popup.utils";
|
2
|
+
|
3
|
+
export function MaxMinTopLeft(
|
4
|
+
{
|
5
|
+
top,
|
6
|
+
left,
|
7
|
+
buildParams,
|
8
|
+
option,
|
9
|
+
}: {
|
10
|
+
top: number,
|
11
|
+
left: number,
|
12
|
+
buildParams: iPopupRefreshBuildParams,
|
13
|
+
option: {
|
14
|
+
maxTop?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
15
|
+
minTop?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
16
|
+
maxLeft?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
17
|
+
minLeft?: number | ((buildParams: iPopupRefreshBuildParams) => number),
|
18
|
+
}
|
19
|
+
}
|
20
|
+
): { top: number, left: number } {
|
21
|
+
if (option.maxTop != null) {
|
22
|
+
const maxTop = typeof option.maxTop === "function" ? option.maxTop(buildParams) : option.maxTop;
|
23
|
+
if (top > maxTop) {top = maxTop;}
|
24
|
+
}
|
25
|
+
if (option.minTop != null) {
|
26
|
+
const minTop = typeof option.minTop === "function" ? option.minTop(buildParams) : option.minTop;
|
27
|
+
if (top < minTop) {top = minTop;}
|
28
|
+
}
|
29
|
+
if (option.maxLeft != null) {
|
30
|
+
const maxLeft = typeof option.maxLeft === "function" ? option.maxLeft(buildParams) : option.maxLeft;
|
31
|
+
if (left > maxLeft) {left = maxLeft;}
|
32
|
+
}
|
33
|
+
if (option.minLeft != null) {
|
34
|
+
const minLeft = typeof option.minLeft === "function" ? option.minLeft(buildParams) : option.minLeft;
|
35
|
+
if (left < minLeft) {left = minLeft;}
|
36
|
+
}
|
37
|
+
return { top, left };
|
38
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import {iPopupRefreshBuildParams} from "../utils/popup.utils";
|
2
2
|
import {handleDirection} from "../utils/handleDirection";
|
3
|
+
import {MaxMinTopLeft} from "./MaxMinTopLeft";
|
3
4
|
|
4
5
|
/**
|
5
6
|
* 计算popup根节点定位信息
|
@@ -83,22 +84,5 @@ export function calcPosition(
|
|
83
84
|
if (left > maxLeft) {left = maxLeft;}
|
84
85
|
}
|
85
86
|
|
86
|
-
|
87
|
-
const maxTop = typeof option.maxTop === "function" ? option.maxTop(buildParams) : option.maxTop;
|
88
|
-
if (top! > maxTop) {top = maxTop;}
|
89
|
-
}
|
90
|
-
if (option.minTop != null) {
|
91
|
-
const minTop = typeof option.minTop === "function" ? option.minTop(buildParams) : option.minTop;
|
92
|
-
if (top! < minTop) {top = minTop;}
|
93
|
-
}
|
94
|
-
if (option.maxLeft != null) {
|
95
|
-
const maxLeft = typeof option.maxLeft === "function" ? option.maxLeft(buildParams) : option.maxLeft;
|
96
|
-
if (left! > maxLeft) {left = maxLeft;}
|
97
|
-
}
|
98
|
-
if (option.minLeft != null) {
|
99
|
-
const minLeft = typeof option.minLeft === "function" ? option.minLeft(buildParams) : option.minLeft;
|
100
|
-
if (left! < minLeft) {left = minLeft;}
|
101
|
-
}
|
102
|
-
|
103
|
-
return { top: top!, left: left! };
|
87
|
+
return MaxMinTopLeft({ top: top!, left: left!, buildParams, option, });
|
104
88
|
}
|
@@ -5,6 +5,7 @@ import {calcPosition} from "./calcPosition";
|
|
5
5
|
import {applyPosition} from "./applyPosition";
|
6
6
|
import {refreshArrow} from "./refreshArrow";
|
7
7
|
import {getRects} from "../utils/getRects";
|
8
|
+
import {MaxMinTopLeft} from "./MaxMinTopLeft";
|
8
9
|
|
9
10
|
/**
|
10
11
|
* 刷新popup定位
|
@@ -64,7 +65,8 @@ export function refreshPopup(params: iPopupRefreshParams) {
|
|
64
65
|
buildParams.rects = getRects(refs);
|
65
66
|
refreshArrow(buildParams);
|
66
67
|
} else {
|
67
|
-
const { top, left, height, width } = rects.alignReference;
|
68
|
+
const { top: _top, left: _left, height, width } = rects.alignReference;
|
69
|
+
const { top, left } = MaxMinTopLeft({ top: _top!, left: _left!, buildParams, option, });
|
68
70
|
Object.assign(refs.popupEl.style, {
|
69
71
|
...params.transformLocation ? { transform: `translate3d(${left}px,${top}px,0)` } : { top: `${top}px`, left: `${left}px`, },
|
70
72
|
height: `${height}px`,
|