Refactor properties into methods for canvas
This commit is contained in:
@@ -17,20 +17,24 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
|
||||
});
|
||||
|
||||
this.on('mouse:up', function () {
|
||||
if (this.image.__moved) {
|
||||
this.aperture.setTransparent(false);
|
||||
if (this.getImage().__moved) {
|
||||
this.getApertures().setTransparent(false);
|
||||
}
|
||||
$(this.upperCanvasEl).css('cursor', 'default');
|
||||
this.renderAll();
|
||||
});
|
||||
},
|
||||
|
||||
get_apertures: function () {
|
||||
getApertures: function () {
|
||||
return this.__aperturehandler ||
|
||||
(this.__aperturehandler = new ApertureHandler(this));
|
||||
},
|
||||
|
||||
get_dragbars: function () {
|
||||
/**
|
||||
*
|
||||
* @returns {DragbarHandler}
|
||||
*/
|
||||
getDragbars: function () {
|
||||
return this.__dragbars ||
|
||||
(this.__dragbars = new DragbarHandler(this));
|
||||
},
|
||||
@@ -38,18 +42,29 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
|
||||
/**
|
||||
* @return {fabric.Image}
|
||||
*/
|
||||
get_image: function () {
|
||||
getImage: function () {
|
||||
return this.__image;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Viewport}
|
||||
*/
|
||||
get_viewport: function () {
|
||||
getViewport: function () {
|
||||
return this.__viewport ||
|
||||
(this.__viewport = new Viewport(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the menu for this instance
|
||||
* @returns {ButtonMenu}
|
||||
*/
|
||||
getButtonMenu: function () {
|
||||
if (!this.__buttonMenu) {
|
||||
this.__buttonMenu = new ButtonMenu(this);
|
||||
}
|
||||
return this.__buttonMenu;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return {Canvas}
|
||||
*/
|
||||
@@ -68,35 +83,11 @@ var Canvas = fabric.util.createClass(fabric.Canvas, {
|
||||
this.removeImage();
|
||||
this.__image = img;
|
||||
this.__image.addTo(this).center().on('mousedown', function () {
|
||||
img.canvas.aperture.setTransparent(true);
|
||||
img.canvas.getApertures().setTransparent(true);
|
||||
}).setCoords();
|
||||
this.viewport.reset();
|
||||
this.getViewport().reset();
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
// Define properties
|
||||
util.setProperties(Canvas.prototype, {
|
||||
aperture: {
|
||||
get: Canvas.prototype.get_apertures
|
||||
},
|
||||
dragbars: {
|
||||
get: Canvas.prototype.get_dragbars
|
||||
},
|
||||
image: {
|
||||
get: Canvas.prototype.get_image
|
||||
},
|
||||
buttonMenu: {
|
||||
get: function () {
|
||||
if (!this.__buttonMenu) {
|
||||
this.__buttonMenu = new ButtonMenu(this);
|
||||
}
|
||||
return this.__buttonMenu;
|
||||
}
|
||||
},
|
||||
viewport: {
|
||||
get: Canvas.prototype.get_viewport
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Canvas;
|
||||
|
||||
Reference in New Issue
Block a user