DropdownMenu: fix popper

Update changelog

DropdownMenu: Remove console
pull/362/head
qingwei.li 2016-10-12 18:29:24 +08:00
parent de696c78bc
commit a71471f6e1
7 changed files with 38 additions and 36 deletions

View File

@ -5,6 +5,10 @@
*2016-XX-XX* *2016-XX-XX*
- Upload 新增 Data 属性支持额外数据的传输 - Upload 新增 Data 属性支持额外数据的传输
- DatePicker 修复 `$t` 报错
- Popper 重构 vue-popper
- Pagination 修复输入后再点击切换,输入框的值不更新
- Step: 修复自定义 icon 的样式
### 1.0.0-rc.6 ### 1.0.0-rc.6

View File

@ -1,39 +1,35 @@
<template> <template>
<ul class="el-dropdown__menu"> <transition name="md-fade-bottom" @after-leave="doDestroy">
<ul class="el-dropdown__menu" v-show="showPopper">
<slot></slot> <slot></slot>
</ul> </ul>
</transition>
</template> </template>
<script> <script>
import Popper from 'main/utils/popper'; import Popper from 'main/utils/vue-popper';
export default { export default {
name: 'ElDropdownMenu', name: 'ElDropdownMenu',
props: { componentName: 'ElDropdownMenu',
visible: Boolean
},
data() {
return {
popper: null
};
},
computed: {
menuAlign() {
return this.$parent.menuAlign;
}
},
mounted() {
document.body.appendChild(this.$el);
this.$nextTick(() => { mixins: [Popper],
this.popper = new Popper(this.$parent.$el, this.$el, { gpuAcceleration: false, placement: `bottom-${this.menuAlign}` });
created() {
this.$on('visible', val => {
this.showPopper = val;
}); });
}, },
destroyed() { mounted() {
setTimeout(() => { this.popperElm = this.$el;
this.popper.destroy(); this.referenceElm = this.$parent.$el;
}, 300); },
computed: {
placement() {
return `bottom-${this.$parent.menuAlign}`;
}
} }
}; };
</script> </script>

View File

@ -1,9 +1,12 @@
<script> <script>
import Clickoutside from 'main/utils/clickoutside'; import Clickoutside from 'main/utils/clickoutside';
import emitter from 'main/mixins/emitter';
export default { export default {
name: 'ElDropdown', name: 'ElDropdown',
mixins: [emitter],
directives: { Clickoutside }, directives: { Clickoutside },
props: { props: {
@ -32,6 +35,12 @@
this.initEvent(); this.initEvent();
}, },
watch: {
visible(val) {
this.broadcast('ElDropdownMenu', 'visible', val);
}
},
methods: { methods: {
show() { show() {
clearTimeout(this.timeout); clearTimeout(this.timeout);
@ -74,8 +83,7 @@
}, },
render(h) { render(h) {
let { hide, splitButton, visible, type } = this; let { hide, splitButton, type } = this;
let dropdownElm = visible ? this.$slots.dropdown : null;
var handleClick = _ => { var handleClick = _ => {
this.$emit('click'); this.$emit('click');
@ -95,9 +103,7 @@
return ( return (
<div class="el-dropdown" v-clickoutside={hide}> <div class="el-dropdown" v-clickoutside={hide}>
{triggerElm} {triggerElm}
<transition name="md-fade-bottom"> {this.$slots.dropdown}
{dropdownElm}
</transition>
</div> </div>
); );
} }

View File

@ -46,13 +46,6 @@ export default {
transition: { transition: {
type: String, type: String,
default: 'fade-in-linear' default: 'fade-in-linear'
},
options: {
default() {
return {
gpuAcceleration: false
};
}
} }
}, },

View File

@ -9,6 +9,7 @@
@import "./radio.css"; @import "./radio.css";
@import "./switch.css"; @import "./switch.css";
@import "./dropdown.css"; @import "./dropdown.css";
@import "./dropdown-menu.css";
@import "./loading.css"; @import "./loading.css";
@import "./dialog.css"; @import "./dialog.css";
@import "./table.css"; @import "./table.css";

View File

@ -34,7 +34,9 @@ export default {
options: { options: {
type: Object, type: Object,
default() { default() {
return {}; return {
gpuAcceleration: false
};
} }
} }
}, },