summaryrefslogtreecommitdiffstats
path: root/src/group.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-02-03 15:14:47 +0100
committerwout <wout@impinc.co.uk>2014-02-03 15:14:47 +0100
commite2304534e0cfb6f6f4ab8c37ea5275ae26cd455a (patch)
tree2386e9f361d9c5fa1308387aeeaf33f00241b3c5 /src/group.js
parent7a29817ffd764cf7ab6906250b57f234801c94e0 (diff)
downloadsvg.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-xsrc/group.js61
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