aboutsummaryrefslogtreecommitdiffstats
path: root/src/wrap.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/wrap.js')
-rw-r--r--src/wrap.js56
1 files changed, 26 insertions, 30 deletions
diff --git a/src/wrap.js b/src/wrap.js
index 4f785cd..85a09a6 100644
--- a/src/wrap.js
+++ b/src/wrap.js
@@ -1,54 +1,51 @@
-
-function Wrap(e) {
+function Wrap(element) {
this.constructor.call(this, SVG.create('g'));
- // insert and store child
- this.node.insertBefore(e.node, null);
- this.child = e;
+ /* insert and store child */
+ this.node.insertBefore(element.node, null);
+ this.child = element;
};
// inherit from SVG.Shape
Wrap.prototype = new SVG.Shape();
-// include the container object
SVG.extend(Wrap, {
-
- // move wrapper around
+ // Move wrapper around
move: function(x, y) {
return this.center(
x + (this._b.width * this.child.trans.scaleX) / 2,
y + (this._b.height * this.child.trans.scaleY) / 2
);
},
-
- // set the actual size in pixels
- size: function(w, h) {
- var s = w / this._b.width;
+ // Set the actual size in pixels
+ size: function(width, height) {
+ var scale = width / this._b.width;
this.child.transform({
- scaleX: s,
- scaleY: h != null ? h / this._b.height : s
+ scaleX: scale,
+ scaleY: height != null ? height / this._b.height : scale
});
return this;
},
-
- // move by center
+ // Move by center
center: function(x, y) {
- return this.transform({ x: x, y: y });
+ return this.transform({
+ x: x,
+ y: y
+ });
},
-
- // create distributed attr
+ // Create distributed attr
attr: function(a, v, n) {
- // call individual attributes if an object is given
+ /* call individual attributes if an object is given */
if (typeof a == 'object') {
for (v in a) this.attr(v, a[v]);
- // act as a getter if only one argument is given
+ /* act as a getter if only one argument is given */
} else if (arguments.length < 2) {
return a == 'transform' ? this.attrs[a] : this.child.attrs[a];
- // apply locally for certain attributes
+ /* apply locally for certain attributes */
} else if (a == 'transform') {
this.attrs[a] = v;
@@ -56,23 +53,22 @@ SVG.extend(Wrap, {
this.node.setAttributeNS(n, a, v) :
this.node.setAttribute(a, v);
- // apply attributes to child
+ /* apply attributes to child */
} else {
this.child.attr(a, v, n);
}
return this;
},
-
- // distribute plot method to child
- plot: function(d) {
- // plot new shape
- this.child.plot(d);
+ // Distribute plot method to child
+ plot: function(data) {
+ /* plot new shape */
+ this.child.plot(data);
- // get new bbox and store size
+ /* get and store new bbox */
this._b = this.child.bbox();
- // reposition element withing wrapper
+ /* reposition element withing wrapper */
this.child.transform({
x: -this._b.cx,
y: -this._b.cy