Move fabric.Rect's stateProperties to prototype for more efficient memory usage

This commit is contained in:
kangax 2013-09-14 13:54:18 +02:00
parent 145f93ad9f
commit eeb0f72bd4

View file

@ -10,6 +10,9 @@
return;
}
var stateProperties = fabric.Object.prototype.stateProperties.concat();
stateProperties.push('rx', 'ry');
/**
* Rectangle class
* @class fabric.Rect
@ -18,6 +21,13 @@
*/
fabric.Rect = fabric.util.createClass(fabric.Object, /** @lends fabric.Rect.prototype */ {
/**
* List of properties to consider when checking if state of an object is changed ({@link fabric.Object#hasStateChanged})
* as well as for history (undo/redo) purposes
* @type Array
*/
stateProperties: stateProperties,
/**
* Type of an object
* @type String
@ -53,7 +63,6 @@
initialize: function(options) {
options = options || { };
this._initStateProperties();
this.callSuper('initialize', options);
this._initRxRy();
@ -61,15 +70,6 @@
this.y = options.y || 0;
},
/**
* Creates `stateProperties` list on an instance, and adds `fabric.Rect` -specific ones to it
* (such as "rx", "ry", etc.)
* @private
*/
_initStateProperties: function() {
this.stateProperties = this.stateProperties.concat(['rx', 'ry']);
},
/**
* Initializes rx/ry attributes
* @private