mirror of
https://github.com/konvajs/konva.git
synced 2025-12-04 19:08:24 +08:00
modified setDefaultAttrs() so that it doesn't overwrite attrs defaulted in a custom class that extends a Kinetic class
This commit is contained in:
14
src/Node.js
14
src/Node.js
@@ -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;
|
||||
},
|
||||
|
||||
@@ -213,7 +213,7 @@ Kinetic.Stage.prototype = {
|
||||
this._setDefaults();
|
||||
|
||||
// reset node attrs
|
||||
this.setDefaultAttrs({
|
||||
this.setAttrs({
|
||||
visible: true,
|
||||
listening: true,
|
||||
name: undefined,
|
||||
|
||||
Reference in New Issue
Block a user