mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-12 15:53:10 +00:00
Add fabric.Object#getBoundingRect. getBoundingRectWidth/getBoundingRectHeight are deprecated.
This commit is contained in:
parent
42c857c18c
commit
69f1b20a8e
4 changed files with 59 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
39
dist/all.js
vendored
39
dist/all.js
vendored
|
|
@ -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
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 <kangax@gmail.com>",
|
||||
"keywords": ["canvas", "graphic", "graphics", "SVG", "node-canvas", "parser", "HTML5", "object model"],
|
||||
"repository": "git://github.com/kangax/fabric.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
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue