diff --git a/simple-mind-map/src/core/view/View.js b/simple-mind-map/src/core/view/View.js index 3586f362..3f756dc7 100644 --- a/simple-mind-map/src/core/view/View.js +++ b/simple-mind-map/src/core/view/View.js @@ -222,8 +222,12 @@ class View { } // 设置缩放 - setScale(scale) { - this.scale = scale + setScale(scale, cx, cy) { + if (cx !== undefined && cy !== undefined) { + this.scaleInCenter(cx, cy, scale) + } else { + this.scale = scale + } this.transform() this.mindMap.emit('scale', this.scale) } diff --git a/simple-mind-map/src/plugins/TouchEvent.js b/simple-mind-map/src/plugins/TouchEvent.js index 641c4f9d..1cb7ec70 100644 --- a/simple-mind-map/src/plugins/TouchEvent.js +++ b/simple-mind-map/src/plugins/TouchEvent.js @@ -53,8 +53,11 @@ class TouchEvent { let ox = touch1.clientX - touch2.clientX let oy = touch1.clientY - touch2.clientY let distance = Math.sqrt(Math.pow(ox, 2) + Math.pow(oy, 2)) - let cx = (touch1.clientX + touch2.clientX) / 2 - let cy = (touch1.clientY + touch2.clientY) / 2 + // 以两指中心点进行缩放 + let { x: touch1ClientX, y: touch1ClientY } = this.mindMap.toPos(touch1.clientX, touch1.clientY) + let { x: touch2ClientX, y: touch2ClientY } = this.mindMap.toPos(touch2.clientX, touch2.clientY) + let cx = (touch1ClientX + touch2ClientX) / 2 + let cy = (touch1ClientY + touch2ClientY) / 2 if (distance > this.doubleTouchmoveDistance) { // 放大 this.mindMap.view.enlarge(cx, cy) diff --git a/web/src/pages/Doc/en/changelog/index.md b/web/src/pages/Doc/en/changelog/index.md index 4e9f98b7..7f4e7bf2 100644 --- a/web/src/pages/Doc/en/changelog/index.md +++ b/web/src/pages/Doc/en/changelog/index.md @@ -1,5 +1,9 @@ # Changelog +## 0.6.4 + +New: 1.The default is to scale at the center point of the canvas. 2.Optimize the scaling of both fingers on the mobile end, with the center position of the two fingers as the center point for scaling. + ## 0.6.3 Fix: 1.Fix the issue where the summary node will respond to inserting node shortcuts. diff --git a/web/src/pages/Doc/en/changelog/index.vue b/web/src/pages/Doc/en/changelog/index.vue index b03cad68..ef06826e 100644 --- a/web/src/pages/Doc/en/changelog/index.vue +++ b/web/src/pages/Doc/en/changelog/index.vue @@ -1,6 +1,8 @@