From 937f7d29699f9f88fbdf3777f3e7e243fcb25b9e Mon Sep 17 00:00:00 2001 From: wangqi01 <13693607080@163.com> Date: Fri, 20 Sep 2024 18:03:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=99=90=E5=80=BC=E5=B9=B3=E7=A7=BB?= =?UTF-8?q?=E6=AD=A5=E9=95=BF=E6=AF=94=E4=BE=8B=E7=94=9F=E6=95=88=E5=8F=AA?= =?UTF-8?q?=E5=9C=A8=E9=BC=A0=E6=A0=87/=E8=A7=A6=E6=8E=A7=E6=9D=BF?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E8=A1=8C=E4=B8=BA=E5=86=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/core/view/View.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/simple-mind-map/src/core/view/View.js b/simple-mind-map/src/core/view/View.js index 9e00bb6d..0093e944 100644 --- a/simple-mind-map/src/core/view/View.js +++ b/simple-mind-map/src/core/view/View.js @@ -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') }