moved .get() method to Container so that all containers can use it, not just stage. This allows you to select nodes within other nodes

This commit is contained in:
Eric Rowell
2012-04-08 21:26:13 -07:00
parent 63c8dde6d5
commit b8516b1b0c
5 changed files with 124 additions and 60 deletions

View File

@@ -103,29 +103,6 @@ Kinetic.Stage.prototype = {
draw: function() {
this._drawChildren();
},
/**
* get selector. can select nodes by id with # and by name
* with .
* ex:
* var node = stage.get('#foo'); // selects node with id foo
* var nodes = stage.get('.bar'); // selects nodes with name bar
* @param {String} selector
*/
get: function(selector) {
var hash;
if(selector.charAt(0) === '#') {
hash = this.ids;
}
else if(selector.charAt(0) === '.') {
hash = this.names;
}
else {
return false;
}
var key = selector.slice(1);
return hash[key];
},
/**
* set stage size
* @param {int} width