@rc-component/trigger 1.13.5 → 1.13.6
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 +16 -16
- package/lib/hooks/useAlign.js +16 -16
- package/package.json +1 -1
package/es/hooks/useAlign.js
CHANGED
|
@@ -379,36 +379,36 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
|
|
|
379
379
|
var numShiftX = shiftX === true ? 0 : shiftX;
|
|
380
380
|
if (typeof numShiftX === 'number') {
|
|
381
381
|
// Left
|
|
382
|
-
if (nextPopupX <
|
|
383
|
-
nextOffsetX -= nextPopupX -
|
|
384
|
-
if (targetRect.x + targetWidth <
|
|
385
|
-
nextOffsetX += targetRect.x -
|
|
382
|
+
if (nextPopupX < visibleRegionArea.left) {
|
|
383
|
+
nextOffsetX -= nextPopupX - visibleRegionArea.left;
|
|
384
|
+
if (targetRect.x + targetWidth < visibleRegionArea.left + numShiftX) {
|
|
385
|
+
nextOffsetX += targetRect.x - visibleRegionArea.left + targetWidth - numShiftX;
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
// Right
|
|
390
|
-
if (nextPopupRight >
|
|
391
|
-
nextOffsetX -= nextPopupRight -
|
|
392
|
-
if (targetRect.x >
|
|
393
|
-
nextOffsetX += targetRect.x -
|
|
390
|
+
if (nextPopupRight > visibleRegionArea.right) {
|
|
391
|
+
nextOffsetX -= nextPopupRight - visibleRegionArea.right;
|
|
392
|
+
if (targetRect.x > visibleRegionArea.right - numShiftX) {
|
|
393
|
+
nextOffsetX += targetRect.x - visibleRegionArea.right + numShiftX;
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
397
|
var numShiftY = shiftY === true ? 0 : shiftY;
|
|
398
398
|
if (typeof numShiftY === 'number') {
|
|
399
399
|
// Top
|
|
400
|
-
if (nextPopupY <
|
|
401
|
-
nextOffsetY -= nextPopupY -
|
|
402
|
-
if (targetRect.y + targetHeight <
|
|
403
|
-
nextOffsetY += targetRect.y -
|
|
400
|
+
if (nextPopupY < visibleRegionArea.top) {
|
|
401
|
+
nextOffsetY -= nextPopupY - visibleRegionArea.top;
|
|
402
|
+
if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
|
|
403
|
+
nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
// Bottom
|
|
408
|
-
if (nextPopupBottom >
|
|
409
|
-
nextOffsetY -= nextPopupBottom -
|
|
410
|
-
if (targetRect.y >
|
|
411
|
-
nextOffsetY += targetRect.y -
|
|
408
|
+
if (nextPopupBottom > visibleRegionArea.bottom) {
|
|
409
|
+
nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom;
|
|
410
|
+
if (targetRect.y > visibleRegionArea.bottom - numShiftY) {
|
|
411
|
+
nextOffsetY += targetRect.y - visibleRegionArea.bottom + numShiftY;
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
}
|
package/lib/hooks/useAlign.js
CHANGED
|
@@ -387,36 +387,36 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
|
|
|
387
387
|
var numShiftX = shiftX === true ? 0 : shiftX;
|
|
388
388
|
if (typeof numShiftX === 'number') {
|
|
389
389
|
// Left
|
|
390
|
-
if (nextPopupX <
|
|
391
|
-
nextOffsetX -= nextPopupX -
|
|
392
|
-
if (targetRect.x + targetWidth <
|
|
393
|
-
nextOffsetX += targetRect.x -
|
|
390
|
+
if (nextPopupX < visibleRegionArea.left) {
|
|
391
|
+
nextOffsetX -= nextPopupX - visibleRegionArea.left;
|
|
392
|
+
if (targetRect.x + targetWidth < visibleRegionArea.left + numShiftX) {
|
|
393
|
+
nextOffsetX += targetRect.x - visibleRegionArea.left + targetWidth - numShiftX;
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
|
|
397
397
|
// Right
|
|
398
|
-
if (nextPopupRight >
|
|
399
|
-
nextOffsetX -= nextPopupRight -
|
|
400
|
-
if (targetRect.x >
|
|
401
|
-
nextOffsetX += targetRect.x -
|
|
398
|
+
if (nextPopupRight > visibleRegionArea.right) {
|
|
399
|
+
nextOffsetX -= nextPopupRight - visibleRegionArea.right;
|
|
400
|
+
if (targetRect.x > visibleRegionArea.right - numShiftX) {
|
|
401
|
+
nextOffsetX += targetRect.x - visibleRegionArea.right + numShiftX;
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
var numShiftY = shiftY === true ? 0 : shiftY;
|
|
406
406
|
if (typeof numShiftY === 'number') {
|
|
407
407
|
// Top
|
|
408
|
-
if (nextPopupY <
|
|
409
|
-
nextOffsetY -= nextPopupY -
|
|
410
|
-
if (targetRect.y + targetHeight <
|
|
411
|
-
nextOffsetY += targetRect.y -
|
|
408
|
+
if (nextPopupY < visibleRegionArea.top) {
|
|
409
|
+
nextOffsetY -= nextPopupY - visibleRegionArea.top;
|
|
410
|
+
if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
|
|
411
|
+
nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
|
|
415
415
|
// Bottom
|
|
416
|
-
if (nextPopupBottom >
|
|
417
|
-
nextOffsetY -= nextPopupBottom -
|
|
418
|
-
if (targetRect.y >
|
|
419
|
-
nextOffsetY += targetRect.y -
|
|
416
|
+
if (nextPopupBottom > visibleRegionArea.bottom) {
|
|
417
|
+
nextOffsetY -= nextPopupBottom - visibleRegionArea.bottom;
|
|
418
|
+
if (targetRect.y > visibleRegionArea.bottom - numShiftY) {
|
|
419
|
+
nextOffsetY += targetRect.y - visibleRegionArea.bottom + numShiftY;
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
422
|
}
|