fix: [image-viewer] two-finger zoom in and out (#3114)

Co-authored-by: jia <Fire_Mars_j@163.com>
This commit is contained in:
Alan Wang 2021-08-31 17:19:39 +08:00 committed by GitHub
parent f34d9f07fd
commit 90f77308a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')