Fix x/y not being set on rectangle sometimes. Closes #344.

This commit is contained in:
kangax 2012-12-13 15:37:11 +01:00
parent 3416d8a090
commit eb35434a97

View file

@ -11,6 +11,7 @@
}
/**
* Rectangle class
* @class Rect
* @extends fabric.Object
*/
@ -40,7 +41,7 @@
/**
* Constructor
* @method initialize
* @param options {Object} options object
* @param {Object} [options] Options object
* @return {Object} thisArg
*/
initialize: function(options) {
@ -49,6 +50,9 @@
this._initStateProperties();
this.callSuper('initialize', options);
this._initRxRy();
this.x = 0;
this.y = 0;
},
/**
@ -62,6 +66,7 @@
},
/**
* Initializes rx/ry attributes
* @private
* @method _initRxRy
*/
@ -166,7 +171,7 @@
/**
* Returns svg representation of an instance
* @method toSVG
* @return {string} svg representation of an instance
* @return {String} svg representation of an instance
*/
toSVG: function() {
return '<rect ' +
@ -179,8 +184,6 @@
}
});
// TODO (kangax): implement rounded rectangles (both parsing and rendering)
/**
* List of attribute names to account for when parsing SVG element (used by `fabric.Rect.fromElement`)
* @static
@ -197,12 +200,12 @@
}
/**
* Returns fabric.Rect instance from an SVG element
* Returns {@link fabric.Rect} instance from an SVG element
* @static
* @method fabric.Rect.fromElement
* @param element {SVGElement} element to parse
* @param options {Object} options object
* @return {fabric.Rect} instance of fabric.Rect
* @param {SVGElement} element Element to parse
* @param {Object} [options] Options object
* @return {fabric.Rect} Instance of fabric.Rect
*/
fabric.Rect.fromElement = function(element, options) {
if (!element) {
@ -219,7 +222,7 @@
};
/**
* Returns fabric.Rect instance from an object representation
* Returns {@link fabric.Rect} instance from an object representation
* @static
* @method fabric.Rect.fromObject
* @param object {Object} object to create an instance from