Commit bd605ab3 authored by bbaer's avatar bbaer
Browse files

quick save to switch to another branch

parent 95ec1504
......@@ -11,6 +11,12 @@ $(function (n) {
stateful: true,
enableRetinaScaling: true
});
var qFabric = this;
this.canvas.on('mouse:up', function (e) { qFabric.defaultMouseUpEvent(e) });
this.canvas.on('mouse:down', function (e) { qFabric.defaultMouseDownEvent(e) });
this.canvas.on('mouse:move', function (e) { qFabric.defaultMouseMoveEvent(e) });
this.canvas.on('mouse:out', function (e) { qFabric.defaultMouseOutEvent(e) });
this.canvas.on('after:render', function(){ this.calcOffset(); });
this.saveOne = false;
this.saveTwo = false;
this.saveThree = false;
......@@ -107,8 +113,6 @@ $(function (n) {
});
};
n.Fabric.prototype.deactivatePanning = function () {
panning = false;
};
......@@ -146,22 +150,23 @@ $(function (n) {
};
n.Fabric.prototype.deleteActiveGroup = function() {
if (canvas.getActiveGroup()) {
canvas.getActiveGroup().forEachObject(function(o) { canvas.remove(o) });
canvas.discardActiveGroup().renderAll();
var that = this;
if (this.canvas.getActiveGroup()) {
this.canvas.getActiveGroup().forEachObject(function(o) { that.canvas.remove(o) });
this.canvas.discardActiveGroup().renderAll();
} else {
canvas.remove(canvas.getActiveObject());
this.canvas.remove(this.canvas.getActiveObject());
}
};
n.Fabric.prototype.freeDrawRectangleStart = function(o) {
this.isDown = true;
var pointer = canvas.getPointer(o.e);
var pointer = this.canvas.getPointer(o.e);
this.origX = pointer.x;
this.origY = pointer.y;
var colorFill = getActiveRGBA(0.4);
var colorBorder = getActiveRGBA(1);
this.pointer = canvas.getPointer(o.e);
this.pointer = this.canvas.getPointer(o.e);
var rect = new fabric.Rect({
left: origX,
top: origY,
......@@ -209,7 +214,7 @@ $(function (n) {
};
n.Fabric.prototype.resizeRectangle = function(o) {
if (!isDown) return;
if (!this.isDown) return;
var rect = canvas.getActiveObject();
var pointer = canvas.getPointer(o.e);
......@@ -240,12 +245,7 @@ $(function (n) {
this.canvas.freeDrawingBrush.width = this.brushSize;
};
n.fabric = new n.Fabric();
n.fabric.setBackground("../mockup/mockData/Scan2a.jpeg");
// Custom Mouse / Touch Events on Canvas
n.fabric.canvas.on('mouse:up', function (e) {
n.Fabric.prototype.defaultMouseUpEvent = function(e) {
if (this.moveMode) {
this.deactivatePanning();
}
......@@ -253,15 +253,15 @@ $(function (n) {
if (this.drawRectangleMode || this.drawTextBoxMode) {
this.deactivateRectangleDrawing();
}
});
};
n.fabric.canvas.on('mouse:out', function (e) {
n.Fabric.prototype.defaultMouseOutEvent = function(e) {
if (this.moveMode) {
this.deactivatePanning();
}
});
};
n.fabric.canvas.on('mouse:down', function (e) {
n.Fabric.prototype.defaultMouseDownEvent = function(e) {
if (this.moveMode) {
this.panning = true;
}
......@@ -271,16 +271,22 @@ $(function (n) {
if (this.drawTextBoxMode) {
this.freeDrawTextBoxStart(e);
}
});
};
n.fabric.canvas.on('mouse:move', function(e) {
n.Fabric.prototype.defaultMouseMoveEvent = function(e) {
if (this.moveMode) {
this.panImage(e);
}
if (this.drawRectangleMode || this.drawTextBoxMode) {
this.resizeRectangle(e);
}
});
};
n.fabric = new n.Fabric();
n.fabric.setBackground("../mockup/mockData/Scan2a.jpeg");
// Custom Mouse / Touch Events on Canvas
n.fabric.canvas.onkeyup = function(e) {
if(e.keyCode == 46) {
......@@ -289,8 +295,6 @@ $(function (n) {
console.log(e.keyCode);
};
n.fabric.canvas.on('after:render', function(){ this.calcOffset(); });
// Button Events
$("#clear-canvas").on( "click", function() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment