fix: 限值平移步长比例生效只在鼠标/触控板滚动行为内

This commit is contained in:
wangqi01
2024-09-20 18:03:18 +08:00
parent 38c0fe2e39
commit 937f7d2969

View File

@@ -138,7 +138,8 @@ class View {
if (dirs.includes(CONSTANTS.DIR.RIGHT)) {
mx = -stepX
}
this.translateXY(mx, my)
// this.translateXY(mx, my)
this.translateXYwithRatio(mx, my)
}
})
this.mindMap.on('resize', () => {
@@ -179,16 +180,25 @@ class View {
// 平移x,y方向
translateXY(x, y) {
if (x === 0 && y === 0) return
this.x += x * this.mindMap.opt.translateRatio
this.y += y * this.mindMap.opt.translateRatio
this.x += x
this.y += y
this.transform()
this.emitEvent('translate')
}
// 鼠标/触控板滑动时根据配置的平移步长比例平移x,y方向
translateXYwithRatio(x, y) {
if (x === 0 && y === 0) return
this.x += x * this.mindMap.opt.translateRatio
this.y += y * this.mindMap.opt.translateRatio
this.transform()
this.emitEvent('translate')
}
// 平移x方向
translateX(step) {
if (step === 0) return
this.x += step * this.mindMap.opt.translateRatio
this.x += step
this.transform()
this.emitEvent('translate')
}
@@ -203,7 +213,7 @@ class View {
// 平移y方向
translateY(step) {
if (step === 0) return
this.y += step * this.mindMap.opt.translateRatio
this.y += step
this.transform()
this.emitEvent('translate')
}