mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 04:42:02 +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:
parent
28f7fc246d
commit
1146919d3d
18
dist/kinetic-core.js
vendored
18
dist/kinetic-core.js
vendored
@ -3,7 +3,7 @@
|
|||||||
* http://www.kineticjs.com/
|
* http://www.kineticjs.com/
|
||||||
* Copyright 2012, Eric Rowell
|
* Copyright 2012, Eric Rowell
|
||||||
* Licensed under the MIT or GPL Version 2 licenses.
|
* Licensed under the MIT or GPL Version 2 licenses.
|
||||||
* Date: May 09 2012
|
* Date: May 12 2012
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 - 2012 by Eric Rowell
|
* Copyright (C) 2011 - 2012 by Eric Rowell
|
||||||
*
|
*
|
||||||
@ -308,8 +308,16 @@ Kinetic.Node.prototype = {
|
|||||||
|
|
||||||
if(config) {
|
if(config) {
|
||||||
for(var key in 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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -831,7 +839,7 @@ Kinetic.Node.prototype = {
|
|||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
setCenterOffset: function() {
|
setCenterOffset: function() {
|
||||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||||
this.attrs.centerOffset.x = pos.x;
|
this.attrs.centerOffset.x = pos.x;
|
||||||
this.attrs.centerOffset.y = pos.y;
|
this.attrs.centerOffset.y = pos.y;
|
||||||
},
|
},
|
||||||
@ -1496,7 +1504,7 @@ Kinetic.Stage.prototype = {
|
|||||||
this._setDefaults();
|
this._setDefaults();
|
||||||
|
|
||||||
// reset node attrs
|
// reset node attrs
|
||||||
this.setDefaultAttrs({
|
this.setAttrs({
|
||||||
visible: true,
|
visible: true,
|
||||||
listening: true,
|
listening: true,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
6
dist/kinetic-core.min.js
vendored
6
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
14
src/Node.js
14
src/Node.js
@ -124,8 +124,16 @@ Kinetic.Node.prototype = {
|
|||||||
|
|
||||||
if(config) {
|
if(config) {
|
||||||
for(var key in 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
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
setCenterOffset: function() {
|
setCenterOffset: function() {
|
||||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||||
this.attrs.centerOffset.x = pos.x;
|
this.attrs.centerOffset.x = pos.x;
|
||||||
this.attrs.centerOffset.y = pos.y;
|
this.attrs.centerOffset.y = pos.y;
|
||||||
},
|
},
|
||||||
|
@ -213,7 +213,7 @@ Kinetic.Stage.prototype = {
|
|||||||
this._setDefaults();
|
this._setDefaults();
|
||||||
|
|
||||||
// reset node attrs
|
// reset node attrs
|
||||||
this.setDefaultAttrs({
|
this.setAttrs({
|
||||||
visible: true,
|
visible: true,
|
||||||
listening: true,
|
listening: true,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user