From f89d2b774175f3dc0cf12967c274974d4d164615 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 03 十二月 2025 16:05:13 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/locMap/locMap.html |   48 +++++++++++++++++++++++-------------------------
 1 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/src/main/webapp/views/locMap/locMap.html b/src/main/webapp/views/locMap/locMap.html
index a8a34d1..2fcfd1d 100644
--- a/src/main/webapp/views/locMap/locMap.html
+++ b/src/main/webapp/views/locMap/locMap.html
@@ -355,29 +355,16 @@
         pixiApp.view.addEventListener('wheel', (event) => {
           event.stopPropagation();
           event.preventDefault();
-          // 鍥犱负鐢诲竷鏄厖婊¤绐楃殑锛屾墍浠lientX绛変簬mouse point鍦╮enderer涓婄殑x鍧愭爣
-          const globalPos = [event.clientX, event.clientY];
-          const delta = event.deltaY;
+          const sx = event.clientX;
+          const sy = event.clientY;
           const oldZoom = pixiApp.stage.scale.x;
+          const delta = event.deltaY;
           let newZoom = oldZoom * 0.999 ** delta;
-
-          // const oldStageMatrix = app.stage.localTransform.clone();
-          // const oldStagePos = oldStageMatrix.applyInverse(pointerGlobalPos);
-          const oldStagePos = globalPos;
-          const dx = oldStagePos[0] * oldZoom - oldStagePos[0] * newZoom;
-          const dy = oldStagePos[1] * oldZoom - oldStagePos[1] * newZoom;
-
-          pixiApp.stage.setTransform(
-                  pixiApp.stage.position.x + dx,
-                  pixiApp.stage.position.y + dy,
-                  newZoom,
-                  newZoom,
-                  0,
-                  0,
-                  0,
-                  0,
-                  0
-          );
+          const worldX = (sx - pixiApp.stage.position.x) / oldZoom;
+          const worldY = (sy - pixiApp.stage.position.y) / oldZoom;
+          const newPosX = sx - worldX * newZoom;
+          const newPosY = sy - worldY * newZoom;
+          pixiApp.stage.setTransform(newPosX, newPosY, newZoom, newZoom, 0, 0, 0, 0, 0);
 
         });
         //*******************缂╂斁鐢诲竷*******************
@@ -462,10 +449,21 @@
             }
           });
 
-          //瑙嗚灞呬腑
-          let containerWidth = (pixiApp.view.width - objectsContainer.width) / 2;
-          let containerHeight = (pixiApp.view.height - objectsContainer.height) / 2;
-          pixiApp.stage.position.set(containerWidth, containerHeight);
+          const b1 = objectsContainer.getLocalBounds();
+          const b2 = objectsContainer2.getLocalBounds();
+          const minX = Math.min(b1.x, b2.x);
+          const minY = Math.min(b1.y, b2.y);
+          const maxX = Math.max(b1.x + b1.width, b2.x + b2.width);
+          const maxY = Math.max(b1.y + b1.height, b2.y + b2.height);
+          const contentW = Math.max(0, maxX - minX);
+          const contentH = Math.max(0, maxY - minY);
+          const vw = pixiApp.view.width;
+          const vh = pixiApp.view.height;
+          let scale = Math.min(vw / contentW, vh / contentH) * 0.95;
+          if (!isFinite(scale) || scale <= 0) { scale = 1; }
+          const posX = (vw - contentW * scale) / 2 - minX * scale;
+          const posY = (vh - contentH * scale) / 2 - minY * scale;
+          pixiApp.stage.setTransform(posX, posY, scale, scale, 0, 0, 0, 0, 0);
         }else {
           let diff = this.findDiffList(this.map, map);
           diff.forEach((item, index) => {

--
Gitblit v1.9.1