Renamed file to get image Data.
This commit is contained in:
@@ -7,6 +7,7 @@ var DragbarHandler = require('./DragbarHandler');
|
|||||||
var Viewport = require('./Viewport');
|
var Viewport = require('./Viewport');
|
||||||
var ThreeDHandler = require('./3dHandler');
|
var ThreeDHandler = require('./3dHandler');
|
||||||
var MirrorHandler = require('./MirrorHandler');
|
var MirrorHandler = require('./MirrorHandler');
|
||||||
|
var ImageDataHandler = require('./ImageDataHandler');
|
||||||
|
|
||||||
var $document = $(document);
|
var $document = $(document);
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
|
|||||||
if (this.getImage().__cropped && !this.get3dHandler().isEnabled()) {
|
if (this.getImage().__cropped && !this.get3dHandler().isEnabled()) {
|
||||||
this.getApertures().setTransparent(false);
|
this.getApertures().setTransparent(false);
|
||||||
|
|
||||||
this.getImage().transformation.setCropData();
|
this.getImageData().setCropData();
|
||||||
// Trigger event to tell the image has been dragged.
|
// Trigger event to tell the image has been dragged.
|
||||||
$document.trigger('PIE:dragged');
|
$document.trigger('PIE:dragged');
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,7 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
|
|||||||
* @return {String}
|
* @return {String}
|
||||||
*/
|
*/
|
||||||
get3dUrl: function () {
|
get3dUrl: function () {
|
||||||
var imageData = this.getImage().transformation.getData();
|
var imageData = this.getImageData().getData();
|
||||||
var params = [
|
var params = [
|
||||||
'h=400',
|
'h=400',
|
||||||
'canvas[edge]=' + imageData.edge,
|
'canvas[edge]=' + imageData.edge,
|
||||||
@@ -98,13 +99,21 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Viewport}
|
* @return {MirrorHandler}
|
||||||
*/
|
*/
|
||||||
getMirror: function () {
|
getMirror: function () {
|
||||||
return this.__mirror ||
|
return this.__mirror ||
|
||||||
(this.__mirror = new MirrorHandler(this.getImage()));
|
(this.__mirror = new MirrorHandler(this.getImage()));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {MirrorHandler}
|
||||||
|
*/
|
||||||
|
getImageData: function () {
|
||||||
|
return this.__imageData ||
|
||||||
|
(this.__imageData = new ImageDataHandler(this.getImage()));
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Viewport}
|
* @return {Viewport}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function ImageTransformationHandler(img) {
|
function ImageDataHandler(img) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets information about how the cropped image is dragged
|
* Gets information about how the cropped image is dragged
|
||||||
@@ -54,4 +54,4 @@ function ImageTransformationHandler(img) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ImageTransformationHandler;
|
module.exports = ImageDataHandler;
|
||||||
@@ -77,7 +77,7 @@ function ImageEditor(canvasId, args) {
|
|||||||
*/
|
*/
|
||||||
this.crop = function (width, height) {
|
this.crop = function (width, height) {
|
||||||
_canvas.getImage().__cropped = false;
|
_canvas.getImage().__cropped = false;
|
||||||
_canvas.getImage().transformation.removeCropData();
|
_canvas.getImageData().removeCropData();
|
||||||
_canvas.getViewport().set(width, height);
|
_canvas.getViewport().set(width, height);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function Viewport(canvas) {
|
|||||||
* Applies viewport to page
|
* Applies viewport to page
|
||||||
*/
|
*/
|
||||||
function apply() {
|
function apply() {
|
||||||
var cropData = canvas.getImage().transformation.getCropData();
|
var cropData = canvas.getImageData().getCropData();
|
||||||
canvas.remove(_rect);
|
canvas.remove(_rect);
|
||||||
|
|
||||||
_rect = new fabric.Rect({
|
_rect = new fabric.Rect({
|
||||||
@@ -139,7 +139,7 @@ function Viewport(canvas) {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
canvas.getApertures().setTransparent(true);
|
canvas.getApertures().setTransparent(true);
|
||||||
canvas.getImage().transformation.removeCropData();
|
canvas.getImageData().removeCropData();
|
||||||
|
|
||||||
// Trigger event to tell the image needs to be dragged.
|
// Trigger event to tell the image needs to be dragged.
|
||||||
$(document).trigger('PIE:needs-dragging', { axis: _data.axis });
|
$(document).trigger('PIE:needs-dragging', { axis: _data.axis });
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var Draggable = require('./Draggable');
|
var Draggable = require('./Draggable');
|
||||||
var ImageTransformationHandler = require('./ImageTransformationHandler');
|
|
||||||
var util = require('./util');
|
var util = require('./util');
|
||||||
|
|
||||||
function ExtendFabricFunctionality() {
|
function ExtendFabricFunctionality() {
|
||||||
@@ -26,13 +25,6 @@ function ExtendFabricFunctionality() {
|
|||||||
get: function() {
|
get: function() {
|
||||||
return this.__draggable || (this.__draggable = new Draggable(this));
|
return this.__draggable || (this.__draggable = new Draggable(this));
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
transformation: {
|
|
||||||
get: function() {
|
|
||||||
return this.__ImageTransformationHandler ||
|
|
||||||
(this.__ImageTransformationHandler = new ImageTransformationHandler(this));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user