11import * as React from 'react' ;
22import { useRef } from 'react' ;
33import classNames from 'classnames' ;
4- import CSSMotion from 'rc-motion' ;
4+ import CSSMotion from '@ rc-component/ motion' ;
55import { offset } from '../../util' ;
66import type { PanelProps , ContentRef } from './Panel' ;
77import Panel from './Panel' ;
88
9+ console . log ( CSSMotion ) ;
10+
911export type ContentProps = {
1012 motionName : string ;
1113 ariaId : string ;
@@ -27,7 +29,10 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
2729 mousePosition,
2830 } = props ;
2931
30- const dialogRef = useRef < HTMLDivElement > ( ) ;
32+ const dialogRef = useRef < {
33+ nativeElement : HTMLDivElement ;
34+ inMotion : ( ) => boolean ;
35+ } > ( ) ;
3136
3237 // ============================= Style ==============================
3338 const [ transformOrigin , setTransformOrigin ] = React . useState < string > ( ) ;
@@ -38,7 +43,8 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
3843 }
3944
4045 function onPrepare ( ) {
41- const elementOffset = offset ( dialogRef . current ) ;
46+ console . log ( 'onPrepare' , dialogRef . current ) ;
47+ const elementOffset = offset ( dialogRef . current ?. nativeElement ) ;
4248
4349 setTransformOrigin (
4450 mousePosition && ( mousePosition . x || mousePosition . y )
@@ -47,6 +53,12 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
4753 ) ;
4854 }
4955
56+ const bbb = React . useCallback ( ( aaa ) => {
57+ console . log ( '???' , aaa ) ;
58+ dialogRef . current = aaa ;
59+ } , [ ] ) ;
60+ console . log ( 'render....' ) ;
61+
5062 // ============================= Render =============================
5163 return (
5264 < CSSMotion
@@ -57,7 +69,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
5769 forceRender = { forceRender }
5870 motionName = { motionName }
5971 removeOnLeave = { destroyOnClose }
60- ref = { dialogRef }
72+ ref = { bbb }
6173 >
6274 { ( { className : motionClassName , style : motionStyle } , motionRef ) => (
6375 < Panel
0 commit comments