@@ -20,7 +20,8 @@ class Drawer extends React.PureComponent {
20
20
openClassName : PropTypes . string ,
21
21
iconChild : PropTypes . any ,
22
22
onChange : PropTypes . func ,
23
- onSwitch : PropTypes . func ,
23
+ onMaskClick : PropTypes . func ,
24
+ onIconClick : PropTypes . func ,
24
25
}
25
26
static defaultProps = {
26
27
className : 'drawer' ,
@@ -31,7 +32,8 @@ class Drawer extends React.PureComponent {
31
32
level : 'all' ,
32
33
levelTransition : 'transform .3s cubic-bezier(0.78, 0.14, 0.15, 0.86)' ,
33
34
onChange : ( ) => { } ,
34
- onSwitch : ( ) => { } ,
35
+ onMaskClick : ( ) => { } ,
36
+ onIconClick : ( ) => { } ,
35
37
iconChild : ( < i className = "drawer-button-icon" /> ) ,
36
38
}
37
39
@@ -109,7 +111,6 @@ class Drawer extends React.PureComponent {
109
111
}
110
112
111
113
onTouchEnd = ( e , close ) => {
112
- this . props . onSwitch ( e ) ;
113
114
if ( this . props . open !== undefined ) {
114
115
return ;
115
116
}
@@ -123,7 +124,17 @@ class Drawer extends React.PureComponent {
123
124
} ) ;
124
125
}
125
126
126
- touchStart = ( e ) => {
127
+ onMaskTouchEnd = ( e ) => {
128
+ this . props . onMaskClick ( e ) ;
129
+ this . onTouchEnd ( e , true ) ;
130
+ }
131
+
132
+ onIconTouchEnd = ( e ) => {
133
+ this . props . onSwitch ( e ) ;
134
+ this . onTouchEnd ( e ) ;
135
+ }
136
+
137
+ onScrollTouchStart = ( e ) => {
127
138
if ( e . touches . length > 1 ) {
128
139
return ;
129
140
}
@@ -133,7 +144,8 @@ class Drawer extends React.PureComponent {
133
144
y : touchs . pageY ,
134
145
} ;
135
146
}
136
- touchEnd = ( ) => {
147
+
148
+ onScrollTouchEnd = ( ) => {
137
149
this . mousePos = null ;
138
150
}
139
151
@@ -234,7 +246,7 @@ class Drawer extends React.PureComponent {
234
246
235
247
getChildToRender = ( ) => {
236
248
const open = this . props . open !== undefined ? this . props . open : this . state . open ;
237
- const { className, openClassName, placement, children, width, iconChild } = this . props ;
249
+ const { className, style , openClassName, placement, children, width, iconChild } = this . props ;
238
250
const wrapperClassname = classnames ( this . props . className , {
239
251
[ `${ className } -${ placement } ` ] : true ,
240
252
[ openClassName ] : open ,
@@ -262,11 +274,10 @@ class Drawer extends React.PureComponent {
262
274
}
263
275
}
264
276
return (
265
- < div className = { wrapperClassname } >
277
+ < div className = { wrapperClassname } style = { style } >
266
278
< div
267
279
className = { `${ className } -bg` }
268
- onTouchEnd = { ( e ) => { this . onTouchEnd ( e , true ) ; } }
269
- onClick = { ( e ) => { this . onTouchEnd ( e , true ) ; } }
280
+ onClick = { this . onMaskTouchEnd }
270
281
/>
271
282
< div
272
283
className = { `${ className } -content-wrapper` }
@@ -277,8 +288,8 @@ class Drawer extends React.PureComponent {
277
288
>
278
289
< div
279
290
className = { `${ className } -content` }
280
- onTouchStart = { this . touchStart }
281
- onTouchEnd = { this . touchEnd }
291
+ onTouchStart = { this . onScrollTouchStart }
292
+ onTouchEnd = { this . onScrollTouchEnd }
282
293
ref = { ( c ) => {
283
294
this . contextDom = c ;
284
295
} }
@@ -288,7 +299,7 @@ class Drawer extends React.PureComponent {
288
299
{ iconChildToRender && (
289
300
< div
290
301
className = { `${ className } -button` }
291
- onClick = { ( e ) => { this . onTouchEnd ( e ) ; } }
302
+ onClick = { this . onIconTouchEnd }
292
303
>
293
304
{ iconChildToRender }
294
305
</ div >
0 commit comments