added default unit parameter to settings

This commit is contained in:
Martin
2017-08-06 01:06:20 +02:00
parent b452790043
commit 4b55debcaf
3 changed files with 15 additions and 11 deletions
+7 -5
View File
@@ -1210,7 +1210,9 @@ function ImageEditor(canvasId, args) {
dimensions: { dimensions: {
width: 800, width: 800,
height: 600 height: 600
} },
// Default unit
unit: 'cm'
}, args); }, args);
@@ -1269,14 +1271,14 @@ function ImageEditor(canvasId, args) {
* Crops image to desired dimensions * Crops image to desired dimensions
* @param {int} width [description] * @param {int} width [description]
* @param {int} height [description] * @param {int} height [description]
* @param {string} units cm|inch * @param {string} unit cm|inch
* @return {ImageEditor} * @return {ImageEditor}
*/ */
this.crop = function (width, height, units) { this.crop = function (width, height, unit) {
unit = typeof unit !== 'undefined' ? unit : _settings.unit;
_canvas.getImageData().removeCropData(); _canvas.getImageData().removeCropData();
_canvas.getViewport().set(width, height, units); _canvas.getViewport().set(width, height, unit);
var shouldBeCropped = util.isAspectChanged(_canvas.getImage().width, _canvas.getImage().height, width, height); var shouldBeCropped = util.isAspectChanged(_canvas.getImage().width, _canvas.getImage().height, width, height);
+1 -1
View File
@@ -17,7 +17,7 @@
}); });
function cropImage() { function cropImage() {
editor.crop(width.value, height.value, 'cm'); editor.crop(width.value, height.value);
} }
function resizeEditor() { function resizeEditor() {
+7 -5
View File
@@ -24,7 +24,9 @@ function ImageEditor(canvasId, args) {
dimensions: { dimensions: {
width: 800, width: 800,
height: 600 height: 600
} },
// Default unit
unit: 'cm'
}, args); }, args);
@@ -83,14 +85,14 @@ function ImageEditor(canvasId, args) {
* Crops image to desired dimensions * Crops image to desired dimensions
* @param {int} width [description] * @param {int} width [description]
* @param {int} height [description] * @param {int} height [description]
* @param {string} units cm|inch * @param {string} unit cm|inch
* @return {ImageEditor} * @return {ImageEditor}
*/ */
this.crop = function (width, height, units) { this.crop = function (width, height, unit) {
unit = typeof unit !== 'undefined' ? unit : _settings.unit;
_canvas.getImageData().removeCropData(); _canvas.getImageData().removeCropData();
_canvas.getViewport().set(width, height, units); _canvas.getViewport().set(width, height, unit);
var shouldBeCropped = util.isAspectChanged(_canvas.getImage().width, _canvas.getImage().height, width, height); var shouldBeCropped = util.isAspectChanged(_canvas.getImage().width, _canvas.getImage().height, width, height);