@rc-component/trigger 1.15.2 → 1.15.3

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.
@@ -308,6 +308,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
308
308
  newVisibleRecommendArea >= originIntersectionRecommendArea)) {
309
309
  prevFlipRef.current.bt = true;
310
310
  nextOffsetY = tmpNextOffsetY;
311
+ popupOffsetY = -popupOffsetY;
311
312
  nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
312
313
  } else {
313
314
  prevFlipRef.current.bt = false;
@@ -331,6 +332,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
331
332
  _newVisibleRecommendArea >= originIntersectionRecommendArea)) {
332
333
  prevFlipRef.current.tb = true;
333
334
  nextOffsetY = _tmpNextOffsetY;
335
+ popupOffsetY = -popupOffsetY;
334
336
  nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
335
337
  } else {
336
338
  prevFlipRef.current.tb = false;
@@ -360,6 +362,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
360
362
  _newVisibleRecommendArea2 >= originIntersectionRecommendArea)) {
361
363
  prevFlipRef.current.rl = true;
362
364
  nextOffsetX = tmpNextOffsetX;
365
+ popupOffsetX = -popupOffsetX;
363
366
  nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
364
367
  } else {
365
368
  prevFlipRef.current.rl = false;
@@ -383,6 +386,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
383
386
  _newVisibleRecommendArea3 >= originIntersectionRecommendArea)) {
384
387
  prevFlipRef.current.lr = true;
385
388
  nextOffsetX = _tmpNextOffsetX;
389
+ popupOffsetX = -popupOffsetX;
386
390
  nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
387
391
  } else {
388
392
  prevFlipRef.current.lr = false;
@@ -395,7 +399,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
395
399
  if (typeof numShiftX === 'number') {
396
400
  // Left
397
401
  if (nextPopupX < visibleRegionArea.left) {
398
- nextOffsetX -= nextPopupX - visibleRegionArea.left;
402
+ nextOffsetX -= nextPopupX - visibleRegionArea.left - popupOffsetX;
399
403
  if (targetRect.x + targetWidth < visibleRegionArea.left + numShiftX) {
400
404
  nextOffsetX += targetRect.x - visibleRegionArea.left + targetWidth - numShiftX;
401
405
  }
@@ -403,7 +407,7 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
403
407
 
404
408
  // Right
405
409
  if (nextPopupRight > visibleRegionArea.right) {
406
- nextOffsetX -= nextPopupRight - visibleRegionArea.right;
410
+ nextOffsetX -= nextPopupRight - visibleRegionArea.right - popupOffsetX;
407
411
  if (targetRect.x > visibleRegionArea.right - numShiftX) {
408
412
  nextOffsetX += targetRect.x - visibleRegionArea.right + numShiftX;
409
413
  }
@@ -413,7 +417,10 @@ export default function useAlign(open, popupEle, target, placement, builtinPlace
413
417
  if (typeof numShiftY === 'number') {
414
418
  // Top
415
419
  if (nextPopupY < visibleRegionArea.top) {
416
- nextOffsetY -= nextPopupY - visibleRegionArea.top + popupOffsetY;
420
+ nextOffsetY -= nextPopupY - visibleRegionArea.top - popupOffsetY;
421
+
422
+ // When target if far away from visible area
423
+ // Stop shift
417
424
  if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
418
425
  nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
419
426
  }
@@ -316,6 +316,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
316
316
  newVisibleRecommendArea >= originIntersectionRecommendArea)) {
317
317
  prevFlipRef.current.bt = true;
318
318
  nextOffsetY = tmpNextOffsetY;
319
+ popupOffsetY = -popupOffsetY;
319
320
  nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
320
321
  } else {
321
322
  prevFlipRef.current.bt = false;
@@ -339,6 +340,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
339
340
  _newVisibleRecommendArea >= originIntersectionRecommendArea)) {
340
341
  prevFlipRef.current.tb = true;
341
342
  nextOffsetY = _tmpNextOffsetY;
343
+ popupOffsetY = -popupOffsetY;
342
344
  nextAlignInfo.points = [reversePoints(popupPoints, 0), reversePoints(targetPoints, 0)];
343
345
  } else {
344
346
  prevFlipRef.current.tb = false;
@@ -368,6 +370,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
368
370
  _newVisibleRecommendArea2 >= originIntersectionRecommendArea)) {
369
371
  prevFlipRef.current.rl = true;
370
372
  nextOffsetX = tmpNextOffsetX;
373
+ popupOffsetX = -popupOffsetX;
371
374
  nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
372
375
  } else {
373
376
  prevFlipRef.current.rl = false;
@@ -391,6 +394,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
391
394
  _newVisibleRecommendArea3 >= originIntersectionRecommendArea)) {
392
395
  prevFlipRef.current.lr = true;
393
396
  nextOffsetX = _tmpNextOffsetX;
397
+ popupOffsetX = -popupOffsetX;
394
398
  nextAlignInfo.points = [reversePoints(popupPoints, 1), reversePoints(targetPoints, 1)];
395
399
  } else {
396
400
  prevFlipRef.current.lr = false;
@@ -403,7 +407,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
403
407
  if (typeof numShiftX === 'number') {
404
408
  // Left
405
409
  if (nextPopupX < visibleRegionArea.left) {
406
- nextOffsetX -= nextPopupX - visibleRegionArea.left;
410
+ nextOffsetX -= nextPopupX - visibleRegionArea.left - popupOffsetX;
407
411
  if (targetRect.x + targetWidth < visibleRegionArea.left + numShiftX) {
408
412
  nextOffsetX += targetRect.x - visibleRegionArea.left + targetWidth - numShiftX;
409
413
  }
@@ -411,7 +415,7 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
411
415
 
412
416
  // Right
413
417
  if (nextPopupRight > visibleRegionArea.right) {
414
- nextOffsetX -= nextPopupRight - visibleRegionArea.right;
418
+ nextOffsetX -= nextPopupRight - visibleRegionArea.right - popupOffsetX;
415
419
  if (targetRect.x > visibleRegionArea.right - numShiftX) {
416
420
  nextOffsetX += targetRect.x - visibleRegionArea.right + numShiftX;
417
421
  }
@@ -421,7 +425,10 @@ function useAlign(open, popupEle, target, placement, builtinPlacements, popupAli
421
425
  if (typeof numShiftY === 'number') {
422
426
  // Top
423
427
  if (nextPopupY < visibleRegionArea.top) {
424
- nextOffsetY -= nextPopupY - visibleRegionArea.top + popupOffsetY;
428
+ nextOffsetY -= nextPopupY - visibleRegionArea.top - popupOffsetY;
429
+
430
+ // When target if far away from visible area
431
+ // Stop shift
425
432
  if (targetRect.y + targetHeight < visibleRegionArea.top + numShiftY) {
426
433
  nextOffsetY += targetRect.y - visibleRegionArea.top + targetHeight - numShiftY;
427
434
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rc-component/trigger",
3
- "version": "1.15.2",
3
+ "version": "1.15.3",
4
4
  "description": "base abstract trigger component for react",
5
5
  "engines": {
6
6
  "node": ">=8.x"