mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 07:25:56 +08:00
moved color key generation logic from Container to Shape so that it's generated immediately, instead of on add
This commit is contained in:
parent
0640e0b705
commit
92208d8e56
29
dist/kinetic-core.js
vendored
29
dist/kinetic-core.js
vendored
@ -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);
|
||||
},
|
||||
|
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
@ -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();
|
||||
|
||||
|
12
src/Shape.js
12
src/Shape.js
@ -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);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user