diff options
Diffstat (limited to 'src/set.js')
-rw-r--r-- | src/set.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/set.js b/src/set.js new file mode 100644 index 0000000..c518c37 --- /dev/null +++ b/src/set.js @@ -0,0 +1,37 @@ +SVG.Set = function() { + this.children = [] +} + +SVG.extend(SVG.Set, { + // Add element to set + add: function(element) { + this.children.push(element) + + return this + } + // Remove element from set +, remove: function(element) { + var i = this.children.indexOf(element) + + if (i > -1) + this.children.splice(i, 1) + + return this + } + // Move all children +, move: function(x, y) { + return this.x(x).y(y) + } + +}) + +// Create method aliases +;['attr'].forEach(function(method) { + + SVG.Set.prototype[method] = function() { + for (var i = 0, il = this.children.length; i < il; i++) + this.children[i][method](arguments) + + } + +})
\ No newline at end of file |