x-ui-design 0.8.87 → 0.8.88

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/dist/index.esm.js CHANGED
@@ -2630,43 +2630,44 @@ const usePopupPosition = ({
2630
2630
  return;
2631
2631
  }
2632
2632
  const _calculation = () => {
2633
- const _bottomCollectionTop = !_placement.includes('bottom') ? 0 : (inBody ? (targetRef.current?.offsetTop || 0) + (targetRef.current?.clientHeight || 0) - (scrollableParents?.scrollTop || 0) + (scrollableParents?.offsetTop || 0) : (targetRef.current?.offsetTop || 0) + (targetRef.current?.clientHeight || 0)) + OFFSET;
2634
- const _topCollectionTop = !_placement.includes('top') ? 0 : (inBody ? (targetRef.current?.offsetTop || 0) - (popupRef.current?.clientHeight || 0) - (scrollableParents?.scrollTop || 0) + (scrollableParents?.offsetTop || 0) : (targetRef.current?.offsetTop || 0) - (popupRef.current?.clientHeight || 0)) - OFFSET;
2633
+ const _placementBottom = !_placement.includes('bottom') ? 0 : (inBody ? (targetRef.current?.offsetTop || 0) + (targetRef.current?.clientHeight || 0) - (scrollableParents?.scrollTop || 0) + (scrollableParents?.offsetTop || 0) : (targetRef.current?.offsetTop || 0) + (targetRef.current?.clientHeight || 0)) + OFFSET;
2634
+ const _placementTop = !_placement.includes('top') ? 0 : (inBody ? (targetRef.current?.offsetTop || 0) - (popupRef.current?.clientHeight || 0) - (scrollableParents?.scrollTop || 0) + (scrollableParents?.offsetTop || 0) : (targetRef.current?.offsetTop || 0) - (popupRef.current?.clientHeight || 0)) - OFFSET;
2635
+ const _positionLeft = inBody ? container.left : targetRef.current?.offsetLeft || 0;
2635
2636
  switch (_placement) {
2636
2637
  case "bottom":
2637
2638
  setPopupPosition({
2638
- top: _bottomCollectionTop,
2639
- left: (targetRef.current?.offsetLeft || 0) + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2639
+ top: _placementBottom,
2640
+ left: _positionLeft + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2640
2641
  });
2641
2642
  break;
2642
2643
  case "bottomLeft":
2643
2644
  setPopupPosition({
2644
- top: _bottomCollectionTop,
2645
- left: targetRef.current?.offsetLeft || 0
2645
+ top: _placementBottom,
2646
+ left: _positionLeft
2646
2647
  });
2647
2648
  break;
2648
2649
  case "bottomRight":
2649
2650
  setPopupPosition({
2650
- top: _bottomCollectionTop,
2651
- left: (targetRef.current?.offsetLeft || 0) + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2651
+ top: _placementBottom,
2652
+ left: _positionLeft + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2652
2653
  });
2653
2654
  break;
2654
2655
  case "top":
2655
2656
  setPopupPosition({
2656
- top: _topCollectionTop,
2657
- left: (targetRef.current?.offsetLeft || 0) + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2657
+ top: _placementTop,
2658
+ left: _positionLeft + (container.width || 0) / 2 - (popupRef.current?.offsetWidth || 0) / 2
2658
2659
  });
2659
2660
  break;
2660
2661
  case "topLeft":
2661
2662
  setPopupPosition({
2662
- top: _topCollectionTop,
2663
- left: targetRef.current?.offsetLeft || 0
2663
+ top: _placementTop,
2664
+ left: _positionLeft
2664
2665
  });
2665
2666
  break;
2666
2667
  case "topRight":
2667
2668
  setPopupPosition({
2668
- top: _topCollectionTop,
2669
- left: (targetRef.current?.offsetLeft || 0) + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2669
+ top: _placementTop,
2670
+ left: _positionLeft + (container.width || 0) - (popupRef.current?.offsetWidth || 0)
2670
2671
  });
2671
2672
  break;
2672
2673
  }