@rc-component/trigger 3.7.1 → 3.7.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/es/hooks/useAlign.js +12 -10
- package/es/util.js +3 -2
- package/lib/hooks/useAlign.js +12 -10
- package/lib/util.js +3 -2
- package/package.json +1 -1
package/es/hooks/useAlign.js
CHANGED
|
@@ -54,12 +54,12 @@ function reversePoints(points, index) {
|
|
|
54
54
|
l: 'r',
|
|
55
55
|
r: 'l'
|
|
56
56
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
const clone = [...points];
|
|
58
|
+
clone[index] = reverseMap[points[index]] || 'c';
|
|
59
|
+
return clone;
|
|
60
|
+
}
|
|
61
|
+
function flatPoints(points) {
|
|
62
|
+
return points.join('');
|
|
63
63
|
}
|
|
64
64
|
export default function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign, mobile) {
|
|
65
65
|
const [offsetInfo, setOffsetInfo] = React.useState({
|
|
@@ -245,6 +245,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
245
245
|
const nextAlignInfo = {
|
|
246
246
|
...placementInfo
|
|
247
247
|
};
|
|
248
|
+
let nextPoints = [popupPoints, targetPoints];
|
|
248
249
|
|
|
249
250
|
// Next Offset
|
|
250
251
|
let nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
|
|
@@ -322,7 +323,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
322
323
|
prevFlipRef.current.bt = true;
|
|
323
324
|
nextOffsetY = tmpNextOffsetY;
|
|
324
325
|
popupOffsetY = -popupOffsetY;
|
|
325
|
-
|
|
326
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
326
327
|
} else {
|
|
327
328
|
prevFlipRef.current.bt = false;
|
|
328
329
|
}
|
|
@@ -346,7 +347,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
346
347
|
prevFlipRef.current.tb = true;
|
|
347
348
|
nextOffsetY = tmpNextOffsetY;
|
|
348
349
|
popupOffsetY = -popupOffsetY;
|
|
349
|
-
|
|
350
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
350
351
|
} else {
|
|
351
352
|
prevFlipRef.current.tb = false;
|
|
352
353
|
}
|
|
@@ -376,7 +377,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
376
377
|
prevFlipRef.current.rl = true;
|
|
377
378
|
nextOffsetX = tmpNextOffsetX;
|
|
378
379
|
popupOffsetX = -popupOffsetX;
|
|
379
|
-
|
|
380
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
380
381
|
} else {
|
|
381
382
|
prevFlipRef.current.rl = false;
|
|
382
383
|
}
|
|
@@ -400,11 +401,12 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
400
401
|
prevFlipRef.current.lr = true;
|
|
401
402
|
nextOffsetX = tmpNextOffsetX;
|
|
402
403
|
popupOffsetX = -popupOffsetX;
|
|
403
|
-
|
|
404
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
404
405
|
} else {
|
|
405
406
|
prevFlipRef.current.lr = false;
|
|
406
407
|
}
|
|
407
408
|
}
|
|
409
|
+
nextAlignInfo.points = [flatPoints(nextPoints[0]), flatPoints(nextPoints[1])];
|
|
408
410
|
|
|
409
411
|
// ============================ Shift ============================
|
|
410
412
|
syncNextPopupPosition();
|
package/es/util.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
function isPointsEq(a1 = [], a2 = [], isAlignPoint) {
|
|
2
|
+
const getVal = (a, index) => a[index] || '';
|
|
2
3
|
if (isAlignPoint) {
|
|
3
|
-
return a1
|
|
4
|
+
return getVal(a1, 0) === getVal(a2, 0);
|
|
4
5
|
}
|
|
5
|
-
return a1
|
|
6
|
+
return getVal(a1, 0) === getVal(a2, 0) && getVal(a1, 1) === getVal(a2, 1);
|
|
6
7
|
}
|
|
7
8
|
export function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
|
|
8
9
|
const {
|
package/lib/hooks/useAlign.js
CHANGED
|
@@ -63,12 +63,12 @@ function reversePoints(points, index) {
|
|
|
63
63
|
l: 'r',
|
|
64
64
|
r: 'l'
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
const clone = [...points];
|
|
67
|
+
clone[index] = reverseMap[points[index]] || 'c';
|
|
68
|
+
return clone;
|
|
69
|
+
}
|
|
70
|
+
function flatPoints(points) {
|
|
71
|
+
return points.join('');
|
|
72
72
|
}
|
|
73
73
|
function useAlign(open, popupEle, target, placement, builtinPlacements, popupAlign, onPopupAlign, mobile) {
|
|
74
74
|
const [offsetInfo, setOffsetInfo] = React.useState({
|
|
@@ -254,6 +254,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
254
254
|
const nextAlignInfo = {
|
|
255
255
|
...placementInfo
|
|
256
256
|
};
|
|
257
|
+
let nextPoints = [popupPoints, targetPoints];
|
|
257
258
|
|
|
258
259
|
// Next Offset
|
|
259
260
|
let nextOffsetX = targetAlignPoint.x - popupAlignPoint.x + popupOffsetX;
|
|
@@ -331,7 +332,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
331
332
|
prevFlipRef.current.bt = true;
|
|
332
333
|
nextOffsetY = tmpNextOffsetY;
|
|
333
334
|
popupOffsetY = -popupOffsetY;
|
|
334
|
-
|
|
335
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
335
336
|
} else {
|
|
336
337
|
prevFlipRef.current.bt = false;
|
|
337
338
|
}
|
|
@@ -355,7 +356,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
355
356
|
prevFlipRef.current.tb = true;
|
|
356
357
|
nextOffsetY = tmpNextOffsetY;
|
|
357
358
|
popupOffsetY = -popupOffsetY;
|
|
358
|
-
|
|
359
|
+
nextPoints = [reversePoints(nextPoints[0], 0), reversePoints(nextPoints[1], 0)];
|
|
359
360
|
} else {
|
|
360
361
|
prevFlipRef.current.tb = false;
|
|
361
362
|
}
|
|
@@ -385,7 +386,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
385
386
|
prevFlipRef.current.rl = true;
|
|
386
387
|
nextOffsetX = tmpNextOffsetX;
|
|
387
388
|
popupOffsetX = -popupOffsetX;
|
|
388
|
-
|
|
389
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
389
390
|
} else {
|
|
390
391
|
prevFlipRef.current.rl = false;
|
|
391
392
|
}
|
|
@@ -409,11 +410,12 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
409
410
|
prevFlipRef.current.lr = true;
|
|
410
411
|
nextOffsetX = tmpNextOffsetX;
|
|
411
412
|
popupOffsetX = -popupOffsetX;
|
|
412
|
-
|
|
413
|
+
nextPoints = [reversePoints(nextPoints[0], 1), reversePoints(nextPoints[1], 1)];
|
|
413
414
|
} else {
|
|
414
415
|
prevFlipRef.current.lr = false;
|
|
415
416
|
}
|
|
416
417
|
}
|
|
418
|
+
nextAlignInfo.points = [flatPoints(nextPoints[0]), flatPoints(nextPoints[1])];
|
|
417
419
|
|
|
418
420
|
// ============================ Shift ============================
|
|
419
421
|
syncNextPopupPosition();
|
package/lib/util.js
CHANGED
|
@@ -9,10 +9,11 @@ exports.getVisibleArea = getVisibleArea;
|
|
|
9
9
|
exports.getWin = getWin;
|
|
10
10
|
exports.toNum = toNum;
|
|
11
11
|
function isPointsEq(a1 = [], a2 = [], isAlignPoint) {
|
|
12
|
+
const getVal = (a, index) => a[index] || '';
|
|
12
13
|
if (isAlignPoint) {
|
|
13
|
-
return a1
|
|
14
|
+
return getVal(a1, 0) === getVal(a2, 0);
|
|
14
15
|
}
|
|
15
|
-
return a1
|
|
16
|
+
return getVal(a1, 0) === getVal(a2, 0) && getVal(a1, 1) === getVal(a2, 1);
|
|
16
17
|
}
|
|
17
18
|
function getAlignPopupClassName(builtinPlacements, prefixCls, align, isAlignPoint) {
|
|
18
19
|
const {
|