modified setDefaultAttrs() so that it doesn't overwrite attrs defaulted in a custom class that extends a Kinetic class

This commit is contained in:
Eric Rowell
2012-05-12 15:15:42 -07:00
parent 28f7fc246d
commit 1146919d3d
4 changed files with 28 additions and 12 deletions

View File

@@ -124,8 +124,16 @@ Kinetic.Node.prototype = {
if(config) {
for(var key in config) {
var val = config[key];
this.attrs[key] = config[key];
/*
* only set the attr if it's undefined in case
* a developer writes a custom class that extends
* a Kinetic Class such that their default property
* isn't overwritten by the Kinetic Class default
* property
*/
if(this.attrs[key] === undefined) {
this.attrs[key] = config[key];
}
}
}
},
@@ -647,7 +655,7 @@ Kinetic.Node.prototype = {
* @param {Number} y
*/
setCenterOffset: function() {
var pos = Kinetic.GlobalObject._getPoint(arguments);
var pos = Kinetic.GlobalObject._getPoint(arguments);
this.attrs.centerOffset.x = pos.x;
this.attrs.centerOffset.y = pos.y;
},

View File

@@ -213,7 +213,7 @@ Kinetic.Stage.prototype = {
this._setDefaults();
// reset node attrs
this.setDefaultAttrs({
this.setAttrs({
visible: true,
listening: true,
name: undefined,