aboutsummaryrefslogtreecommitdiffstats
path: root/src/set.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-06-09 11:37:26 +0100
committerwout <wout@impinc.co.uk>2013-06-09 11:37:26 +0100
commit8f03d84e43681ecca20ac028071e51a2e2bbc0c8 (patch)
treef5c11dc6c429e8459c20731ba775fa6ca794400f /src/set.js
parentec75128ec31aa055aca2ae7f95ad4f5cf38d12e0 (diff)
downloadsvg.js-8f03d84e43681ecca20ac028071e51a2e2bbc0c8.tar.gz
svg.js-8f03d84e43681ecca20ac028071e51a2e2bbc0c8.zip
Added deep traversing, reorganizd modules
Diffstat (limited to 'src/set.js')
-rw-r--r--src/set.js37
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