diff --git a/HEADER.js b/HEADER.js index ef808e2a..59a77f52 100644 --- a/HEADER.js +++ b/HEADER.js @@ -1,6 +1,6 @@ /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */ -var fabric = fabric || { version: "1.0.3" }; +var fabric = fabric || { version: "1.0.4" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; diff --git a/dist/all.js b/dist/all.js index 83a91618..2922b317 100644 --- a/dist/all.js +++ b/dist/all.js @@ -1,7 +1,7 @@ /* build: `node build.js modules=ALL exclude=gestures` */ /*! Fabric.js Copyright 2008-2013, Printio (Juriy Zaytsev, Maxim Chernyak) */ -var fabric = fabric || { version: "1.0.3" }; +var fabric = fabric || { version: "1.0.4" }; if (typeof exports !== 'undefined') { exports.fabric = fabric; @@ -8251,7 +8251,8 @@ fabric.util.string = { this._rotateObject(x, y); this.fire('object:rotating', { - target: this._currentTransform.target + target: this._currentTransform.target, + e: e }); this._currentTransform.target.fire('rotating'); } @@ -10085,30 +10086,50 @@ fabric.util.object.extend(fabric.StaticCanvas.prototype, /** @scope fabric.Stati && bl.y < selectionBR.y; }, - /** + /** * Returns width of an object's bounding rectangle + * @deprecated since 1.0.4 * @method getBoundingRectWidth * @return {Number} width value */ getBoundingRectWidth: function() { - this.oCoords || this.setCoords(); - var xCoords = [this.oCoords.tl.x, this.oCoords.tr.x, this.oCoords.br.x, this.oCoords.bl.x]; - var minX = fabric.util.array.min(xCoords); - var maxX = fabric.util.array.max(xCoords); - return Math.abs(minX - maxX); + return this.getBoundingRect().width; }, /** * Returns height of an object's bounding rectangle + * @deprecated since 1.0.4 * @method getBoundingRectHeight * @return {Number} height value */ getBoundingRectHeight: function() { + return this.getBoundingRect().height; + }, + + /** + * Returns coordinates of object's bounding rectangle (left, top, width, height) + * @method getBoundingRect + * @return {Object} Object with left, top, width, height properties + */ + getBoundingRect: function() { this.oCoords || this.setCoords(); + + var xCoords = [this.oCoords.tl.x, this.oCoords.tr.x, this.oCoords.br.x, this.oCoords.bl.x]; + var minX = fabric.util.array.min(xCoords); + var maxX = fabric.util.array.max(xCoords); + var width = Math.abs(minX - maxX); + var yCoords = [this.oCoords.tl.y, this.oCoords.tr.y, this.oCoords.br.y, this.oCoords.bl.y]; var minY = fabric.util.array.min(yCoords); var maxY = fabric.util.array.max(yCoords); - return Math.abs(minY - maxY); + var height = Math.abs(minY - maxY); + + return { + left: minX, + top: minY, + width: width, + height: height + }; }, /** diff --git a/package.json b/package.json index 52e9885b..1f543a2e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fabric", "description": "Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.", - "version": "1.0.3", + "version": "1.0.4", "author": "Juriy Zaytsev ", "keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"], "repository": "git://github.com/kangax/fabric.js", diff --git a/src/object_geometry.mixin.js b/src/object_geometry.mixin.js index 93aabeac..25222b2e 100644 --- a/src/object_geometry.mixin.js +++ b/src/object_geometry.mixin.js @@ -82,30 +82,50 @@ && bl.y < selectionBR.y; }, - /** + /** * Returns width of an object's bounding rectangle + * @deprecated since 1.0.4 * @method getBoundingRectWidth * @return {Number} width value */ getBoundingRectWidth: function() { - this.oCoords || this.setCoords(); - var xCoords = [this.oCoords.tl.x, this.oCoords.tr.x, this.oCoords.br.x, this.oCoords.bl.x]; - var minX = fabric.util.array.min(xCoords); - var maxX = fabric.util.array.max(xCoords); - return Math.abs(minX - maxX); + return this.getBoundingRect().width; }, /** * Returns height of an object's bounding rectangle + * @deprecated since 1.0.4 * @method getBoundingRectHeight * @return {Number} height value */ getBoundingRectHeight: function() { + return this.getBoundingRect().height; + }, + + /** + * Returns coordinates of object's bounding rectangle (left, top, width, height) + * @method getBoundingRect + * @return {Object} Object with left, top, width, height properties + */ + getBoundingRect: function() { this.oCoords || this.setCoords(); + + var xCoords = [this.oCoords.tl.x, this.oCoords.tr.x, this.oCoords.br.x, this.oCoords.bl.x]; + var minX = fabric.util.array.min(xCoords); + var maxX = fabric.util.array.max(xCoords); + var width = Math.abs(minX - maxX); + var yCoords = [this.oCoords.tl.y, this.oCoords.tr.y, this.oCoords.br.y, this.oCoords.bl.y]; var minY = fabric.util.array.min(yCoords); var maxY = fabric.util.array.max(yCoords); - return Math.abs(minY - maxY); + var height = Math.abs(minY - maxY); + + return { + left: minX, + top: minY, + width: width, + height: height + }; }, /**