move the source files to ./src
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
'use strict';
|
||||
|
||||
function ImageDataHandler(img) {
|
||||
|
||||
/**
|
||||
* Gets information about how the cropped image is dragged
|
||||
* @return {Object}
|
||||
*/
|
||||
this.getCropData = function () {
|
||||
return JSON.parse(sessionStorage.getItem('cropData'));
|
||||
};
|
||||
|
||||
this.setCropData = function() {
|
||||
var viewportBounds = img.canvas.getViewport().getBounds();
|
||||
var dragAxis = img.canvas.getViewport().getData().axis;
|
||||
|
||||
var cropData = {
|
||||
x: dragAxis === 'x' ? (viewportBounds.left - img.left) / (img.width * img.scaleX) : 0,
|
||||
y: dragAxis === 'y' ? (viewportBounds.top - img.top) / (img.height * img.scaleY) : 0,
|
||||
}
|
||||
|
||||
sessionStorage.setItem('cropData', JSON.stringify(cropData));
|
||||
}
|
||||
|
||||
this.removeCropData = function() {
|
||||
sessionStorage.removeItem('cropData');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an object containing applied transformations for the Image and also
|
||||
* how it is cropped and dragged.
|
||||
* @return {Object}
|
||||
*/
|
||||
this.getData = function () {
|
||||
var viewportData = img.canvas.getViewport().getData();
|
||||
|
||||
var returnValue = $.extend(
|
||||
{},
|
||||
{
|
||||
mirrored: img.canvas.getMirror().getStatus(),
|
||||
width: viewportData.dim.width,
|
||||
height: viewportData.dim.height,
|
||||
},
|
||||
this.getCropData()
|
||||
);
|
||||
|
||||
if (img.canvas.__type === 'canvas') {
|
||||
var frameHandler = img.canvas.getViewport().getFrameHandler();
|
||||
returnValue.edge = frameHandler.getFrameType();
|
||||
returnValue.framed = returnValue.edge !== 'none';
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = ImageDataHandler;
|
||||
Reference in New Issue
Block a user