Browse Source

canvasview 增加滚轮拖动抛出事件,增加滚轮缩放抛出事件

haojianlong 4 years ago
parent
commit
9a92911b9a
2 changed files with 5 additions and 2 deletions
  1. 2 0
      persagy-web-draw/src/SCanvasView.ts
  2. 3 2
      persagy-web-graph/src/SGraphScene.ts

+ 2 - 0
persagy-web-draw/src/SCanvasView.ts

@@ -284,6 +284,7 @@ export class SCanvasView extends SObject {
                 this.origin.y += se.y - this._midKeyPos.y;
                 this.origin.y += se.y - this._midKeyPos.y;
                 this._midKeyPos.x = se.x;
                 this._midKeyPos.x = se.x;
                 this._midKeyPos.y = se.y;
                 this._midKeyPos.y = se.y;
+                this.$emit("midMouseMove", se);
                 this.update();
                 this.update();
                 return;
                 return;
             }
             }
@@ -317,6 +318,7 @@ export class SCanvasView extends SObject {
             //向上滑动
             //向上滑动
             this.scaleByPoint(1 / this.wheelZoom, event.offsetX, event.offsetY);
             this.scaleByPoint(1 / this.wheelZoom, event.offsetX, event.offsetY);
         }
         }
+        this.$emit("onMouseWheel", this.scale, event.deltaY < 0);
     }
     }
 
 
     /**
     /**

+ 3 - 2
persagy-web-graph/src/SGraphScene.ts

@@ -24,7 +24,7 @@
  * *********************************************************************************************************************
  * *********************************************************************************************************************
  */
  */
 
 
-import { SMouseEvent, SMatrix } from "@persagy-web/base";
+import { SMouseEvent, SMatrix, SObject } from "@persagy-web/base";
 import { SPainter, SPoint, SRect } from "@persagy-web/draw";
 import { SPainter, SPoint, SRect } from "@persagy-web/draw";
 import { SGraphItem } from "./SGraphItem";
 import { SGraphItem } from "./SGraphItem";
 import { SGraphView } from "./SGraphView";
 import { SGraphView } from "./SGraphView";
@@ -35,7 +35,7 @@ import { SGraphSelectContainer } from "./SGraphSelectContainer";
  *
  *
  * @author 庞利祥 <sybotan@126.com>
  * @author 庞利祥 <sybotan@126.com>
  */
  */
-export class SGraphScene {
+export class SGraphScene extends SObject {
     /** 展示场景的视图 */
     /** 展示场景的视图 */
     view: SGraphView | null = null;
     view: SGraphView | null = null;
     /** 根节点 */
     /** 根节点 */
@@ -51,6 +51,7 @@ export class SGraphScene {
      * 构造函数
      * 构造函数
      */
      */
     constructor() {
     constructor() {
+        super();
         this.root.scene = this;
         this.root.scene = this;
         this.addItem(this.selectContainer);
         this.addItem(this.selectContainer);
     }
     }