Skip to content

Commit

Permalink
Image: fix z-index and keydown event add stopPropagation (ElemeFE#20859)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 authored and cn3lfs committed Feb 24, 2022
1 parent 3995f9c commit 60a0b86
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/image/src/image-viewer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<transition name="viewer-fade">
<div tabindex="-1" ref="el-image-viewer__wrapper" class="el-image-viewer__wrapper" :style="{ 'z-index': zIndex }">
<div tabindex="-1" ref="el-image-viewer__wrapper" class="el-image-viewer__wrapper" :style="{ 'z-index': viewerZIndex }">
<div class="el-image-viewer__mask" @click.self="handleMaskClick"></div>
<!-- CLOSE -->
<span class="el-image-viewer__btn el-image-viewer__close" @click="hide">
Expand Down Expand Up @@ -54,6 +54,7 @@
<script>
import { on, off } from 'element-ui/src/utils/dom';
import { rafThrottle, isFirefox } from 'element-ui/src/utils/util';
import { PopupManager } from 'element-ui/src/utils/popup';
const Mode = {
CONTAIN: {
Expand Down Expand Up @@ -143,6 +144,10 @@ export default {
style.maxWidth = style.maxHeight = '100%';
}
return style;
},
viewerZIndex() {
const nextZIndex = PopupManager.nextZIndex();
return this.zIndex > nextZIndex ? this.zIndex : nextZIndex;
}
},
watch: {
Expand All @@ -167,7 +172,8 @@ export default {
this.onClose();
},
deviceSupportInstall() {
this._keyDownHandler = rafThrottle(e => {
this._keyDownHandler = e => {
e.stopPropagation();
const keyCode = e.keyCode;
switch (keyCode) {
// ESC
Expand Down Expand Up @@ -195,7 +201,7 @@ export default {
this.handleActions('zoomOut');
break;
}
});
};
this._mouseWheelHandler = rafThrottle(e => {
const delta = e.wheelDelta ? e.wheelDelta : -e.detail;
if (delta > 0) {
Expand Down

0 comments on commit 60a0b86

Please sign in to comment.