Skip to content

Commit 5a9eb88

Browse files
committed
fix: drawer style to wrapStyle
1 parent 14dfeba commit 5a9eb88

File tree

4 files changed

+17
-148
lines changed

4 files changed

+17
-148
lines changed

components/drawer/demo/from-drawer.md

Lines changed: 0 additions & 131 deletions
This file was deleted.

components/drawer/index.jsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warning from 'warning'
21
import classnames from 'classnames'
32
import VcDrawer from '../vc-drawer/src'
43
import PropTypes from '../_util/vue-types'
@@ -15,6 +14,7 @@ const Drawer = {
1514
maskClosable: PropTypes.bool.def(true),
1615
mask: PropTypes.bool.def(true),
1716
maskStyle: PropTypes.object,
17+
wrapStyle: PropTypes.object,
1818
title: PropTypes.any,
1919
visible: PropTypes.bool,
2020
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).def(256),
@@ -107,7 +107,7 @@ const Drawer = {
107107
return null
108108
}
109109
this.destoryClose = false
110-
const { placement, bodyStyle } = this.$props
110+
const { placement } = this.$props
111111

112112
const containerStyle = placement === 'left' ||
113113
placement === 'right' ? {
@@ -157,26 +157,22 @@ const Drawer = {
157157
>
158158
{header}
159159
{closer}
160-
<div key='body' class={`${prefixCls}-body`} style={bodyStyle}>
160+
<div key='body' class={`${prefixCls}-body`}>
161161
{this.$slots.default}
162162
</div>
163163
</div>
164164
)
165165
},
166166
getRcDrawerStyle () {
167-
const { zIndex, placement, maskStyle } = this.$props
168-
return this.$data._push
169-
? {
170-
...maskStyle,
171-
zIndex,
172-
transform: this.getPushTransform(placement),
173-
}
174-
: {
175-
...maskStyle,
176-
zIndex,
177-
}
167+
const { zIndex, placement, maskStyle, wrapStyle } = this.$props
168+
const { _push: push } = this.$data
169+
return {
170+
...maskStyle,
171+
zIndex,
172+
transform: push ? this.getPushTransform(placement) : undefined,
173+
...wrapStyle,
174+
}
178175
},
179-
180176
},
181177
render () {
182178
const props = getOptionProps(this)
@@ -200,12 +196,12 @@ const Drawer = {
200196
[wrapClassName]: !!wrapClassName,
201197
[haveMask]: !!haveMask,
202198
}),
199+
wrapStyle: this.getRcDrawerStyle(),
203200
},
204201
on: {
205202
maskClick: this.onMaskClick,
206203
...this.$listeners,
207204
},
208-
style: this.getRcDrawerStyle(),
209205
}
210206
return (
211207
<VcDrawer

components/vc-drawer/src/Drawer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import classnames from 'classnames'
22
import Vue from 'vue'
33
import ref from 'vue-ref'
44
import BaseMixin from '../../_util/BaseMixin'
5-
import { initDefaultProps, getEvents, getClass } from '../../_util/props-util'
5+
import { initDefaultProps, getEvents } from '../../_util/props-util'
66
import { cloneElement } from '../../_util/vnode'
77
import ContainerRender from '../../_util/ContainerRender'
88
import getScrollBarSize from '../../_util/getScrollBarSize'
@@ -376,6 +376,7 @@ const Drawer = {
376376
maskStyle,
377377
width,
378378
height,
379+
wrapStyle,
379380
} = this.$props
380381
const children = this.$slots.default
381382
const wrapperClassname = classnames(prefixCls, {
@@ -422,6 +423,7 @@ const Drawer = {
422423
}],
423424
})
424425
}
426+
425427
const domContProps = {
426428
class: wrapperClassname,
427429
directives: [{
@@ -433,6 +435,7 @@ const Drawer = {
433435
on: {
434436
transitionend: this.onWrapperTransitionEnd,
435437
},
438+
style: wrapStyle,
436439
}
437440
const directivesMaskDom = [{
438441
name: 'ant-ref',

components/vc-drawer/src/drawerProps.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ export default {
1818
showMask: PropTypes.bool,
1919
maskStyle: PropTypes.object,
2020
className: PropTypes.string,
21+
wrapStyle: PropTypes.object,
2122
}

0 commit comments

Comments
 (0)