Skip to content

Commit fc859b3

Browse files
committed
docs: update demo
1 parent 3867241 commit fc859b3

File tree

4 files changed

+52
-13
lines changed

4 files changed

+52
-13
lines changed

assets/index.less

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,27 @@
44
@zIndex: 1050;
55

66
.@{prefixCls} {
7-
// position: fixed;
8-
// inset: 0;
9-
// z-index: @zIndex;
10-
// pointer-events: none;
7+
position: fixed;
8+
inset: 0;
9+
z-index: @zIndex;
10+
pointer-events: none;
1111

1212
&-mask {
1313
position: absolute;
1414
z-index: @zIndex;
1515
background: rgba(0, 0, 0, 0.5);
1616
inset: 0;
17-
// pointer-events: auto;
17+
pointer-events: auto;
1818
}
1919

2020
&-panel-wrapper {
2121
position: absolute;
2222
z-index: @zIndex;
2323

24+
&-hidden {
25+
display: none;
26+
}
27+
2428
// Placement
2529
.@{prefixCls}-left & {
2630
top: 0;
@@ -36,10 +40,10 @@
3640
}
3741

3842
&-panel {
39-
background: #fff;
4043
width: 100%;
4144
height: 100%;
42-
// pointer-events: auto;
45+
background: #fff;
46+
pointer-events: auto;
4347
}
4448
}
4549

docs/examples/change-remove.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
1+
import {
2+
AppstoreOutlined,
3+
MailOutlined,
4+
SettingOutlined,
5+
} from '@ant-design/icons';
26
import { Menu } from 'antd';
37
import * as React from 'react';
48

59
import Drawer from 'rc-drawer';
610

711
import '../../assets/index.less';
812
import './assets/index.less';
13+
import motionProps from './motion';
914

1015
const SubMenu = Menu.SubMenu;
1116
const MenuItemGroup = Menu.ItemGroup;
@@ -24,7 +29,12 @@ class Demo extends React.Component<any, { show: boolean }> {
2429
return (
2530
<div>
2631
{this.state.show && (
27-
<Drawer wrapperClassName="drawer-wrapper" width="20vw">
32+
<Drawer
33+
wrapperClassName="drawer-wrapper"
34+
width="20vw"
35+
open
36+
{...motionProps}
37+
>
2838
<Menu
2939
defaultSelectedKeys={['1']}
3040
defaultOpenKeys={['sub1']}

docs/examples/getContainer.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
1+
import {
2+
AppstoreOutlined,
3+
MailOutlined,
4+
SettingOutlined,
5+
} from '@ant-design/icons';
26
import { Menu } from 'antd';
37
import * as React from 'react';
48

@@ -26,8 +30,26 @@ class DrawerTester extends React.Component {
2630
public render() {
2731
return (
2832
<div>
29-
<div ref={this.saveContainer} id="container" />
30-
<Drawer width="20vw" getContainer={this.getContainer}>
33+
<div
34+
ref={this.saveContainer}
35+
id="container"
36+
style={{
37+
height: 300,
38+
background: 'rgba(0,0,0,0.05)',
39+
overflow: 'auto',
40+
}}
41+
>
42+
<div
43+
style={{
44+
display: 'inline-block',
45+
height: 1000,
46+
boxShadow: `0 0 1px red`,
47+
}}
48+
>
49+
Hello World
50+
</div>
51+
</div>
52+
<Drawer width="20vw" getContainer={this.getContainer} open>
3153
<Menu
3254
defaultSelectedKeys={['1']}
3355
defaultOpenKeys={['sub1']}

src/DrawerPopup.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default function DrawerPopup(props: DrawerPopupProps) {
8888

8989
// ============================ Mask ============================
9090
const maskNode: React.ReactNode = mask && (
91-
<CSSMotion {...maskMotion} visible={open}>
91+
<CSSMotion key="mask" {...maskMotion} visible={open}>
9292
{({ className: motionMaskClassName, style: motionMaskStyle }) => {
9393
return (
9494
<div
@@ -114,6 +114,7 @@ export default function DrawerPopup(props: DrawerPopupProps) {
114114
const panelNode: React.ReactNode = (
115115
<div className={`${prefixCls}-panel-wrapper`}>
116116
<CSSMotion
117+
key="panel"
117118
{...motionProps}
118119
visible={open}
119120
onVisibleChanged={nextVisible => {
@@ -122,6 +123,8 @@ export default function DrawerPopup(props: DrawerPopupProps) {
122123
scrollLocker?.unLock();
123124
}
124125
}}
126+
removeOnLeave={false}
127+
leavedClassName={`${prefixCls}-panel-wrapper-hidden`}
125128
>
126129
{({ className: motionClassName, style: motionStyle }) => {
127130
return (

0 commit comments

Comments
 (0)