@@ -164,20 +164,35 @@ export default function useAlign(
164
164
if ( popupEle && target && open ) {
165
165
const popupElement = popupEle ;
166
166
167
+ const doc = popupElement . ownerDocument ;
168
+ const win = getWin ( popupElement ) ;
169
+
170
+ const {
171
+ width,
172
+ height,
173
+ position : popupPosition ,
174
+ } = win . getComputedStyle ( popupElement ) ;
175
+
167
176
const originLeft = popupElement . style . left ;
168
177
const originTop = popupElement . style . top ;
169
178
const originRight = popupElement . style . right ;
170
179
const originBottom = popupElement . style . bottom ;
171
180
172
- const doc = popupElement . ownerDocument ;
173
- const win = getWin ( popupElement ) ;
174
-
175
181
// Placement
176
182
const placementInfo : AlignType = {
177
183
...builtinPlacements [ placement ] ,
178
184
...popupAlign ,
179
185
} ;
180
186
187
+ // placeholder element
188
+ const placeholderElement = doc . createElement ( 'div' ) ;
189
+ popupElement . parentElement ?. appendChild ( placeholderElement ) ;
190
+ placeholderElement . style . left = `${ popupElement . offsetLeft } px` ;
191
+ placeholderElement . style . top = `${ popupElement . offsetTop } px` ;
192
+ placeholderElement . style . position = popupPosition ;
193
+ placeholderElement . style . height = `${ popupElement . offsetHeight } px` ;
194
+ placeholderElement . style . width = `${ popupElement . offsetWidth } px` ;
195
+
181
196
// Reset first
182
197
popupElement . style . left = '0' ;
183
198
popupElement . style . top = '0' ;
@@ -203,7 +218,6 @@ export default function useAlign(
203
218
} ;
204
219
}
205
220
const popupRect = popupElement . getBoundingClientRect ( ) ;
206
- const { width, height } = win . getComputedStyle ( popupElement ) ;
207
221
const {
208
222
clientWidth,
209
223
clientHeight,
@@ -268,6 +282,8 @@ export default function useAlign(
268
282
popupElement . style . right = originRight ;
269
283
popupElement . style . bottom = originBottom ;
270
284
285
+ popupElement . parentElement ?. removeChild ( placeholderElement ) ;
286
+
271
287
// Calculate scale
272
288
const scaleX = toNum (
273
289
Math . round ( ( popupWidth / parseFloat ( width ) ) * 1000 ) / 1000 ,
0 commit comments