summaryrefslogtreecommitdiffstats
path: root/src/element.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-04-13 20:57:44 +0100
committerwout <wout@impinc.co.uk>2013-04-13 20:57:44 +0100
commit4154cf975a9a458dab4af4610010c3faddbdcad4 (patch)
tree7e5138295805bb825f331c7fa16228d8a3d9e446 /src/element.js
parent9aa9472043fa53ce11f716537a4e1eded464cc97 (diff)
downloadsvg.js-4154cf975a9a458dab4af4610010c3faddbdcad4.tar.gz
svg.js-4154cf975a9a458dab4af4610010c3faddbdcad4.zip
Ensure center point for rotations
Diffstat (limited to 'src/element.js')
-rw-r--r--src/element.js18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/element.js b/src/element.js
index b069d3a..269d61b 100644
--- a/src/element.js
+++ b/src/element.js
@@ -200,6 +200,15 @@ SVG.extend(SVG.Element, {
/* parse matrix */
o = this._parseMatrix(o)
+ /* ensure correct rotation center point */
+ if (o.rotation != null) {
+ if (o.cx == null)
+ o.cx = this.bbox().cx
+
+ if (o.cy == null)
+ o.cy = this.bbox().cy
+ }
+
/* merge values */
for (v in o)
if (o[v] != null)
@@ -221,13 +230,8 @@ SVG.extend(SVG.Element, {
transform.push('matrix(' + o.matrix + ')')
/* add rotation */
- if (o.rotation != 0) {
- transform.push(
- 'rotate(' + o.rotation + ','
- + (o.cx != null ? o.cx : this.bbox().cx) + ','
- + (o.cy != null ? o.cy : this.bbox().cy) + ')'
- )
- }
+ if (o.rotation != 0)
+ transform.push('rotate(' + o.rotation + ',' + o.cx + ',' + o.cy + ')')
/* add scale */
if (o.scaleX != 1 || o.scaleY != 1)