diff --git a/static/diagram.js b/static/diagram.js index 445daf9..fd00a96 100644 --- a/static/diagram.js +++ b/static/diagram.js @@ -75,6 +75,9 @@ function diagramOnMouseMove(ev) { function diagramOnWheel(ev) { //_diagram.onwheel(ev); } +function diagramOnContext(ev) { + ev.preventDefault(); +} var Diagrams = /** @class */ (function () { function Diagrams(canvasId) { this.nodes = new Array(); @@ -105,6 +108,7 @@ var Diagrams = /** @class */ (function () { this.canvas.onmousedown = diagramOnMouseDown; this.canvas.onmouseup = diagramOnMouseUp; this.canvas.onwheel = diagramOnWheel; + this.canvas.oncontextmenu = diagramOnContext; window.onresize = diargramOnResize; } Diagrams.prototype.onmousemove = function (ev) { @@ -181,6 +185,9 @@ var Diagrams = /** @class */ (function () { this.panning = true; }; Diagrams.prototype.onmouseup = function (ev) { + if (ev.button != 0) { + return; + } this.panning = false; this.nodeDragging = null; if (this.makingConnectionNode !== null) { @@ -324,8 +331,6 @@ var Diagrams = /** @class */ (function () { Diagrams.prototype.removeConnection = function (A, B) { this.connections.splice(this.connections.indexOf([A, B]), 1); }; - Diagrams.prototype.drawDiagramNode = function (node) { - }; Diagrams.prototype.fillParent = function () { this.canvas.width = this.canvas.clientWidth; this.canvas.height = this.canvas.clientHeight; diff --git a/static/diagram.ts b/static/diagram.ts index e31756f..e0806c2 100644 --- a/static/diagram.ts +++ b/static/diagram.ts @@ -99,6 +99,9 @@ function diagramOnMouseMove(ev: MouseEvent){ function diagramOnWheel(ev: WheelEvent){ //_diagram.onwheel(ev); } +function diagramOnContext(ev: MouseEvent){ + ev.preventDefault(); +} class Diagrams { canvas: HTMLCanvasElement; @@ -140,6 +143,7 @@ class Diagrams { this.canvas.onmousedown = diagramOnMouseDown; this.canvas.onmouseup = diagramOnMouseUp; this.canvas.onwheel = diagramOnWheel; + this.canvas.oncontextmenu = diagramOnContext; window.onresize = diargramOnResize; } @@ -218,6 +222,10 @@ class Diagrams { } onmouseup(ev: MouseEvent){ + if (ev.button != 0){ + return; + } + this.panning = false; this.nodeDragging = null; if (this.makingConnectionNode !== null){ @@ -388,11 +396,7 @@ class Diagrams { removeConnection(A: DiagramNode, B: DiagramNode){ this.connections.splice(this.connections.indexOf([A, B]), 1); } - - drawDiagramNode(node: DiagramNode){ - - } - + fillParent(){ this.canvas.width = this.canvas.clientWidth; this.canvas.height = this.canvas.clientHeight;