xushiting 2 лет назад
Родитель
Сommit
219fd93e77
3 измененных файлов с 16 добавлено и 17 удалено
  1. 2 2
      src/graphic/Coordinate.js
  2. 4 5
      src/graphic/Layer.js
  3. 10 10
      src/graphic/Service/DataService.js

+ 2 - 2
src/graphic/Coordinate.js

@@ -79,8 +79,8 @@ export default class Coordinate {
     if (canvas) {
       canvas.width *= this.ratio;
       canvas.height *= this.ratio;
-      this.width = canvas.clientWidth;
-      this.height = canvas.clientHeight;
+      this.width = canvas.width;
+      this.height = canvas.height;
     }
     this.setCenter(canvas);
   }

+ 4 - 5
src/graphic/Layer.js

@@ -220,19 +220,18 @@ export default class Layer {
         // let zoom =
         //   (mathUtil.getDistance(point1, point2) /
         //     mathUtil.getDistance(this.StorePage1, this.StorePage2)) *
-        //   coordinate.defaultZoom;
+        //   coordinate.zoom;
         let zoom =
-          coordinate.defaultZoom +
+          coordinate.zoom +
           mathUtil.getDistance(point1, point2) -
           mathUtil.getDistance(this.StorePage1, this.StorePage2);
-
         this.zoomVector(zoom);
         return;
       }
     }
 
-    let dx = X - this.lastX;
-    let dy = Y - this.lastY;
+    let dx = (X - this.lastX) * coordinate.ratio;
+    let dy = (Y - this.lastY) * coordinate.ratio;
 
     let position = coordinate.getXYFromScreen({
       x: X,

+ 10 - 10
src/graphic/Service/DataService.js

@@ -9,10 +9,10 @@ export class DataService {
     this.grid = {
       startX: 0,
       startY: 0,
-      step1: 50,
-      step2: 250,
-      defalutstep1: 50,
-      defalutstep2: 250,
+      step1: 50 * coordinate.ratio,
+      step2: 250 * coordinate.ratio,
+      defalutstep1: 50 * coordinate.ratio,
+      defalutstep2: 250 * coordinate.ratio,
       display: true,
     };
     this.vectorData = {
@@ -82,12 +82,12 @@ export class DataService {
     }
   }
 
-  setGridForZoom(w, h, ratio) {
-    console.log("setGridForZoom:" + ratio);
-    this.grid.startX = w / 2 - (ratio * w) / 2;
-    this.grid.startY = w / 2 - (ratio * h) / 2;
-    this.grid.step1 = this.grid.defalutstep1 * ratio;
-    this.grid.step2 = this.grid.defalutstep2 * ratio;
+  setGridForZoom(w, h, zoom) {
+    console.log("setGridForZoom:" + zoom);
+    this.grid.startX = w / 2 - (zoom * w) / 2;
+    this.grid.startY = w / 2 - (zoom * h) / 2;
+    this.grid.step1 = this.grid.defalutstep1 * zoom;
+    this.grid.step2 = this.grid.defalutstep2 * zoom;
     while (this.grid.startX > 0) {
       this.grid.startX -= this.grid.step2;
     }