@@ -99,6 +99,8 @@ export default function useAlign(
99
99
ready : boolean ,
100
100
offsetX : number ,
101
101
offsetY : number ,
102
+ offsetR : number ,
103
+ offsetB : number ,
102
104
arrowX : number ,
103
105
arrowY : number ,
104
106
scaleX : number ,
@@ -110,6 +112,8 @@ export default function useAlign(
110
112
ready : boolean ;
111
113
offsetX : number ;
112
114
offsetY : number ;
115
+ offsetR : number ;
116
+ offsetB : number ;
113
117
arrowX : number ;
114
118
arrowY : number ;
115
119
scaleX : number ;
@@ -119,6 +123,8 @@ export default function useAlign(
119
123
ready : false ,
120
124
offsetX : 0 ,
121
125
offsetY : 0 ,
126
+ offsetR : 0 ,
127
+ offsetB : 0 ,
122
128
arrowX : 0 ,
123
129
arrowY : 0 ,
124
130
scaleX : 1 ,
@@ -160,6 +166,8 @@ export default function useAlign(
160
166
161
167
const originLeft = popupElement . style . left ;
162
168
const originTop = popupElement . style . top ;
169
+ const originRight = popupElement . style . right ;
170
+ const originBottom = popupElement . style . bottom ;
163
171
164
172
const doc = popupElement . ownerDocument ;
165
173
const win = getWin ( popupElement ) ;
@@ -173,6 +181,8 @@ export default function useAlign(
173
181
// Reset first
174
182
popupElement . style . left = '0' ;
175
183
popupElement . style . top = '0' ;
184
+ popupElement . style . right = 'auto' ;
185
+ popupElement . style . bottom = 'auto' ;
176
186
177
187
// Calculate align style, we should consider `transform` case
178
188
let targetRect : Rect ;
@@ -244,9 +254,19 @@ export default function useAlign(
244
254
? visibleRegionArea
245
255
: visibleArea ;
246
256
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
+
247
265
// Reset back
248
266
popupElement . style . left = originLeft ;
249
267
popupElement . style . top = originTop ;
268
+ popupElement . style . right = originRight ;
269
+ popupElement . style . bottom = originBottom ;
250
270
251
271
// Calculate scale
252
272
const scaleX = toNum (
@@ -622,10 +642,18 @@ export default function useAlign(
622
642
623
643
onPopupAlign ?.( popupEle , nextAlignInfo ) ;
624
644
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
+
625
651
setOffsetInfo ( {
626
652
ready : true ,
627
653
offsetX : nextOffsetX / scaleX ,
628
654
offsetY : nextOffsetY / scaleY ,
655
+ offsetR : offsetX4Right / scaleX ,
656
+ offsetB : offsetY4Bottom / scaleY ,
629
657
arrowX : nextArrowX / scaleX ,
630
658
arrowY : nextArrowY / scaleY ,
631
659
scaleX,
@@ -667,6 +695,8 @@ export default function useAlign(
667
695
offsetInfo . ready ,
668
696
offsetInfo . offsetX ,
669
697
offsetInfo . offsetY ,
698
+ offsetInfo . offsetR ,
699
+ offsetInfo . offsetB ,
670
700
offsetInfo . arrowX ,
671
701
offsetInfo . arrowY ,
672
702
offsetInfo . scaleX ,
0 commit comments