summaryrefslogtreecommitdiffstats
path: root/src/relative.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-01-30 19:44:40 +0100
committerwout <wout@impinc.co.uk>2014-01-30 19:44:40 +0100
commitbd7e10cb46e0cb113983c69f4f48c7a42a776809 (patch)
tree37ad5746b3e66879a33b6fe85c5e5718ec58a18b /src/relative.js
parentf6fc66659d0fc391442f58e8c82f965b38995725 (diff)
downloadsvg.js-bd7e10cb46e0cb113983c69f4f48c7a42a776809.tar.gz
svg.js-bd7e10cb46e0cb113983c69f4f48c7a42a776809.zip
Added `relative()`method for relative translations
Diffstat (limited to 'src/relative.js')
-rw-r--r--src/relative.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/relative.js b/src/relative.js
new file mode 100644
index 0000000..2d02c08
--- /dev/null
+++ b/src/relative.js
@@ -0,0 +1,28 @@
+//
+SVG.extend(SVG.Element, SVG.FX, {
+ // Relative methods
+ relative: function() {
+ var b, e = this
+
+ return {
+ // Move over x axis
+ x: function(x) {
+ b = e.bbox()
+
+ return e.x(b.x + (x || 0))
+ }
+ // Move over y axis
+ , y: function(y) {
+ b = e.bbox()
+
+ return e.y(b.y + (y || 0))
+ }
+ // Move over x and y axes
+ , move: function(x, y) {
+ this.x(x)
+ return this.y(y)
+ }
+ }
+ }
+
+}) \ No newline at end of file