P5-1417: Dragbar and rulers should work with inches
This commit is contained in:
@@ -74,7 +74,7 @@ var DragHandle = function (handler) {
|
||||
this.__handles.y.set({left: handler.getTracks().y.left}).setCoords();
|
||||
this.__handles.x.set({top: handler.getTracks().x.top}).setCoords();
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
this.init = function () {
|
||||
var viewportData = this.getCanvas().getViewport().getData();
|
||||
@@ -86,8 +86,8 @@ var DragHandle = function (handler) {
|
||||
}
|
||||
|
||||
this.__handles = {
|
||||
x: getRect(viewportData.dim.width + ' cm', viewportData.width),
|
||||
y: getRect(viewportData.dim.height + ' cm', viewportData.height)
|
||||
x: getRect(viewportData.dim.width + ' ' + viewportData.dim.units, viewportData.width),
|
||||
y: getRect(viewportData.dim.height + ' ' + viewportData.dim.units, viewportData.height)
|
||||
};
|
||||
|
||||
this.__handles.x.addTo(this.getCanvas()).centerH().set({ top: tracks.x.top }).setCoords();
|
||||
|
||||
@@ -76,12 +76,13 @@ function ImageEditor(canvasId, args) {
|
||||
* Crops image to desired dimensions
|
||||
* @param {int} width [description]
|
||||
* @param {int} height [description]
|
||||
* @param {string} units cm|inch
|
||||
* @return {ImageEditor}
|
||||
*/
|
||||
this.crop = function (width, height) {
|
||||
this.crop = function (width, height, units) {
|
||||
_canvas.getImage().__cropped = false;
|
||||
_canvas.getImageData().removeCropData();
|
||||
_canvas.getViewport().set(width, height);
|
||||
_canvas.getViewport().set(width, height, units);
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ function RulerHandler(viewport) {
|
||||
dim = viewport.getData().dim.height - dim;
|
||||
}
|
||||
|
||||
this.setText(Math.round(dim * 100) / 100 + ' cm');
|
||||
this.setText(Math.round(dim * 100) / 100 + ' ' + viewport.getData().dim.units);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ function Viewport(canvas) {
|
||||
*/
|
||||
this.reset = function () {
|
||||
if (_data) {
|
||||
return this.set(_data.dim.width, _data.dim.height);
|
||||
return this.set(_data.dim.width, _data.dim.height, _data.dim.units);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -127,10 +127,12 @@ function Viewport(canvas) {
|
||||
/**
|
||||
* @param {Number} width
|
||||
* @param {Number} height
|
||||
* @param {string} units
|
||||
* @return {Viewport}
|
||||
*/
|
||||
this.set = function (width, height) {
|
||||
this.set = function (width, height, units) {
|
||||
_data = util.calcCrop(canvas.getImage(), width, height);
|
||||
_data.dim.units = units;
|
||||
apply();
|
||||
this.getGores().reset();
|
||||
this.getRulers().reset();
|
||||
|
||||
Reference in New Issue
Block a user