mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-12 10:45:10 +08:00
fix: [image-viewer] two-finger zoom in and out (#3114)
Co-authored-by: jia <Fire_Mars_j@163.com>
This commit is contained in:
parent
f34d9f07fd
commit
90f77308a9
@ -247,11 +247,25 @@ export default defineComponent({
|
|||||||
_lazyLoadHandler = null
|
_lazyLoadHandler = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _wheelHandler(e){
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
if (e.deltaY < 0) {
|
||||||
|
e.preventDefault()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (e.deltaY > 0) {
|
||||||
|
e.preventDefault()
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function clickHandler() {
|
function clickHandler() {
|
||||||
// don't show viewer when preview is false
|
// don't show viewer when preview is false
|
||||||
if (!preview.value) {
|
if (!preview.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
document.body.addEventListener('wheel', _wheelHandler, { passive: false })
|
||||||
// prevent body scroll
|
// prevent body scroll
|
||||||
prevOverflow = document.body.style.overflow
|
prevOverflow = document.body.style.overflow
|
||||||
document.body.style.overflow = 'hidden'
|
document.body.style.overflow = 'hidden'
|
||||||
@ -259,6 +273,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closeViewer() {
|
function closeViewer() {
|
||||||
|
document.body.removeEventListener('wheel', _wheelHandler, false)
|
||||||
document.body.style.overflow = prevOverflow
|
document.body.style.overflow = prevOverflow
|
||||||
showViewer.value = false
|
showViewer.value = false
|
||||||
emit('close')
|
emit('close')
|
||||||
|
Loading…
Reference in New Issue
Block a user