@@ -10,6 +10,7 @@ import type { AlignType, ArrowPos, ArrowTypeOuter } from '../interface';
1010import Arrow from './Arrow' ;
1111import Mask from './Mask' ;
1212import PopupContent from './PopupContent' ;
13+ import useOffsetStyle from '../hooks/useOffsetStyle' ;
1314
1415export interface MobileConfig {
1516 mask ?: boolean ;
@@ -175,49 +176,23 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
175176 }
176177 } , [ show , getPopupContainerNeedParams , target ] ) ;
177178
179+ // ========================= Styles =========================
180+ const offsetStyle = useOffsetStyle (
181+ isMobile ,
182+ ready ,
183+ open ,
184+ align ,
185+ offsetR ,
186+ offsetB ,
187+ offsetX ,
188+ offsetY ,
189+ ) ;
190+
178191 // ========================= Render =========================
179192 if ( ! show ) {
180193 return null ;
181194 }
182195
183- // TODO: Move offsetStyle logic to useOffsetStyle.ts hooks
184- // >>>>> Offset
185- const AUTO = 'auto' as const ;
186-
187- const offsetStyle : React . CSSProperties = isMobile
188- ? { }
189- : {
190- left : '-1000vw' ,
191- top : '-1000vh' ,
192- right : AUTO ,
193- bottom : AUTO ,
194- } ;
195-
196- // Set align style
197- if ( ! isMobile && ( ready || ! open ) ) {
198- const { points } = align ;
199- const dynamicInset =
200- align . dynamicInset || ( align as any ) . _experimental ?. dynamicInset ;
201- const alignRight = dynamicInset && points [ 0 ] [ 1 ] === 'r' ;
202- const alignBottom = dynamicInset && points [ 0 ] [ 0 ] === 'b' ;
203-
204- if ( alignRight ) {
205- offsetStyle . right = offsetR ;
206- offsetStyle . left = AUTO ;
207- } else {
208- offsetStyle . left = offsetX ;
209- offsetStyle . right = AUTO ;
210- }
211-
212- if ( alignBottom ) {
213- offsetStyle . bottom = offsetB ;
214- offsetStyle . top = AUTO ;
215- } else {
216- offsetStyle . top = offsetY ;
217- offsetStyle . bottom = AUTO ;
218- }
219- }
220-
221196 // >>>>> Misc
222197 const miscStyle : React . CSSProperties = { } ;
223198 if ( stretch ) {
0 commit comments