mirror of
https://github.com/konvajs/konva.git
synced 2025-12-05 03:24:23 +08:00
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:
23
src/Stage.js
23
src/Stage.js
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user