client/js/renderer/scene.js
changeset 398 57f8d344fde9
parent 396 b51c25ef4292
child 403 96781c1a8bbe
--- a/client/js/renderer/scene.js	Fri Mar 13 13:29:02 2015 +0100
+++ b/client/js/renderer/scene.js	Fri Mar 13 16:33:49 2015 +0100
@@ -554,31 +554,31 @@
         },
         drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
             var _options = this.renkan.options,
-            _startRads = _startAngle * Math.PI / 180,
-            _endRads = _endAngle * Math.PI / 180,
-            _img = this.icon_cache[_imgname],
-            _startdx = - Math.sin(_startRads),
-            _startdy = Math.cos(_startRads),
-            _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
-            _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
-            _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
-            _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
-            _enddx = - Math.sin(_endRads),
-            _enddy = Math.cos(_endRads),
-            _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
-            _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
-            _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
-            _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
-            _centerR = (_inR + _outR) / 2,
-            _centerRads = (_startRads + _endRads) / 2,
-            _centerX = Math.cos(_centerRads) * _centerR,
-            _centerY = Math.sin(_centerRads) * _centerR,
-            _centerXIn = Math.cos(_centerRads) * _inR,
-            _centerXOut = Math.cos(_centerRads) * _outR,
-            _centerYIn = Math.sin(_centerRads) * _inR,
-            _centerYOut = Math.sin(_centerRads) * _outR,
-            _textX = Math.cos(_centerRads) * (_outR + 3),
-            _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
+                _startRads = _startAngle * Math.PI / 180,
+                _endRads = _endAngle * Math.PI / 180,
+                _img = this.icon_cache[_imgname],
+                _startdx = - Math.sin(_startRads),
+                _startdy = Math.cos(_startRads),
+                _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
+                _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
+                _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
+                _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
+                _enddx = - Math.sin(_endRads),
+                _enddy = Math.cos(_endRads),
+                _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
+                _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
+                _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
+                _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
+                _centerR = (_inR + _outR) / 2,
+                _centerRads = (_startRads + _endRads) / 2,
+                _centerX = Math.cos(_centerRads) * _centerR,
+                _centerY = Math.sin(_centerRads) * _centerR,
+                _centerXIn = Math.cos(_centerRads) * _inR,
+                _centerXOut = Math.cos(_centerRads) * _outR,
+                _centerYIn = Math.sin(_centerRads) * _inR,
+                _centerYOut = Math.sin(_centerRads) * _outR,
+                _textX = Math.cos(_centerRads) * (_outR + 3),
+                _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
             this.buttons_layer.activate();
             var _path = new paper.Path();
             _path.add([_startXIn, _startYIn]);
@@ -603,12 +603,15 @@
             }
             _text.visible = false;
             var _visible = false,
-            _restPos = new paper.Point(-200, -200),
-            _grp = new paper.Group([_path, _text]),
-            _delta = _grp.position,
-            _imgdelta = new paper.Point([_centerX, _centerY]),
-            _currentPos = new paper.Point(0,0);
+                _restPos = new paper.Point(-200, -200),
+                _grp = new paper.Group([_path, _text]),
+                //_grp = new paper.Group([_path]),
+                _delta = _grp.position,
+                _imgdelta = new paper.Point([_centerX, _centerY]),
+                _currentPos = new paper.Point(0,0);
             _text.content = _caption;
+            // set group pivot to not depend on text visibility that changes the group bounding box.
+            _grp.pivot = _grp.bounds.center;
             _grp.visible = false;
             _grp.position = _restPos;
             var _res = {