@@ -3,10 +3,13 @@ import { useRef } from 'react';
33import classNames from 'classnames' ;
44import CSSMotion from '@rc-component/motion' ;
55import { offset } from '../../util' ;
6- import type { PanelProps , ContentRef } from './Panel' ;
6+ import type { PanelProps , PanelRef } from './Panel' ;
77import Panel from './Panel' ;
88
9- console . log ( CSSMotion ) ;
9+ export type ContentRef = PanelRef & {
10+ inMotion : ( ) => boolean ;
11+ enableMotion : ( ) => boolean ;
12+ } ;
1013
1114export type ContentProps = {
1215 motionName : string ;
@@ -34,6 +37,15 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
3437 inMotion : ( ) => boolean ;
3538 } > ( ) ;
3639
40+ const panelRef = useRef < PanelRef > ( ) ;
41+
42+ // ============================== Refs ==============================
43+ React . useImperativeHandle ( ref , ( ) => ( {
44+ ...panelRef . current ,
45+ inMotion : dialogRef . current . inMotion ,
46+ enableMotion : dialogRef . current . enableMotion ,
47+ } ) ) ;
48+
3749 // ============================= Style ==============================
3850 const [ transformOrigin , setTransformOrigin ] = React . useState < string > ( ) ;
3951 const contentStyle : React . CSSProperties = { } ;
@@ -43,8 +55,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
4355 }
4456
4557 function onPrepare ( ) {
46- console . log ( 'onPrepare' , dialogRef . current ) ;
47- const elementOffset = offset ( dialogRef . current ?. nativeElement ) ;
58+ const elementOffset = offset ( dialogRef . current . nativeElement ) ;
4859
4960 setTransformOrigin (
5061 mousePosition && ( mousePosition . x || mousePosition . y )
@@ -53,12 +64,6 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
5364 ) ;
5465 }
5566
56- const bbb = React . useCallback ( ( aaa ) => {
57- console . log ( '???' , aaa ) ;
58- dialogRef . current = aaa ;
59- } , [ ] ) ;
60- console . log ( 'render....' ) ;
61-
6267 // ============================= Render =============================
6368 return (
6469 < CSSMotion
@@ -69,12 +74,12 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
6974 forceRender = { forceRender }
7075 motionName = { motionName }
7176 removeOnLeave = { destroyOnClose }
72- ref = { bbb }
77+ ref = { dialogRef }
7378 >
7479 { ( { className : motionClassName , style : motionStyle } , motionRef ) => (
7580 < Panel
7681 { ...props }
77- ref = { ref }
82+ ref = { panelRef }
7883 title = { title }
7984 ariaId = { ariaId }
8085 prefixCls = { prefixCls }
0 commit comments