mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 06:55:17 +08:00
Re-added Kinetic.Collection to _getNodes and a test confirming its necessity.
This commit is contained in:
parent
222addd579
commit
16c7cd2708
2
dist/kinetic-core.js
vendored
2
dist/kinetic-core.js
vendored
@ -2711,7 +2711,7 @@ Kinetic.Container.prototype = {
|
||||
* get all shapes inside container
|
||||
*/
|
||||
_getNodes: function(sel) {
|
||||
var arr = [];
|
||||
var arr = new Kinetic.Collection();
|
||||
function traverse(cont) {
|
||||
var children = cont.getChildren();
|
||||
for(var n = 0; n < children.length; n++) {
|
||||
|
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
@ -229,7 +229,7 @@ Kinetic.Container.prototype = {
|
||||
* get all shapes inside container
|
||||
*/
|
||||
_getNodes: function(sel) {
|
||||
var arr = [];
|
||||
var arr = new Kinetic.Collection();
|
||||
function traverse(cont) {
|
||||
var children = cont.getChildren();
|
||||
for(var n = 0; n < children.length; n++) {
|
||||
|
@ -649,19 +649,63 @@ Test.prototype.tests = {
|
||||
layer.add(circle);
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
|
||||
var shapes = layer.get('.myShape');
|
||||
|
||||
|
||||
test(shapes.length === 2, 'shapes array should have 2 elements');
|
||||
|
||||
|
||||
shapes.apply('setX', 200);
|
||||
|
||||
|
||||
layer.draw();
|
||||
|
||||
|
||||
shapes.each(function() {
|
||||
test(this.getX() === 200, 'shape x should be 200');
|
||||
});
|
||||
},
|
||||
'SELECTOR - set fill on array by Shape-selector': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
var circle = new Kinetic.Circle({
|
||||
x: stage.getWidth() / 2,
|
||||
y: stage.getHeight() / 2,
|
||||
radius: 70,
|
||||
fill: 'green',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
name: 'myShape'
|
||||
});
|
||||
|
||||
var rect = new Kinetic.Rect({
|
||||
x: 300,
|
||||
y: 100,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'purple',
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
name: 'myShape'
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
var shapes = layer.get('Shape');
|
||||
|
||||
test(shapes.length === 2, 'shapes array should have 2 elements');
|
||||
|
||||
shapes.apply('setFill', 'gray');
|
||||
|
||||
layer.draw();
|
||||
|
||||
shapes.each(function() {
|
||||
test(this.getFill() === 'gray', 'shape x should be 200');
|
||||
});
|
||||
},
|
||||
'SELECTOR - add listener to an array of nodes': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
|
Loading…
Reference in New Issue
Block a user