File tree Expand file tree Collapse file tree 1 file changed +19
-15
lines changed Expand file tree Collapse file tree 1 file changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import React, {
5
5
useRef ,
6
6
useState ,
7
7
} from 'react'
8
- import { CSSTransition } from 'react-transition-group '
8
+ import { useSpring , animated } from '@ react-spring/web '
9
9
import classNames from 'classnames'
10
10
import { ComponentDefaults } from '@/utils/typings'
11
11
import { useLockScroll } from '@/hooks/use-lock-scroll'
@@ -50,7 +50,7 @@ export const Overlay: FunctionComponent<
50
50
51
51
const shouldLockScroll = ! innerVisible ? false : lockScroll
52
52
useLockScroll ( nodeRef , shouldLockScroll )
53
- const classes = classNames ( classPrefix , className )
53
+ const classes = classNames ( classPrefix , ` ${ classPrefix } -slide` , className )
54
54
const styles = {
55
55
...style ,
56
56
zIndex,
@@ -62,26 +62,30 @@ export const Overlay: FunctionComponent<
62
62
}
63
63
}
64
64
65
+ const springProps = useSpring ( {
66
+ opacity : innerVisible ? 1 : 0 ,
67
+ config : { duration } ,
68
+ onRest : ( ) => {
69
+ if ( innerVisible ) {
70
+ afterShow ( )
71
+ } else {
72
+ afterClose ( )
73
+ }
74
+ } ,
75
+ } )
76
+
65
77
return (
66
- < CSSTransition
67
- nodeRef = { nodeRef }
68
- classNames = { `${ classPrefix } -slide` }
69
- unmountOnExit
70
- timeout = { duration }
71
- in = { innerVisible }
72
- onEntered = { afterShow }
73
- onExited = { afterClose }
74
- >
75
- < div
78
+ innerVisible && (
79
+ < animated . div
76
80
ref = { nodeRef }
77
81
className = { classes }
78
- style = { styles }
82
+ style = { { ... styles , ... springProps } }
79
83
{ ...rest }
80
84
onClick = { handleClick }
81
85
>
82
86
{ children }
83
- </ div >
84
- </ CSSTransition >
87
+ </ animated . div >
88
+ )
85
89
)
86
90
}
87
91
You can’t perform that action at this time.
0 commit comments