@@ -3,10 +3,13 @@ import { useRef } from 'react';
3
3
import classNames from 'classnames' ;
4
4
import CSSMotion from '@rc-component/motion' ;
5
5
import { offset } from '../../util' ;
6
- import type { PanelProps , ContentRef } from './Panel' ;
6
+ import type { PanelProps , PanelRef } from './Panel' ;
7
7
import Panel from './Panel' ;
8
8
9
- console . log ( CSSMotion ) ;
9
+ export type ContentRef = PanelRef & {
10
+ inMotion : ( ) => boolean ;
11
+ enableMotion : ( ) => boolean ;
12
+ } ;
10
13
11
14
export type ContentProps = {
12
15
motionName : string ;
@@ -34,6 +37,15 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
34
37
inMotion : ( ) => boolean ;
35
38
} > ( ) ;
36
39
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
+
37
49
// ============================= Style ==============================
38
50
const [ transformOrigin , setTransformOrigin ] = React . useState < string > ( ) ;
39
51
const contentStyle : React . CSSProperties = { } ;
@@ -43,8 +55,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
43
55
}
44
56
45
57
function onPrepare ( ) {
46
- console . log ( 'onPrepare' , dialogRef . current ) ;
47
- const elementOffset = offset ( dialogRef . current ?. nativeElement ) ;
58
+ const elementOffset = offset ( dialogRef . current . nativeElement ) ;
48
59
49
60
setTransformOrigin (
50
61
mousePosition && ( mousePosition . x || mousePosition . y )
@@ -53,12 +64,6 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
53
64
) ;
54
65
}
55
66
56
- const bbb = React . useCallback ( ( aaa ) => {
57
- console . log ( '???' , aaa ) ;
58
- dialogRef . current = aaa ;
59
- } , [ ] ) ;
60
- console . log ( 'render....' ) ;
61
-
62
67
// ============================= Render =============================
63
68
return (
64
69
< CSSMotion
@@ -69,12 +74,12 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
69
74
forceRender = { forceRender }
70
75
motionName = { motionName }
71
76
removeOnLeave = { destroyOnClose }
72
- ref = { bbb }
77
+ ref = { dialogRef }
73
78
>
74
79
{ ( { className : motionClassName , style : motionStyle } , motionRef ) => (
75
80
< Panel
76
81
{ ...props }
77
- ref = { ref }
82
+ ref = { panelRef }
78
83
title = { title }
79
84
ariaId = { ariaId }
80
85
prefixCls = { prefixCls }
0 commit comments