1
1
import * as React from 'react' ;
2
2
import { useRef } from 'react' ;
3
3
import classNames from 'classnames' ;
4
- import CSSMotion from 'rc-motion' ;
4
+ import CSSMotion from '@ rc-component/ motion' ;
5
5
import { offset } from '../../util' ;
6
6
import type { PanelProps , ContentRef } from './Panel' ;
7
7
import Panel from './Panel' ;
8
8
9
+ console . log ( CSSMotion ) ;
10
+
9
11
export type ContentProps = {
10
12
motionName : string ;
11
13
ariaId : string ;
@@ -27,7 +29,10 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
27
29
mousePosition,
28
30
} = props ;
29
31
30
- const dialogRef = useRef < HTMLDivElement > ( ) ;
32
+ const dialogRef = useRef < {
33
+ nativeElement : HTMLDivElement ;
34
+ inMotion : ( ) => boolean ;
35
+ } > ( ) ;
31
36
32
37
// ============================= Style ==============================
33
38
const [ transformOrigin , setTransformOrigin ] = React . useState < string > ( ) ;
@@ -38,7 +43,8 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
38
43
}
39
44
40
45
function onPrepare ( ) {
41
- const elementOffset = offset ( dialogRef . current ) ;
46
+ console . log ( 'onPrepare' , dialogRef . current ) ;
47
+ const elementOffset = offset ( dialogRef . current ?. nativeElement ) ;
42
48
43
49
setTransformOrigin (
44
50
mousePosition && ( mousePosition . x || mousePosition . y )
@@ -47,6 +53,12 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
47
53
) ;
48
54
}
49
55
56
+ const bbb = React . useCallback ( ( aaa ) => {
57
+ console . log ( '???' , aaa ) ;
58
+ dialogRef . current = aaa ;
59
+ } , [ ] ) ;
60
+ console . log ( 'render....' ) ;
61
+
50
62
// ============================= Render =============================
51
63
return (
52
64
< CSSMotion
@@ -57,7 +69,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>((props, ref) => {
57
69
forceRender = { forceRender }
58
70
motionName = { motionName }
59
71
removeOnLeave = { destroyOnClose }
60
- ref = { dialogRef }
72
+ ref = { bbb }
61
73
>
62
74
{ ( { className : motionClassName , style : motionStyle } , motionRef ) => (
63
75
< Panel
0 commit comments