@@ -11,6 +11,14 @@ import Arrow from './Arrow';
1111import Mask from './Mask' ;
1212import PopupContent from './PopupContent' ;
1313
14+ export interface MobileConfig {
15+ mask ?: boolean ;
16+ /** Set popup motion. You can ref `rc-motion` for more info. */
17+ motion ?: CSSMotionProps ;
18+ /** Set mask motion. You can ref `rc-motion` for more info. */
19+ maskMotion ?: CSSMotionProps ;
20+ }
21+
1422export interface PopupProps {
1523 prefixCls : string ;
1624 className ?: string ;
@@ -63,6 +71,9 @@ export interface PopupProps {
6371 stretch ?: string ;
6472 targetWidth ?: number ;
6573 targetHeight ?: number ;
74+
75+ // Mobile
76+ mobile ?: MobileConfig ;
6677}
6778
6879const Popup = React . forwardRef < HTMLDivElement , PopupProps > ( ( props , ref ) => {
@@ -95,6 +106,9 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
95106 motion,
96107 maskMotion,
97108
109+ // Mobile
110+ mobile,
111+
98112 // Portal
99113 forceRender,
100114 getPopupContainer,
@@ -126,6 +140,24 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
126140 // We can not remove holder only when motion finished.
127141 const isNodeVisible = open || keepDom ;
128142
143+ // ========================= Mobile =========================
144+ const isMobile = ! ! mobile ;
145+
146+ // ========================== Mask ==========================
147+ const [ mergedMask , mergedMaskMotion , mergedPopupMotion ] = React . useMemo <
148+ [
149+ mask : boolean ,
150+ maskMotion : CSSMotionProps | undefined ,
151+ popupMotion : CSSMotionProps | undefined ,
152+ ]
153+ > ( ( ) => {
154+ if ( mobile ) {
155+ return [ mobile . mask , mobile . maskMotion , mobile . motion ] ;
156+ }
157+
158+ return [ mask , maskMotion , motion ] ;
159+ } , [ mobile ] ) ;
160+
129161 // ======================= Container ========================
130162 const getPopupContainerNeedParams = getPopupContainer ?. length > 0 ;
131163
@@ -148,15 +180,17 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
148180 // >>>>> Offset
149181 const AUTO = 'auto' as const ;
150182
151- const offsetStyle : React . CSSProperties = {
152- left : '-1000vw' ,
153- top : '-1000vh' ,
154- right : AUTO ,
155- bottom : AUTO ,
156- } ;
183+ const offsetStyle : React . CSSProperties = isMobile
184+ ? { }
185+ : {
186+ left : '-1000vw' ,
187+ top : '-1000vh' ,
188+ right : AUTO ,
189+ bottom : AUTO ,
190+ } ;
157191
158192 // Set align style
159- if ( ready || ! open ) {
193+ if ( ! isMobile && ( ready || ! open ) ) {
160194 const { points } = align ;
161195 const dynamicInset =
162196 align . dynamicInset || ( align as any ) . _experimental ?. dynamicInset ;
@@ -209,8 +243,9 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
209243 prefixCls = { prefixCls }
210244 open = { open }
211245 zIndex = { zIndex }
212- mask = { mask }
213- motion = { maskMotion }
246+ mask = { mergedMask }
247+ motion = { mergedMaskMotion }
248+ mobile = { isMobile }
214249 />
215250 < ResizeObserver onResize = { onAlign } disabled = { ! open } >
216251 { ( resizeObserverRef ) => {
@@ -222,7 +257,7 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
222257 removeOnLeave = { false }
223258 forceRender = { forceRender }
224259 leavedClassName = { `${ prefixCls } -hidden` }
225- { ...motion }
260+ { ...mergedPopupMotion }
226261 onAppearPrepare = { onPrepare }
227262 onEnterPrepare = { onPrepare }
228263 visible = { open }
@@ -235,7 +270,9 @@ const Popup = React.forwardRef<HTMLDivElement, PopupProps>((props, ref) => {
235270 { className : motionClassName , style : motionStyle } ,
236271 motionRef ,
237272 ) => {
238- const cls = classNames ( prefixCls , motionClassName , className ) ;
273+ const cls = classNames ( prefixCls , motionClassName , className , {
274+ [ `${ prefixCls } -mobile` ] : isMobile ,
275+ } ) ;
239276
240277 return (
241278 < div
0 commit comments