Added simple resize function to canvas. Needs to be fixed with positioning of other elements

This commit is contained in:
Erik Tiekstra
2017-05-19 07:41:20 +02:00
parent eb6ff91aff
commit 7817b35a50
3 changed files with 18 additions and 10 deletions
+2 -10
View File
@@ -25,15 +25,7 @@
#wrapper { #wrapper {
margin: 0 auto; margin: 0 auto;
width: 100%;
height: 600px;
} }
.canvas-container {
margin: 0 auto;
width: 100% !important;
}
canvas {
margin: 0 auto;
max-width: 100% !important;
height: auto !important;
}
+6
View File
@@ -31,6 +31,12 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
}); });
}, },
resize: function (args) {
this.setHeight(args.height);
this.setWidth(args.width);
this.renderAll();
},
get3dHandler: function () { get3dHandler: function () {
return this.__3dHandler || return this.__3dHandler ||
(this.__3dHandler = new ThreeDHandler(this)); (this.__3dHandler = new ThreeDHandler(this));
+10
View File
@@ -2,6 +2,9 @@
(function() { (function() {
var $document = $(document); var $document = $(document);
var $window = $(window);
var $wrapper = $('#wrapper');
// Inputs for the editor // Inputs for the editor
var $input = { var $input = {
w: $('#form-control input[name="w"]'), w: $('#form-control input[name="w"]'),
@@ -62,6 +65,11 @@
}, },
SetBorder: function () { SetBorder: function () {
editor.canvas.getViewport().setFrame($(this).val()); editor.canvas.getViewport().setFrame($(this).val());
},
handleResize: function() {
var width = $wrapper.width();
var height = $wrapper.height();
editor.canvas.resize({width: width, height: height});
} }
}; };
@@ -80,4 +88,6 @@
.on('PIE:dragbar-click', function(e, data) { .on('PIE:dragbar-click', function(e, data) {
console.log('Clicked on a dragbar! Axis: ' + data.axis); console.log('Clicked on a dragbar! Axis: ' + data.axis);
}); });
$window.on('resize', Event.handleResize);
}()); }());