diff options
author | wout <wout@impinc.co.uk> | 2013-03-24 19:19:06 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-03-24 19:19:06 +0100 |
commit | 67d367e0d74b3287956130da0077e42c6483dd2f (patch) | |
tree | bb2d23315e39c89b79cb8c52e7a5db54636e08ad /src/line.js | |
parent | ff09596144c3fd6770d1dc64178a10c2432396ca (diff) | |
download | svg.js-67d367e0d74b3287956130da0077e42c6483dd2f.tar.gz svg.js-67d367e0d74b3287956130da0077e42c6483dd2f.zip |
Bumped to v0.11
- removed SVG.Wrap on SVG.Polyline, SVG.Polygon and SVG.Path
- added delay on SVG.FX module
- made x(), y(), cx() and cy() as getters
- added SGB.get() method, to get elements by a DOM id
- fixed bug in remove() method on container elements
- added jasmine test suite to repo
Diffstat (limited to 'src/line.js')
-rw-r--r-- | src/line.js | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/line.js b/src/line.js index 7407983..893fe62 100644 --- a/src/line.js +++ b/src/line.js @@ -11,35 +11,37 @@ SVG.extend(SVG.Line, { x: function(x) { var b = this.bbox() - return this.attr({ - x1: this.attrs.x1 - b.x + x - , x2: this.attrs.x2 - b.x + x + return x == null ? b.x : this.attr({ + x1: this.attr('x1') - b.x + x + , x2: this.attr('x2') - b.x + x }) } // Move over y-axis , y: function(y) { var b = this.bbox() - return this.attr({ - y1: this.attrs.y1 - b.y + y - , y2: this.attrs.y2 - b.y + y + return y == null ? b.y : this.attr({ + y1: this.attr('y1') - b.y + y + , y2: this.attr('y2') - b.y + y }) } // Move by center over x-axis , cx: function(x) { - return this.x(x - this.bbox().width / 2) + var half = this.bbox().width / 2 + return x == null ? this.x() + half : this.x(x - half) } // Move by center over y-axis , cy: function(y) { - return this.y(y - this.bbox().height / 2) + var half = this.bbox().height / 2 + return y == null ? this.y() + half : this.y(y - half) } // Set line size by width and height , size: function(width, height) { var b = this.bbox() return this - .attr(this.attrs.x1 < this.attrs.x2 ? 'x2' : 'x1', b.x + width) - .attr(this.attrs.y1 < this.attrs.y2 ? 'y2' : 'y1', b.y + height) + .attr(this.attr('x1') < this.attr('x2') ? 'x2' : 'x1', b.x + width) + .attr(this.attr('y1') < this.attr('y2') ? 'y2' : 'y1', b.y + height) } -})
\ No newline at end of file +}) |