Skip to content
Snippets Groups Projects
Commit f945c9f7 authored by bbaer's avatar bbaer
Browse files

updated to fabric 5

parent 03f93d8a
No related branches found
No related tags found
1 merge request!451Fabric update
Pipeline #7416 passed
This diff is collapsed.
...@@ -330,7 +330,7 @@ $(function (n) { ...@@ -330,7 +330,7 @@ $(function (n) {
this.canvas.loadFromJSON(fabricJSON, function() { this.canvas.loadFromJSON(fabricJSON, function() {
this.firstLoad = true; this.firstLoad = true;
that.setBackground(); that.setBackground();
that.resizeCanvas(); //that.resizeCanvas();
if(!isReadOnly) { that.setBrush(); } if(!isReadOnly) { that.setBrush(); }
that.canvas.renderAll(); that.canvas.renderAll();
that.userChangePossible = true; that.userChangePossible = true;
...@@ -546,14 +546,12 @@ $(function (n) { ...@@ -546,14 +546,12 @@ $(function (n) {
if (this.backgroundImage) { if (this.backgroundImage) {
fabric.Image.fromURL(this.backgroundImage, function(img) { fabric.Image.fromURL(this.backgroundImage, function(img) {
img.set({ img.set({
width: that.canvas.width,
height: that.canvas.height,
originX: 'left',
originY: 'top',
lockUniScaling: true, lockUniScaling: true,
centeredScaling: true, centeredScaling: true,
centeredRotation: true centeredRotation: true
}); });
img.scaleX = that.canvas.width / img.width;
img.scaleY = that.canvas.height / img.height;
that.canvas.setBackgroundImage(img, function() { that.canvas.setBackgroundImage(img, function() {
that.canvas.renderAll.bind(that.canvas); that.canvas.renderAll.bind(that.canvas);
that.canvas.renderAll(); that.canvas.renderAll();
...@@ -564,14 +562,14 @@ $(function (n) { ...@@ -564,14 +562,14 @@ $(function (n) {
$image.onload = function() { $image.onload = function() {
console.log("Image loaded"); console.log("Image loaded");
var img = new fabric.Image(this, { var img = new fabric.Image(this, {
width: that.canvas.width,
height: that.canvas.height,
originX: 'left', originX: 'left',
originY: 'top', originY: 'top',
lockUniScaling: true, lockUniScaling: true,
centeredScaling: true, centeredScaling: true,
centeredRotation: true centeredRotation: true
}); });
img.scaleX = that.canvas.width / img.width;
img.scaleY = that.canvas.height / img.height;
img.rotate(that.rotation); img.rotate(that.rotation);
that.canvas.setBackgroundImage(img, function() { that.canvas.setBackgroundImage(img, function() {
that.canvas.renderAll.bind(that.canvas); that.canvas.renderAll.bind(that.canvas);
...@@ -664,9 +662,9 @@ $(function (n) { ...@@ -664,9 +662,9 @@ $(function (n) {
// for Fabric 1.x and current Fabric 2.0 beta has a major drawing bug. // for Fabric 1.x and current Fabric 2.0 beta has a major drawing bug.
n.Fabric.prototype.deleteActiveGroup = function() { n.Fabric.prototype.deleteActiveGroup = function() {
var that = this; var that = this;
if (this.canvas.getActiveGroup()) { if (this.canvas.getActiveObjects()) {
this.canvas.getActiveGroup().forEachObject(function(o) { that.canvas.remove(o) }); this.canvas.getActiveObjects().forEach(function(o) { that.canvas.remove(o) });
this.canvas.discardActiveGroup().renderAll(); this.canvas.discardActiveObject().renderAll();
} else { } else {
this.canvas.remove(this.canvas.getActiveObject()); this.canvas.remove(this.canvas.getActiveObject());
} }
...@@ -1048,13 +1046,14 @@ $(function (n) { ...@@ -1048,13 +1046,14 @@ $(function (n) {
} }
var that = this; var that = this;
this.outputField.val(JSON.stringify(that.canvas.toJSON())); this.outputField.val(JSON.stringify(that.canvas.toJSON()));
/*
if (this.qfqPage.qfqForm) { if (this.qfqPage.qfqForm) {
this.qfqPage.qfqForm.eventEmitter.emitEvent('form.changed', n.EventEmitter.makePayload(that, null)); this.qfqPage.qfqForm.eventEmitter.emitEvent('form.changed', n.EventEmitter.makePayload(that, null));
this.qfqPage.qfqForm.changeHandler(); this.qfqPage.qfqForm.changeHandler();
this.qfqPage.qfqForm.form.formChanged = true; this.qfqPage.qfqForm.form.formChanged = true;
} else { } else {
throw("Error: Couldn't initialize qfqForm - not possible to send form.changed event"); throw("Error: Couldn't initialize qfqForm - not possible to send form.changed event");
} }*/
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment