mirror of
https://github.com/Hopiu/fabric.js.git
synced 2026-05-25 05:33:44 +00:00
Move fabric.Rect's stateProperties to prototype for more efficient memory usage
This commit is contained in:
parent
145f93ad9f
commit
eeb0f72bd4
1 changed files with 10 additions and 10 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue