mirror of https://github.com/ElemeFE/element
Tabs: remove box shadow when browser hidden / blur (#10503)
parent
528bce4479
commit
464f81886f
|
@ -35,7 +35,8 @@
|
||||||
return {
|
return {
|
||||||
scrollable: false,
|
scrollable: false,
|
||||||
navOffset: 0,
|
navOffset: 0,
|
||||||
isFocus: false
|
isFocus: false,
|
||||||
|
focusable: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -150,10 +151,28 @@
|
||||||
this.setFocus();
|
this.setFocus();
|
||||||
},
|
},
|
||||||
setFocus() {
|
setFocus() {
|
||||||
|
if (this.focusable) {
|
||||||
this.isFocus = true;
|
this.isFocus = true;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
removeFocus() {
|
removeFocus() {
|
||||||
this.isFocus = false;
|
this.isFocus = false;
|
||||||
|
},
|
||||||
|
visibilityChangeHandler() {
|
||||||
|
const visibility = document.visibilityState;
|
||||||
|
if (visibility === 'hidden') {
|
||||||
|
this.focusable = false;
|
||||||
|
} else if (visibility === 'visible') {
|
||||||
|
this.focusable = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
windowBlurHandler() {
|
||||||
|
this.focusable = false;
|
||||||
|
},
|
||||||
|
windowFocusHandler() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.focusable = true;
|
||||||
|
}, 50);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -236,10 +255,16 @@
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
addResizeListener(this.$el, this.update);
|
addResizeListener(this.$el, this.update);
|
||||||
|
document.addEventListener('visibilitychange', this.visibilityChangeHandler);
|
||||||
|
window.addEventListener('blur', this.windowBlurHandler);
|
||||||
|
window.addEventListener('focus', this.windowFocusHandler);
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
if (this.$el && this.update) removeResizeListener(this.$el, this.update);
|
if (this.$el && this.update) removeResizeListener(this.$el, this.update);
|
||||||
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
||||||
|
window.removeEventListener('blur', this.windowBlurHandler);
|
||||||
|
window.removeEventListener('focus', this.windowFocusHandler);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue