[new feature] DropdownMenu: add direction prop (#3490)

This commit is contained in:
neverland
2019-06-13 13:09:35 +08:00
committed by GitHub
parent 156ac95382
commit 6b7307a657
10 changed files with 238 additions and 61 deletions

View File

@@ -55,7 +55,15 @@ export default sfc({
},
render(h) {
const { top, zIndex, overlay, duration, activeColor, closeOnClickOverlay } = this.parent;
const {
zIndex,
offset,
overlay,
duration,
direction,
activeColor,
closeOnClickOverlay
} = this.parent;
const Options = this.options.map(option => {
const active = option.value === this.value;
@@ -81,11 +89,18 @@ export default sfc({
const emit = eventName => () => this.$emit(eventName);
const style = { zIndex };
if (direction === 'down') {
style.top = `${offset}px`;
} else {
style.bottom = `${offset}px`;
}
return (
<div vShow={this.showWrapper} style={{ top: `${top}px`, zIndex }} class={bem()}>
<div vShow={this.showWrapper} style={style} class={bem([direction])}>
<Popup
vModel={this.showPopup}
position="top"
position={direction === 'down' ? 'top' : 'bottom'}
duration={this.transition ? duration : 0}
class={bem('content')}
overlay={overlay}