Feat:在鼠标滚轮行为为上下移动画布时,支持按住Ctrl键改为放大缩小画布

This commit is contained in:
wanglin2 2023-12-01 09:49:02 +08:00
parent 546cf27b33
commit 7d83a3635f
2 changed files with 5 additions and 13 deletions

View File

@ -133,18 +133,10 @@ class Event extends EventEmitter {
e.stopPropagation() e.stopPropagation()
e.preventDefault() e.preventDefault()
let dir let dir
// 解决mac触控板双指缩放方向相反的问题 if (e.deltaY < 0) dir = CONSTANTS.DIR.UP
if (e.ctrlKey) { if (e.deltaY > 0) dir = CONSTANTS.DIR.DOWN
if (e.deltaY > 0) dir = CONSTANTS.DIR.UP if (e.deltaX < 0) dir = CONSTANTS.DIR.LEFT
if (e.deltaY < 0) dir = CONSTANTS.DIR.DOWN if (e.deltaX > 0) dir = CONSTANTS.DIR.RIGHT
if (e.deltaX > 0) dir = CONSTANTS.DIR.LEFT
if (e.deltaX < 0) dir = CONSTANTS.DIR.RIGHT
} else {
if ((e.wheelDeltaY || e.detail) > 0) dir = CONSTANTS.DIR.UP
if ((e.wheelDeltaY || e.detail) < 0) dir = CONSTANTS.DIR.DOWN
if ((e.wheelDeltaX || e.detail) > 0) dir = CONSTANTS.DIR.LEFT
if ((e.wheelDeltaX || e.detail) < 0) dir = CONSTANTS.DIR.RIGHT
}
// 判断是否是触控板 // 判断是否是触控板
let isTouchPad = false let isTouchPad = false
// mac、windows // mac、windows

View File

@ -72,7 +72,7 @@ class View {
return customHandleMousewheel(e) return customHandleMousewheel(e)
} }
// 鼠标滚轮事件控制缩放 // 鼠标滚轮事件控制缩放
if (mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM) { if (mousewheelAction === CONSTANTS.MOUSE_WHEEL_ACTION.ZOOM || e.ctrlKey) {
if (disableMouseWheelZoom) return if (disableMouseWheelZoom) return
const { x: clientX, y: clientY } = this.mindMap.toPos( const { x: clientX, y: clientY } = this.mindMap.toPos(
e.clientX, e.clientX,