diff options
author | wout <wout@impinc.co.uk> | 2014-02-03 15:14:47 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-02-03 15:14:47 +0100 |
commit | e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a (patch) | |
tree | 2386e9f361d9c5fa1308387aeeaf33f00241b3c5 /src/group.js | |
parent | 7a29817ffd764cf7ab6906250b57f234801c94e0 (diff) | |
download | svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.tar.gz svg.js-e2304534e0cfb6f6f4ab8c37ea5275ae26cd455a.zip |
Implemented SVG.invent function and bumped to v1.0rc3
Diffstat (limited to 'src/group.js')
-rwxr-xr-x | src/group.js | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/src/group.js b/src/group.js index 6f2d502..cfb99ac 100755 --- a/src/group.js +++ b/src/group.js @@ -1,36 +1,35 @@ -SVG.G = function() { - this.constructor.call(this, SVG.create('g')) -} +SVG.G = SVG.invent({ + // Initialize node + create: 'g' -// Inherit from SVG.Container -SVG.G.prototype = new SVG.Container - -// -SVG.extend(SVG.G, { - // Move over x-axis - x: function(x) { - return x == null ? this.trans.x : this.transform('x', x) - } - // Move over y-axis -, y: function(y) { - return y == null ? this.trans.y : this.transform('y', y) - } - // Move by center over x-axis -, cx: function(x) { - return x == null ? this.bbox().cx : this.x(x - this.bbox().width / 2) - } - // Move by center over y-axis -, cy: function(y) { - return y == null ? this.bbox().cy : this.y(y - this.bbox().height / 2) - } + // Inherit from +, inherit: SVG.Container -}) - -// -SVG.extend(SVG.Container, { - // Create a group element - group: function() { - return this.put(new SVG.G) + // Add class methods +, extend: { + // Move over x-axis + x: function(x) { + return x == null ? this.trans.x : this.transform('x', x) + } + // Move over y-axis + , y: function(y) { + return y == null ? this.trans.y : this.transform('y', y) + } + // Move by center over x-axis + , cx: function(x) { + return x == null ? this.bbox().cx : this.x(x - this.bbox().width / 2) + } + // Move by center over y-axis + , cy: function(y) { + return y == null ? this.bbox().cy : this.y(y - this.bbox().height / 2) + } } + // Add parent method +, construct: { + // Create a group element + group: function() { + return this.put(new SVG.G) + } + } })
\ No newline at end of file |