File tree Expand file tree Collapse file tree 3 files changed +75
-31
lines changed Expand file tree Collapse file tree 3 files changed +75
-31
lines changed Original file line number Diff line number Diff line change 31
31
&-enter ,
32
32
&-appear ,
33
33
&-leave {
34
+ &-start {
35
+ transition : none ;
36
+ }
37
+
34
38
&-active {
35
39
transition : all @duration ;
36
40
}
Original file line number Diff line number Diff line change @@ -268,45 +268,46 @@ export default function DrawerPopup(props: DrawerPopupProps) {
268
268
}
269
269
270
270
const panelNode : React . ReactNode = (
271
- < div
272
- className = { classNames ( `${ prefixCls } -content-wrapper` ) }
273
- style = { {
274
- ...wrapperStyle ,
275
- ...contentWrapperStyle ,
276
- ...zIndexStyle ,
271
+ < CSSMotion
272
+ key = "panel"
273
+ { ...motionProps }
274
+ visible = { open }
275
+ forceRender = { forceRender }
276
+ onVisibleChanged = { nextVisible => {
277
+ afterOpenChange ?.( nextVisible ) ;
278
+ if ( ! nextVisible ) {
279
+ scrollLocker ?. unLock ( ) ;
280
+ }
277
281
} }
282
+ removeOnLeave = { false }
283
+ leavedClassName = { `${ prefixCls } -content-hidden` }
278
284
>
279
- < CSSMotion
280
- key = "panel"
281
- { ...motionProps }
282
- visible = { open }
283
- forceRender = { forceRender }
284
- onVisibleChanged = { nextVisible => {
285
- afterOpenChange ?.( nextVisible ) ;
286
- if ( ! nextVisible ) {
287
- scrollLocker ?. unLock ( ) ;
288
- }
289
- } }
290
- removeOnLeave = { false }
291
- leavedClassName = { `${ prefixCls } -content-hidden` }
292
- >
293
- { ( { className : motionClassName , style : motionStyle } , motionRef ) => {
294
- return (
285
+ { ( { className : motionClassName , style : motionStyle } , motionRef ) => {
286
+ return (
287
+ < div
288
+ className = { classNames (
289
+ `${ prefixCls } -content-wrapper` ,
290
+ motionClassName ,
291
+ ) }
292
+ style = { {
293
+ ...wrapperStyle ,
294
+ ...motionStyle ,
295
+ ...contentWrapperStyle ,
296
+ ...zIndexStyle ,
297
+ } }
298
+ >
295
299
< DrawerPanel
296
300
containerRef = { motionRef }
297
301
prefixCls = { prefixCls }
298
- className = { classNames ( className , motionClassName ) }
299
- style = { {
300
- ...motionStyle ,
301
- ...style ,
302
- } }
302
+ className = { className }
303
+ style = { style }
303
304
>
304
305
{ children }
305
306
</ DrawerPanel >
306
- ) ;
307
- } }
308
- </ CSSMotion >
309
- </ div >
307
+ </ div >
308
+ ) ;
309
+ } }
310
+ </ CSSMotion >
310
311
) ;
311
312
312
313
// =========================== Render ===========================
Original file line number Diff line number Diff line change
1
+ import { render } from '@testing-library/react' ;
2
+ import React from 'react' ;
3
+ import Drawer from '../src' ;
4
+
5
+ jest . mock ( 'rc-motion' , ( ) => {
6
+ const { genCSSMotion } = jest . requireActual ( 'rc-motion/lib/CSSMotion' ) ;
7
+ const CSSMotion = genCSSMotion ( true ) ;
8
+ return CSSMotion ;
9
+ } ) ;
10
+
11
+ describe ( 'motion' , ( ) => {
12
+ beforeEach ( ( ) => {
13
+ jest . useFakeTimers ( ) ;
14
+ } ) ;
15
+
16
+ afterEach ( ( ) => {
17
+ jest . useRealTimers ( ) ;
18
+ } ) ;
19
+
20
+ // zombieJ: Do not modify patch dom since user use `contentWrapperStyle` for override style
21
+ it ( 'motion patch on the correct element' , ( ) => {
22
+ const { container } = render (
23
+ < Drawer
24
+ width = "93%"
25
+ open
26
+ getContainer = { false }
27
+ motion = { { motionName : 'bamboo' , motionAppear : true } }
28
+ contentWrapperStyle = { { background : 'red' } }
29
+ /> ,
30
+ ) ;
31
+
32
+ expect ( container . querySelector ( '.rc-drawer-content-wrapper' ) ) . toHaveClass (
33
+ 'bamboo-appear' ,
34
+ ) ;
35
+ expect ( container . querySelector ( '.rc-drawer-content-wrapper' ) ) . toHaveStyle ( {
36
+ background : 'red' ,
37
+ } ) ;
38
+ } ) ;
39
+ } ) ;
You can’t perform that action at this time.
0 commit comments