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
|
||||
}
|
||||
|
||||
function _wheelHandler(e){
|
||||
if (e.ctrlKey) {
|
||||
if (e.deltaY < 0) {
|
||||
e.preventDefault()
|
||||
return false
|
||||
}
|
||||
if (e.deltaY > 0) {
|
||||
e.preventDefault()
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clickHandler() {
|
||||
// don't show viewer when preview is false
|
||||
if (!preview.value) {
|
||||
return
|
||||
}
|
||||
document.body.addEventListener('wheel', _wheelHandler, { passive: false })
|
||||
// prevent body scroll
|
||||
prevOverflow = document.body.style.overflow
|
||||
document.body.style.overflow = 'hidden'
|
||||
@ -259,6 +273,7 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
function closeViewer() {
|
||||
document.body.removeEventListener('wheel', _wheelHandler, false)
|
||||
document.body.style.overflow = prevOverflow
|
||||
showViewer.value = false
|
||||
emit('close')
|
||||
|
Loading…
Reference in New Issue
Block a user