|
@@ -45,7 +45,8 @@
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
timeout: null,
|
|
timeout: null,
|
|
- visible: false
|
|
|
|
|
|
+ visible: false,
|
|
|
|
+ triggerElm: null
|
|
};
|
|
};
|
|
},
|
|
},
|
|
|
|
|
|
@@ -63,37 +64,39 @@
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
show() {
|
|
show() {
|
|
|
|
+ if (this.triggerElm.disabled) return;
|
|
clearTimeout(this.timeout);
|
|
clearTimeout(this.timeout);
|
|
this.timeout = setTimeout(() => {
|
|
this.timeout = setTimeout(() => {
|
|
this.visible = true;
|
|
this.visible = true;
|
|
}, 250);
|
|
}, 250);
|
|
},
|
|
},
|
|
hide() {
|
|
hide() {
|
|
|
|
+ if (this.triggerElm.disabled) return;
|
|
clearTimeout(this.timeout);
|
|
clearTimeout(this.timeout);
|
|
this.timeout = setTimeout(() => {
|
|
this.timeout = setTimeout(() => {
|
|
this.visible = false;
|
|
this.visible = false;
|
|
}, 150);
|
|
}, 150);
|
|
},
|
|
},
|
|
handleClick() {
|
|
handleClick() {
|
|
|
|
+ if (this.triggerElm.disabled) return;
|
|
this.visible = !this.visible;
|
|
this.visible = !this.visible;
|
|
},
|
|
},
|
|
initEvent() {
|
|
initEvent() {
|
|
let { trigger, show, hide, handleClick, splitButton } = this;
|
|
let { trigger, show, hide, handleClick, splitButton } = this;
|
|
- let triggerElm = splitButton
|
|
|
|
|
|
+ this.triggerElm = splitButton
|
|
? this.$refs.trigger.$el
|
|
? this.$refs.trigger.$el
|
|
: this.$slots.default[0].elm;
|
|
: this.$slots.default[0].elm;
|
|
|
|
|
|
- if (triggerElm.disabled) return;
|
|
|
|
if (trigger === 'hover') {
|
|
if (trigger === 'hover') {
|
|
- triggerElm.addEventListener('mouseenter', show);
|
|
|
|
- triggerElm.addEventListener('mouseleave', hide);
|
|
|
|
|
|
+ this.triggerElm.addEventListener('mouseenter', show);
|
|
|
|
+ this.triggerElm.addEventListener('mouseleave', hide);
|
|
|
|
|
|
let dropdownElm = this.$slots.dropdown[0].elm;
|
|
let dropdownElm = this.$slots.dropdown[0].elm;
|
|
|
|
|
|
dropdownElm.addEventListener('mouseenter', show);
|
|
dropdownElm.addEventListener('mouseenter', show);
|
|
dropdownElm.addEventListener('mouseleave', hide);
|
|
dropdownElm.addEventListener('mouseleave', hide);
|
|
} else if (trigger === 'click') {
|
|
} else if (trigger === 'click') {
|
|
- triggerElm.addEventListener('click', handleClick);
|
|
|
|
|
|
+ this.triggerElm.addEventListener('click', handleClick);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
handleMenuItemClick(command, instance) {
|
|
handleMenuItemClick(command, instance) {
|