moved color key generation logic from Container to Shape so that it's generated immediately, instead of on add

This commit is contained in:
Eric Rowell 2012-08-20 21:55:05 -07:00
parent 0640e0b705
commit 92208d8e56
4 changed files with 28 additions and 34 deletions

29
dist/kinetic-core.js vendored
View File

@ -3,7 +3,7 @@
* http://www.kineticjs.com/
* Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Aug 19 2012
* Date: Aug 20 2012
*
* Copyright (C) 2011 - 2012 by Eric Rowell
*
@ -2490,21 +2490,6 @@ Kinetic.Container = Kinetic.Node.extend({
child.index = this.children.length;
child.parent = this;
// set color key
if(child.nodeType === 'Shape') {
var shapes = Kinetic.Global.shapes;
var key;
while(true) {
key = Kinetic.Type._getRandomColorKey();
if(key && !( key in shapes)) {
break;
}
}
child.colorKey = key;
shapes[key] = child;
}
this.children.push(child);
var stage = child.getStage();
@ -3820,6 +3805,18 @@ Kinetic.Shape = Kinetic.Node.extend({
this.nodeType = 'Shape';
this.appliedShadow = false;
// set colorKey
var shapes = Kinetic.Global.shapes;
var key;
while(true) {
key = Kinetic.Type._getRandomColorKey();
if(key && !( key in shapes)) {
break;
}
}
this.colorKey = key;
shapes[key] = this;
// call super constructor
this._super(config);
},

File diff suppressed because one or more lines are too long

View File

@ -64,21 +64,6 @@ Kinetic.Container = Kinetic.Node.extend({
child.index = this.children.length;
child.parent = this;
// set color key
if(child.nodeType === 'Shape') {
var shapes = Kinetic.Global.shapes;
var key;
while(true) {
key = Kinetic.Type._getRandomColorKey();
if(key && !( key in shapes)) {
break;
}
}
child.colorKey = key;
shapes[key] = child;
}
this.children.push(child);
var stage = child.getStage();

View File

@ -64,6 +64,18 @@ Kinetic.Shape = Kinetic.Node.extend({
this.nodeType = 'Shape';
this.appliedShadow = false;
// set colorKey
var shapes = Kinetic.Global.shapes;
var key;
while(true) {
key = Kinetic.Type._getRandomColorKey();
if(key && !( key in shapes)) {
break;
}
}
this.colorKey = key;
shapes[key] = this;
// call super constructor
this._super(config);
},