优化触控板缩放画布时幅度过大的问题
This commit is contained in:
parent
fb1251afc1
commit
b8a3be7a62
@ -82,12 +82,12 @@ class View {
|
|||||||
// 鼠标滚轮,向上和向左,都是缩小
|
// 鼠标滚轮,向上和向左,都是缩小
|
||||||
case CONSTANTS.DIR.UP:
|
case CONSTANTS.DIR.UP:
|
||||||
case CONSTANTS.DIR.LEFT:
|
case CONSTANTS.DIR.LEFT:
|
||||||
mousewheelZoomActionReverse ? this.enlarge(cx, cy) : this.narrow(cx, cy)
|
mousewheelZoomActionReverse ? this.enlarge(cx, cy, isTouchPad) : this.narrow(cx, cy, isTouchPad)
|
||||||
break
|
break
|
||||||
// 鼠标滚轮,向下和向右,都是放大
|
// 鼠标滚轮,向下和向右,都是放大
|
||||||
case CONSTANTS.DIR.DOWN:
|
case CONSTANTS.DIR.DOWN:
|
||||||
case CONSTANTS.DIR.RIGHT:
|
case CONSTANTS.DIR.RIGHT:
|
||||||
mousewheelZoomActionReverse ? this.narrow(cx, cy) : this.enlarge(cx, cy)
|
mousewheelZoomActionReverse ? this.narrow(cx, cy, isTouchPad) : this.enlarge(cx, cy, isTouchPad)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else {// 鼠标滚轮事件控制画布移动
|
} else {// 鼠标滚轮事件控制画布移动
|
||||||
@ -199,16 +199,18 @@ class View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 缩小
|
// 缩小
|
||||||
narrow(cx, cy) {
|
narrow(cx, cy, isTouchPad) {
|
||||||
const scale = Math.max(this.scale - this.mindMap.opt.scaleRatio, 0.1)
|
const scaleRatio = this.mindMap.opt.scaleRatio / (isTouchPad ? 5 : 1)
|
||||||
|
const scale = Math.max(this.scale - scaleRatio, 0.1)
|
||||||
this.scaleInCenter(scale, cx, cy)
|
this.scaleInCenter(scale, cx, cy)
|
||||||
this.transform()
|
this.transform()
|
||||||
this.mindMap.emit('scale', this.scale)
|
this.mindMap.emit('scale', this.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 放大
|
// 放大
|
||||||
enlarge(cx, cy) {
|
enlarge(cx, cy, isTouchPad) {
|
||||||
const scale = this.scale + this.mindMap.opt.scaleRatio
|
const scaleRatio = this.mindMap.opt.scaleRatio / (isTouchPad ? 5 : 1)
|
||||||
|
const scale = this.scale + scaleRatio
|
||||||
this.scaleInCenter(scale, cx, cy)
|
this.scaleInCenter(scale, cx, cy)
|
||||||
this.transform()
|
this.transform()
|
||||||
this.mindMap.emit('scale', this.scale)
|
this.mindMap.emit('scale', this.scale)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user