summaryrefslogtreecommitdiffstats
path: root/src/set.js
blob: c518c37f7bd4a3254611bed19b47c59bbee66b37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)

  }

})