@@ -99,6 +99,8 @@ export default function useAlign(
9999 ready : boolean ,
100100 offsetX : number ,
101101 offsetY : number ,
102+ offsetR : number ,
103+ offsetB : number ,
102104 arrowX : number ,
103105 arrowY : number ,
104106 scaleX : number ,
@@ -110,6 +112,8 @@ export default function useAlign(
110112 ready : boolean ;
111113 offsetX : number ;
112114 offsetY : number ;
115+ offsetR : number ;
116+ offsetB : number ;
113117 arrowX : number ;
114118 arrowY : number ;
115119 scaleX : number ;
@@ -119,6 +123,8 @@ export default function useAlign(
119123 ready : false ,
120124 offsetX : 0 ,
121125 offsetY : 0 ,
126+ offsetR : 0 ,
127+ offsetB : 0 ,
122128 arrowX : 0 ,
123129 arrowY : 0 ,
124130 scaleX : 1 ,
@@ -160,6 +166,8 @@ export default function useAlign(
160166
161167 const originLeft = popupElement . style . left ;
162168 const originTop = popupElement . style . top ;
169+ const originRight = popupElement . style . right ;
170+ const originBottom = popupElement . style . bottom ;
163171
164172 const doc = popupElement . ownerDocument ;
165173 const win = getWin ( popupElement ) ;
@@ -173,6 +181,8 @@ export default function useAlign(
173181 // Reset first
174182 popupElement . style . left = '0' ;
175183 popupElement . style . top = '0' ;
184+ popupElement . style . right = 'auto' ;
185+ popupElement . style . bottom = 'auto' ;
176186
177187 // Calculate align style, we should consider `transform` case
178188 let targetRect : Rect ;
@@ -244,9 +254,19 @@ export default function useAlign(
244254 ? visibleRegionArea
245255 : visibleArea ;
246256
257+ // Record right & bottom align data
258+ popupElement . style . left = 'auto' ;
259+ popupElement . style . top = 'auto' ;
260+ popupElement . style . right = '0' ;
261+ popupElement . style . bottom = '0' ;
262+
263+ const popupMirrorRect = popupElement . getBoundingClientRect ( ) ;
264+
247265 // Reset back
248266 popupElement . style . left = originLeft ;
249267 popupElement . style . top = originTop ;
268+ popupElement . style . right = originRight ;
269+ popupElement . style . bottom = originBottom ;
250270
251271 // Calculate scale
252272 const scaleX = toNum (
@@ -622,10 +642,18 @@ export default function useAlign(
622642
623643 onPopupAlign ?.( popupEle , nextAlignInfo ) ;
624644
645+ // Additional calculate right & bottom position
646+ const offsetX4Right =
647+ popupMirrorRect . right - popupRect . x - ( nextOffsetX + popupRect . width ) ;
648+ const offsetY4Bottom =
649+ popupMirrorRect . bottom - popupRect . y - ( nextOffsetY + popupRect . height ) ;
650+
625651 setOffsetInfo ( {
626652 ready : true ,
627653 offsetX : nextOffsetX / scaleX ,
628654 offsetY : nextOffsetY / scaleY ,
655+ offsetR : offsetX4Right / scaleX ,
656+ offsetB : offsetY4Bottom / scaleY ,
629657 arrowX : nextArrowX / scaleX ,
630658 arrowY : nextArrowY / scaleY ,
631659 scaleX,
@@ -667,6 +695,8 @@ export default function useAlign(
667695 offsetInfo . ready ,
668696 offsetInfo . offsetX ,
669697 offsetInfo . offsetY ,
698+ offsetInfo . offsetR ,
699+ offsetInfo . offsetB ,
670700 offsetInfo . arrowX ,
671701 offsetInfo . arrowY ,
672702 offsetInfo . scaleX ,
0 commit comments